Used to play audio resources (i.e. tracks, streams) to voice connections.
Remarks
Audio players are designed to be re-used - even if a resource has finished playing, the player itself can still be used.The AudioPlayer drives the timing of playback, and therefore is unaffected by voice connections becoming unavailable. Its behavior in these scenarios can be configured.Extends
EventEmitterCreates a new AudioPlayer.
Name | Type | Optional | Description |
---|---|---|---|
options | CreateAudioPlayerOptions | Yes | None |
Checks whether the underlying resource (if any) is playable (readable)
Returns
true
if the resource is playable, otherwise false
Pauses playback of the current resource, if any.
Returns
true
if the player was successfully paused, otherwise false
Name | Type | Optional | Description |
---|---|---|---|
interpolateSilence | boolean | Yes | If true, the player will play 5 packets of silence after pausing to prevent audio glitches |
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.Name | Type | Optional | Description |
---|---|---|---|
resource | AudioResource<Metadata> | No | The resource to play |
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.
Returns
true
if the player will come to a stop, otherwise false
Name | Type | Optional | Description |
---|---|---|---|
force | boolean | Yes | If true, will force the player to enter the Idle state even if the resource has silence padding frames |
Unpauses playback of the current resource, if any.
Returns
true
if the player was successfully unpaused, otherwise false
Emitted when there is an error emitted from the audio resource played by the audio player
Name | Type | Optional | Description |
---|---|---|---|
event | 'error' | No | None |
listener | (error: AudioPlayerError) => void | No | None |