Skip to main content
A playback instance returned by Audio:play*, with controls for transport and volume.

Fields

volume

volume of the sound.
function update(self: AudioScript)
  -- updates the volume for AudioSound playback when the input is changed
  if self.soundInstance then
    self.soundInstance.volume = self.volumeNumber / 100
  end
end

Methods

stop

stop(fadeToStopTime: number?) -> ()
stop the audio
function stopSound(self: AudioScript)
  if self.soundInstance then
    self.soundInstance:stop()
  end
end

seek

seek(seconds: number) -> ()
seek the audio to a specific time in seconds.
if self.soundInstance then
  self.soundInstance:seek(self.seekSeconds)
end

seekFrame

seekFrame(frame: number) -> ()
seek the audio to a specific time in PCM frames.
if self.soundInstance then
  self.soundInstance:seekFrame(self.seekFrameNumber)
end

completed

completed() -> boolean
Whether the sound has completed playing.
function advance(self: AudioScript, seconds: number): boolean
  if self.soundInstance then
    self.isCompleted = self.soundInstance:completed()      -- whether playback has finished
  end
  return true
end

time

time() -> number
Current sound time in seconds.
function advance(self: AudioScript, seconds: number): boolean
  if self.soundInstance then
    self.currentTime = self.soundInstance:time()           -- current playback time in seconds
  end
  return true
end

timeFrame

timeFrame() -> number
Current sound time in PCM frames.
function advance(self: AudioScript, seconds: number): boolean
  if self.soundInstance then
    self.currentTimeFrame = self.soundInstance:timeFrame() -- current playback time in PCM frames
  end
  return true
end

pause

pause() -> ()
pauses the audio.
function pauseSound(self: AudioScript)
  if self.soundInstance then
    self.soundInstance:pause()
  end
end

resume

resume() -> ()
resumes the audio from its current position.
function resumeSound(self: AudioScript)
  if self.soundInstance then
    self.soundInstance:resume()
  end
end

play

play() -> ()
plays the audio.
function playSound(self: AudioScript)
  if self.soundInstance then
    self.soundInstance:play()
  end
end