Discord Player

AudioPlayer

Used to play audio resources (i.e. tracks, streams) to voice connections.

AudioPlayer extends EventEmitter

Used to play audio resources (i.e. tracks, streams) to voice connections.

new AudioPlayer(options);
ParameterTypeOptional
optionsCreateAudioPlayerOptions

Properties

public playable: any

A list of subscribed voice connections that can currently receive audio to play.

public state: any

The state that the player is in.

Methods

public checkPlayable(): boolean

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

public on(event, listener): this

Emitted when there is an error emitted from the audio resource played by the audio player

ParameterTypeOptional
event'error'
listener( error: AudioPlayerError ) => void

public pause(interpolateSilence): boolean

Pauses playback of the current resource, if any.

ParameterTypeOptionalDescription
interpolateSilencebooleanIf true, the player will play 5 packets of silence after pausing to prevent audio glitches

public 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.

ParameterTypeOptionalDescription
resourceAudioResource<Metadata>The resource to play

public 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.

ParameterTypeOptionalDescription
forcebooleanIf true, will force the player to enter the Idle state even if the resource has silence padding frames

public unpause(): boolean

Unpauses playback of the current resource, if any.

On this page