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
booleanpause
Pauses playback. Can be resumed by calling
play.Signature
pause()Returns
voidplay
Starts playback.
Signature
play()Returns
voidsetBuffer
Sets the audio buffer to be played back from.
Signature
setBuffer(buffer: AudioBuffer)| Name | Type | Description |
|---|---|---|
buffer | AudioBuffer | new audio buffer |
Returns
voidsetLoop
Sets whether or not the audio should be looped.
Signature
setLoop(shouldLoop: boolean)| Name | Type | Description |
|---|---|---|
shouldLoop | boolean | loop status to set |
Returns
voidstop
Stops playback. The next
play call will playback the buffer from the beginning.Signature
stop()Returns
voidtogglePlayback
Starts playback if not playing currently, stops playback otherwise.
Signature
togglePlayback()Returns
void