Class: StreamDispatcher

StreamDispatcher

The class that sends voice packet data to the voice connection. ```js // Obtained using: voiceChannel.join().then(connection => { // You can play a file or a stream here: const dispatcher = connection.play('/home/hydrabolt/audio.mp3'); }); ```

Constructor

new StreamDispatcher()

Implements:
Source:

Extends

  • WritableStream

Members

(readonly) bitrateEditable :boolean

Whether or not the Opus bitrate of this stream is editable
Type:
  • boolean
Source:

(nullable) broadcast :VoiceBroadcast

The broadcast controlling this dispatcher, if any
Type:
Source:

(readonly) paused :boolean

Whether or not playback is paused
Type:
  • boolean
Source:

(nullable) pausedSince :number

The time that the stream was paused at (null if not paused)
Type:
  • number
Source:

(readonly) pausedTime :number

Total time that this dispatcher has been paused in milliseconds
Type:
  • number
Source:

player :AudioPlayer

The Audio Player that controls this dispatcher
Type:
Source:

(readonly) streamTime :number

The time (in milliseconds) that the dispatcher has actually been playing audio for
Type:
  • number
Source:

(readonly) totalStreamTime :number

The time (in milliseconds) that the dispatcher has been playing audio for, taking into account skips and pauses
Type:
  • number
Source:

(readonly) volume :number

The current volume of the stream
Type:
  • number
Implements:
Source:

(readonly) volumeDecibels :number

The current volume of the stream in decibels
Type:
  • number
Implements:
Source:

(readonly) volumeEditable :boolean

Whether or not the volume of this stream is editable
Type:
  • boolean
Implements:
Source:

(readonly) volumeLogarithmic :number

The current volume of the stream from a logarithmic scale
Type:
  • number
Implements:
Source:

Methods

pause(silenceopt)

Pauses playback
Parameters:
Name Type Attributes Default Description
silence boolean <optional>
false Whether to play silence while paused to prevent audio glitches
Source:

resume()

Resumes playback
Source:

setBitrate(value) → {boolean}

Set the bitrate of the current Opus encoder if using a compatible Opus stream.
Parameters:
Name Type Description
value number New bitrate, in kbps If set to 'auto', the voice channel's bitrate will be used
Source:
Returns:
true if the bitrate has been successfully changed.
Type
boolean

setFEC(enabled) → {boolean}

Enables or disables forward error correction if using a compatible Opus stream.
Parameters:
Name Type Description
enabled boolean true to enable
Source:
Returns:
Returns true if it was successfully set.
Type
boolean

setPLP(value) → {boolean}

Sets the expected packet loss percentage if using a compatible Opus stream.
Parameters:
Name Type Description
value number between 0 and 1
Source:
Returns:
Returns true if it was successfully set.
Type
boolean

setVolume(volume)

Sets the volume relative to the input stream - i.e. 1 is normal, 0.5 is half, 2 is double.
Parameters:
Name Type Description
volume number The volume that you want to set
Implements:
Source:

setVolumeDecibels(db)

Sets the volume in decibels.
Parameters:
Name Type Description
db number The decibels
Implements:
Source:

setVolumeLogarithmic(value)

Sets the volume so that a perceived value of 0.5 is half the perceived volume etc.
Parameters:
Name Type Description
value number The value for the volume
Implements:
Source:

Events

debug

Emitted whenever the dispatcher has debug information.
Parameters:
Name Type Description
info string The debug info
Source:

error

Emitted when the dispatcher encounters an error.
Source:

speaking

Emitted when the dispatcher starts/stops speaking.
Parameters:
Name Type Description
value boolean Whether or not the dispatcher is speaking
Source:

start

Emitted once the stream has started to play.
Source:

volumeChange

Emitted when the volume of this dispatcher changes.
Parameters:
Name Type Description
oldVolume number The old volume of this dispatcher
newVolume number The new volume of this dispatcher
Implements:
Source: