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 endend
Methods
stop
stop(fadeToStopTime: number?) -> ()
Stops the audio, fading out over fadeToStopTime PCM frames. Omit it
to stop at once. A sound that has not started yet stops at once
whatever the fade.
function stopSound(self: AudioScript) if self.soundInstance then self.soundInstance:stop() endend
seek
seek(seconds: number) -> boolean
Seeks the audio to a specific time in seconds. Returns false when the
sound was disposed or the seek failed.
if self.soundInstance then self.soundInstance:seek(self.seekSeconds)end
seekFrame
seekFrame(frame: number) -> boolean
Seeks the audio to a specific time in PCM frames. Returns false when
the sound was disposed or the seek failed.
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 trueend
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 trueend
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 trueend
pause
pause() -> ()
pauses the audio.
function pauseSound(self: AudioScript) if self.soundInstance then self.soundInstance:pause() endend
resume
resume() -> ()
resumes the audio from its current position.
function resumeSound(self: AudioScript) if self.soundInstance then self.soundInstance:resume() endend
play
play() -> ()
plays the audio.
function playSound(self: AudioScript) if self.soundInstance then self.soundInstance:play() endend