atmoky Engage Server SDK is now available! Check out the documentation to learn more.
API Reference
Classes
AudioFile

AudioFile

Summary
AudioPlayer that handles loading and playback of audio files.
Remarks
Like AudioPlayer this class acts as an AudioNode which can be used as an input to AudioObject instances.

Constructor

Constructs an AudioFile instance.
Signature
new AudioFile(context: BaseAudioContext)
NameTypeDescription
contextBaseAudioContextAudioContext to use

Methods

isPlaying

Returns true if the player is currently playing, false otherwise.
Signature
isPlaying()
Returns
boolean

load

Loads audio data from a file or URL. Can be configured to start playback when loading is complete.
Signature
load(path: string | URL, shouldPlayOnLoad?: boolean)
NameTypeDescription
pathstring | URL
shouldPlayOnLoad optionalboolean
Returns
Promise<void>
💡
If playback is already running and load is called again with shouldPlayOnLoad = true, then playback of the previous buffer stops and the new buffer is played back immediately.

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)
NameTypeDescription
bufferAudioBuffernew audio buffer
Returns
void

setLoop

Sets whether or not the audio should be looped.
Signature
setLoop(shouldLoop: boolean)
NameTypeDescription
shouldLoopbooleanloop 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

atmoky Logo

© 2024 atmoky, GmbH.
All rights reserved.

We use cookies to measure and improve your browsing experience, and serve personalized ads or content.