Skip to main content
Dropping the Player (prevent this by holding a reference) stops all its sounds.

Constructor

Returns

Player

Properties

boolean
required
Whether the player is currently paused. Players can be paused and resumed using pause() and play().
number
required
Playback speed of the sound.Increasing the speed will increase the pitch by the same factor. For example, speed 0.5 halves the frequency (lowering pitch) and speed 2 doubles it (raising pitch). Changes in speed affect the total duration inversely.
number
required
Volume of the sound.The value 1.0 is the “normal” volume (unfiltered input). Any value other than 1.0 will multiply each sample by this value.

Methods

appendFile()

Decodes an audio file and appends it to the playback queue. Supports WAV, MP3, FLAC, Vorbis/OGG, and other formats depending on build features.

Parameters

string
required

appendSamples()

Appends a sound to the queue of sounds to play.

Parameters

SamplesBuffer
required

clear()

Removes all currently loaded sources from the player and pauses it.

empty()

Returns true if this player has no more sounds to play.

Returns

boolean

getPos()

Returns the position of the sound that’s being played, in milliseconds. This takes into account any speedup or delay applied. Example: if you apply a speedup of 2 to a source and getPos() returns 5000 then the position in the recording is 10 seconds from its start.

Returns

number

len()

Returns the number of sounds currently in the queue.

Returns

number

pause()

Pauses playback of this player. No effect if already paused. A paused player can be resumed with play().

play()

Resumes playback of a paused player. No effect if not paused.

skipOne()

Skips to the next source in the player. If there are more sources appended to the player at the time, it will play the next one. Otherwise, the player will finish as if it had finished playing a source all the way through.

sleepUntilEnd()

Sleeps the current thread until the sound ends.

stop()

Stops the player by emptying the queue.

trySeek()

Attempts to seek to the given position (in milliseconds) in the current source. This blocks between 0 and ~5 milliseconds. As long as the duration of the source is known, seek is guaranteed to saturate at the end of the source. For example given a source that reports a total duration of 42 seconds, calling trySeek(60000) will seek to 42 seconds.

Parameters

number
required