AudioPlayer
Summary
Class playing back an AudioBuffer with handy controls like play and pause.Remarks
This class acts as an AudioNode and can be used as an input to an AudioObject.Constructor
Constructs an AudioPlayer instance.
Signature
new AudioPlayer(context: BaseAudioContext)
Name | Type | Description |
---|---|---|
context | BaseAudioContext | AudioContext to use |
Methods
isPlaying
Returns true if the player is currently playing, false otherwise.
Signature
isPlaying()
Returns
boolean
pause
Pauses playback. Can be resumed by calling
play
.Signature
pause()
Returns
void
play
Starts playback.
Signature
play()
Returns
void
setBuffer
Sets the audio buffer to be played back from.
Signature
setBuffer(buffer: AudioBuffer)
Name | Type | Description |
---|---|---|
buffer | AudioBuffer | new audio buffer |
Returns
void
setLoop
Sets whether or not the audio should be looped.
Signature
setLoop(shouldLoop: boolean)
Name | Type | Description |
---|---|---|
shouldLoop | boolean | loop status to set |
Returns
void
stop
Stops playback. The next
play
call will playback the buffer from the beginning.Signature
stop()
Returns
void
togglePlayback
Starts playback if not playing currently, stops playback otherwise.
Signature
togglePlayback()
Returns
void