Search...

AudioPlayer

Used to play audio resources (i.e. tracks, streams) to voice connections.
declare class AudioPlayer extends EventEmitter 
declare class AudioPlayer extends EventEmitter 

Extends

EventEmitter

constructor(options?)

Creates a new AudioPlayer.
NameTypeOptionalDescription
optionsCreateAudioPlayerOptionsYesNone
Readonly

playable

:

VoiceConnection[]

A list of subscribed voice connections that can currently receive audio to play.
The state that the player is in.

checkPlayable()

:

boolean

Checks whether the underlying resource (if any) is playable (readable)

pause(interpolateSilence?)

:

boolean

Pauses playback of the current resource, if any.
NameTypeOptionalDescription
interpolateSilencebooleanYesIf true, the player will play 5 packets of silence after pausing to prevent audio glitches

play(resource)

:

void

Plays a new resource on the player. If the player is already playing a resource, the existing resource is destroyed (it cannot be reused, even in another player) and is replaced with the new resource.
Remarks
The player will transition to the Playing state once playback begins, and will return to the Idle state once playback is ended.If the player was previously playing a resource and this method is called, the player will not transition to the Idle state during the swap over.
Will throw if attempting to play an audio resource that has already ended, or is being played by another player
NameTypeOptionalDescription
resourceAudioResource<T>NoThe resource to play

stop(force?)

:

boolean

Stops playback of the current resource and destroys the resource. The player will either transition to the Idle state, or remain in its current state until the silence padding frames of the resource have been played.
NameTypeOptionalDescription
forcebooleanYesIf true, will force the player to enter the Idle state even if the resource has silence padding frames

unpause()

:

boolean

Unpauses playback of the current resource, if any.