VoiceClient
        
        extends EventEmitter
    
    
            
            in package
            
        
    
    
    
The Discord voice client.
Tags
Table of Contents
Constants
- SILENCE_FRAME = "\xf8\xff\xfe"
 - The Opus Silence Frame.
 - SUPPORTED_MODES = ['aead_aes256_gcm_rtpsize', 'aead_xchacha20_poly1305_rtpsize']
 - Supported encryption modes for voice connections.
 - VOICE_OP_HANDLERS = [\Discord\WebSockets\Op::VOICE_READY => 'handleReady', \Discord\WebSockets\Op::VOICE_SESSION_DESCRIPTION => 'handleSessionDescription', \Discord\WebSockets\Op::VOICE_SPEAKING => 'handleSpeaking', \Discord\WebSockets\Op::VOICE_HEARTBEAT_ACK => 'heartbeatAck', \Discord\WebSockets\Op::VOICE_HELLO => 'handleHello', \Discord\WebSockets\Op::VOICE_RESUMED => 'handleResumed', \Discord\WebSockets\Op::VOICE_CLIENT_CONNECT => 'handleClientConnect', \Discord\WebSockets\Op::VOICE_CLIENT_DISCONNECT => 'handleClientDisconnect', \Discord\WebSockets\Op::VOICE_CLIENT_UNKNOWN_15 => 'handleAny', \Discord\WebSockets\Op::VOICE_CLIENT_UNKNOWN_18 => 'handleFlags', \Discord\WebSockets\Op::VOICE_CLIENT_PLATFORM => 'handlePlatform', \Discord\WebSockets\Op::VOICE_DAVE_PREPARE_TRANSITION => 'handleDavePrepareTransition', \Discord\WebSockets\Op::VOICE_DAVE_EXECUTE_TRANSITION => 'handleDaveExecuteTransition', \Discord\WebSockets\Op::VOICE_DAVE_TRANSITION_READY => 'handleDaveTransitionReady', \Discord\WebSockets\Op::VOICE_DAVE_PREPARE_EPOCH => 'handleDavePrepareEpoch', \Discord\WebSockets\Op::VOICE_DAVE_MLS_EXTERNAL_SENDER => 'handleDaveMlsExternalSender', \Discord\WebSockets\Op::VOICE_DAVE_MLS_KEY_PACKAGE => 'handleDaveMlsKeyPackage', \Discord\WebSockets\Op::VOICE_DAVE_MLS_PROPOSALS => 'handleDaveMlsProposals', \Discord\WebSockets\Op::VOICE_DAVE_MLS_COMMIT_WELCOME => 'handleDaveMlsCommitWelcome', \Discord\WebSockets\Op::VOICE_DAVE_MLS_ANNOUNCE_COMMIT_TRANSITION => 'handleDaveMlsAnnounceCommitTransition', \Discord\WebSockets\Op::VOICE_DAVE_MLS_WELCOME => 'handleDaveMlsWelcome', \Discord\WebSockets\Op::VOICE_DAVE_MLS_INVALID_COMMIT_WELCOME => 'handleDaveMlsInvalidCommitWelcome', \Discord\WebSockets\Op::CLOSE_VOICE_DISCONNECTED => 'handleCloseVoiceDisconnected']
 - Dispatch table mapping Discord Voice Gateway opcodes to handler methods.
 
Properties
- $client : Socket
 - The UDP client.
 - $receiveStreams : array<string|int, ReceiveStream>
 - Voice audio receive streams.
 - $speakingStatus : ExCollectionInterface<string|int, Speaking>|array<string|int, Speaking>
 - Collection of the status of people speaking.
 - $ssrc : int
 - The SSRC value.
 - $voiceDecoders : array<string|int, Process>
 - Array of voice decoders.
 - $audioApplication : string
 - The audio application to encode with.
 - $buffer : Buffer
 - Audio Buffer.
 - $channel_id : string
 - The Channel that we are connecting to.
 - $data : array<string|int, mixed>
 - Data from the main WebSocket.
 - $deaf : bool
 - Whether we are set as deaf.
 - $discord : Discord
 - The Discord client.
 - $dnsConfig : Config|string
 - The configuration for DNS Resolver.
 - $endpoint : string
 - The Voice WebSocket endpoint.
 - $ffmpeg : string
 - The FFmpeg binary location.
 - $frameSize : int
 - The size of audio frames, in milliseconds.
 - $guild_id : string
 - The ID of the Channel's Guild.
 - $heartbeat : TimerInterface
 - The Voice WebSocket heartbeat timer.
 - $heartbeat_interval : int
 - The UDP heartbeat interval.
 - $heartbeatSeq : int
 - The UDP heartbeat sequence.
 - $mainWebsocket : WebSocket
 - The main WebSocket instance.
 - $mode : string
 - The Voice WebSocket mode.
 - $mute : bool
 - Whether we are set as mute.
 - $paused : bool
 - Whether the voice client is currently paused.
 - $protocol : string
 - The Voice connection protocol.
 - $readOpusTimer : TimerInterface|null
 - readopus Timer.
 - $ready : bool
 - Is the voice client ready?
 - $reconnecting : bool
 - Is the voice client reconnecting?
 - $secret_key : string
 - The secret key used for encrypting voice.
 - $sentLoginFrame : bool
 - Have we sent the login frame yet?
 - $seq : int
 - The sequence of audio packets being sent.
 - $silenceRemaining : int
 - Silence Frame Remain Count.
 - $speaking : bool
 - Are we currently set as speaking?
 - $startTime : int
 - The time we started sending packets.
 - $streamTime : int
 - The stream time of the last packet.
 - $supportedModes : array<string|int, string>
 - The supported transport encryption modes the voice server expects.
 - $timestamp : int
 - The timestamp of the last packet.
 - $udpHeartbeat : TimerInterface
 - The UDP heartbeat timer.
 - $udpIp : string
 - The IP the UDP client will use.
 - $udpPort : int
 - The port the UDP client will use.
 - $userClose : bool
 - Is the voice client being closed by user?
 - $version : int
 - The Discord voice gateway version.
 - $voice_sessions : array<string|int, string>
 - The array of voice session IDs.
 - $voiceWebsocket : WebSocket
 - The voice WebSocket instance.
 - $volume : int
 - The volume the audio will be encoded with.
 
Methods
- __construct() : mixed
 - Constructs the Voice Client instance.
 - close() : void
 - Closes the voice client.
 - decodeVoicePacket() : void
 - Decodes voice packet data.
 - ffmpegEncode() : Process
 - Creates a process that will run FFmpeg and encode `$filename` into Ogg Opus format.
 - getChannel() : Channel
 - Returns the connected channel.
 - getGuild() : Guild
 - Returns the connected guild.
 - getReceiveStream() : ReceiveStream
 - Gets a receive voice stream.
 - getRecieveStream() : RecieveStream
 - Gets a receive voice stream.
 - handleAny() : void
 - Handles the any event from the voice server.
 - handleVoiceServerChange() : void
 - Handles a voice server change.
 - handleVoiceStateUpdate() : void
 - Handles a voice state update.
 - handleWebSocketClose() : void
 - Handles a WebSocket close.
 - handleWebSocketConnection() : void
 - Handles a WebSocket connection.
 - handleWebSocketError() : void
 - Handles a WebSocket error.
 - initSockets() : void
 - Initilizes the WebSocket and UDP socket.
 - isPaused() : bool
 - Checks if we are paused.
 - isReady() : bool
 - Returns whether the voice client is ready.
 - isSpeaking() : bool
 - Checks if the user is speaking.
 - pause() : PromiseInterface
 - Pauses the current sound.
 - playFile() : PromiseInterface
 - Plays a file/url on the voice stream.
 - playOggStream() : PromiseInterface
 - Plays an Ogg Opus stream.
 - playRawStream() : PromiseInterface
 - Plays a raw PCM16 stream.
 - readOpus() : mixed
 - Reads and processes Opus audio packets from an OGG stream.
 - setAudioApplication() : void
 - Sets the audio application.
 - setBitrate() : void
 - Sets the bitrate.
 - setMode() : void
 - Sets the transport encryption mode for the voice client.
 - setMuteDeaf() : void
 - Changes your mute and deaf value.
 - setSpeaking() : void
 - Sets the speaking value of the client.
 - setVolume() : void
 - Sets the volume.
 - start() : bool|void
 - Starts the voice client.
 - stop() : PromiseInterface
 - Stops the current sound.
 - switchChannel() : void
 - Switches voice channels.
 - unpause() : PromiseInterface
 - Unpauses the current sound.
 - __insertSilence() : void
 - Inserts silence frames recursively.
 - checkForExecutable() : string|null
 - Checks if an executable exists on the system.
 - checkForFFmpeg() : bool
 - Checks if FFmpeg is installed.
 - checkForLibsodium() : bool
 - Checks if libsodium-php is installed.
 - createDecoder() : Process|null
 - Creates and starts a decoder process for the given stream source.
 - decodeUDP() : void
 - Decodes a UDP message to extract the IP address and port, then selects the protocol for voice communication.
 - decryptVoicePacket() : string|false
 - Decrypts a voice packet received from Discord.
 - generateCommit() : mixed
 - generateKeyPackage() : mixed
 - generateWelcome() : mixed
 - handleAudioData() : void
 - Handles raw opus data from the UDP server.
 - handleClientConnect() : void
 - Handles the event when a client connects to the voice server.
 - handleClientDisconnect() : void
 - Handles the event when a client disconnects from the voice server.
 - handleCloseVoiceDisconnected() : void
 - handleDaveExecuteTransition() : void
 - handleDaveMlsAnnounceCommitTransition() : void
 - handleDaveMlsCommitWelcome() : void
 - handleDaveMlsExternalSender() : mixed
 - handleDaveMlsInvalidCommitWelcome() : void
 - handleDaveMlsKeyPackage() : void
 - handleDaveMlsProposals() : void
 - handleDaveMlsWelcome() : void
 - handleDavePrepareEpoch() : void
 - handleDavePrepareTransition() : void
 - handleDaveTransitionReady() : void
 - handleFlags() : void
 - Handles the flags event from the voice server.
 - handleHello() : void
 - Handles the "Hello" event from the Discord voice server.
 - handlePlatform() : void
 - Handles the platform event from the voice server.
 - handleReady() : void
 - Handles the "ready" event for the voice client, initializing UDP connection and heartbeat.
 - handleResumed() : void
 - Handles the 'resumed' event for the voice client.
 - handleSessionDescription() : void
 - Handles the session description packet received from the Discord voice server.
 - handleSpeaking() : void
 - Handles the speaking state of a user.
 - handleUndocumented() : void
 - Handles undocumented voice opcodes not intended for use by bots.
 - heartbeat() : void
 - Sends a heartbeat payload to the voice server to maintain the connection.
 - heartbeatAck() : void
 - Handles the heartbeat acknowledgement from the voice WebSocket connection.
 - identify() : void
 - Sends an identify payload to the voice gateway to authenticate the client.
 - insertSilence() : PromiseInterface
 - Sends five frames of Opus silence to avoid unintended interpolation when there is a break in the sent data.
 - mainSend() : void
 - Sends a message to the main websocket.
 - removeDecoder() : mixed
 - Removes the voice decoder associated with the given SSRC.
 - reset() : void
 - Resets the voice client.
 - resume() : void
 - Resumes a previously established voice connection.
 - selectProtocol() : void
 - Selects the UDP protocol for the voice connection and sends the selection payload.
 - send() : void
 - Sends a message to the voice websocket.
 - sendBuffer() : void
 - Sends a buffer to the UDP socket.
 
Constants
SILENCE_FRAME
The Opus Silence Frame.
    public
        string
    SILENCE_FRAME
    = "\xf8\xff\xfe"
    
        The silence frame.
Tags
SUPPORTED_MODES
Supported encryption modes for voice connections.
    public
        array<string|int, string>
    SUPPORTED_MODES
    = ['aead_aes256_gcm_rtpsize', 'aead_xchacha20_poly1305_rtpsize']
    
        The supported transport encryption modes.
Tags
VOICE_OP_HANDLERS
Dispatch table mapping Discord Voice Gateway opcodes to handler methods.
    public
        array<int, string>
    VOICE_OP_HANDLERS
    = [\Discord\WebSockets\Op::VOICE_READY => 'handleReady', \Discord\WebSockets\Op::VOICE_SESSION_DESCRIPTION => 'handleSessionDescription', \Discord\WebSockets\Op::VOICE_SPEAKING => 'handleSpeaking', \Discord\WebSockets\Op::VOICE_HEARTBEAT_ACK => 'heartbeatAck', \Discord\WebSockets\Op::VOICE_HELLO => 'handleHello', \Discord\WebSockets\Op::VOICE_RESUMED => 'handleResumed', \Discord\WebSockets\Op::VOICE_CLIENT_CONNECT => 'handleClientConnect', \Discord\WebSockets\Op::VOICE_CLIENT_DISCONNECT => 'handleClientDisconnect', \Discord\WebSockets\Op::VOICE_CLIENT_UNKNOWN_15 => 'handleAny', \Discord\WebSockets\Op::VOICE_CLIENT_UNKNOWN_18 => 'handleFlags', \Discord\WebSockets\Op::VOICE_CLIENT_PLATFORM => 'handlePlatform', \Discord\WebSockets\Op::VOICE_DAVE_PREPARE_TRANSITION => 'handleDavePrepareTransition', \Discord\WebSockets\Op::VOICE_DAVE_EXECUTE_TRANSITION => 'handleDaveExecuteTransition', \Discord\WebSockets\Op::VOICE_DAVE_TRANSITION_READY => 'handleDaveTransitionReady', \Discord\WebSockets\Op::VOICE_DAVE_PREPARE_EPOCH => 'handleDavePrepareEpoch', \Discord\WebSockets\Op::VOICE_DAVE_MLS_EXTERNAL_SENDER => 'handleDaveMlsExternalSender', \Discord\WebSockets\Op::VOICE_DAVE_MLS_KEY_PACKAGE => 'handleDaveMlsKeyPackage', \Discord\WebSockets\Op::VOICE_DAVE_MLS_PROPOSALS => 'handleDaveMlsProposals', \Discord\WebSockets\Op::VOICE_DAVE_MLS_COMMIT_WELCOME => 'handleDaveMlsCommitWelcome', \Discord\WebSockets\Op::VOICE_DAVE_MLS_ANNOUNCE_COMMIT_TRANSITION => 'handleDaveMlsAnnounceCommitTransition', \Discord\WebSockets\Op::VOICE_DAVE_MLS_WELCOME => 'handleDaveMlsWelcome', \Discord\WebSockets\Op::VOICE_DAVE_MLS_INVALID_COMMIT_WELCOME => 'handleDaveMlsInvalidCommitWelcome', \Discord\WebSockets\Op::CLOSE_VOICE_DISCONNECTED => 'handleCloseVoiceDisconnected']
    
        Method name indexed by opcode constant.
Properties
$client
The UDP client.
        public
            Socket
    $client
    
    
        The voiceUDP client.
$receiveStreams
Voice audio receive streams.
        public
            array<string|int, ReceiveStream>
    $receiveStreams
     = []
    
        Voice audio receive streams.
$speakingStatus
Collection of the status of people speaking.
        public
            ExCollectionInterface<string|int, Speaking>|array<string|int, Speaking>
    $speakingStatus
    
    
        Status of people speaking.
$ssrc
The SSRC value.
        public
            int
    $ssrc
    
    
        The SSRC value used for RTP.
$voiceDecoders
Array of voice decoders.
        public
            array<string|int, Process>
    $voiceDecoders
    
    
        Voice decoders.
$audioApplication
The audio application to encode with.
        protected
            string
    $audioApplication
     = 'audio'
        Available: voip, audio (default), lowdelay
The audio application.
$buffer
Audio Buffer.
        protected
            Buffer
    $buffer
    
    
        The Audio Buffer
$channel_id
The Channel that we are connecting to.
        protected
            string
    $channel_id
    
    
        The channel that we are connecting to.
$data
Data from the main WebSocket.
        protected
            array<string|int, mixed>
    $data
    
    
        Information required for the voice WebSocket.
$deaf
Whether we are set as deaf.
        protected
            bool
    $deaf
     = false
    
        Whether we are set as deaf.
$discord
The Discord client.
        protected
            Discord
    $discord
    
    
        The Discord client.
$dnsConfig
The configuration for DNS Resolver.
        protected
            Config|string
    $dnsConfig
    
    
        The DNS configuration.
$endpoint
The Voice WebSocket endpoint.
        protected
            string
    $endpoint
    
    
        The endpoint the Voice WebSocket and UDP client will connect to.
$ffmpeg
The FFmpeg binary location.
        protected
            string
    $ffmpeg
    
    
    
    
    
    
$frameSize
The size of audio frames, in milliseconds.
        protected
            int
    $frameSize
     = 20
    
        The size of audio frames.
$guild_id
The ID of the Channel's Guild.
        protected
            string
    $guild_id
    
    
        The ID of the channel's guild.
$heartbeat
The Voice WebSocket heartbeat timer.
        protected
            TimerInterface
    $heartbeat
    
    
        The heartbeat periodic timer.
$heartbeat_interval
The UDP heartbeat interval.
        protected
            int
    $heartbeat_interval
    
    
        How often we send a heartbeat packet.
$heartbeatSeq
The UDP heartbeat sequence.
        protected
            int
    $heartbeatSeq
     = 0
    
        The heartbeat sequence.
$mainWebsocket
The main WebSocket instance.
        protected
            WebSocket
    $mainWebsocket
    
    
        The main WebSocket client.
$mode
The Voice WebSocket mode.
        protected
            string
    $mode
     = 'aead_aes256_gcm_rtpsize'
    
        The transport encryption mode.
$mute
Whether we are set as mute.
        protected
            bool
    $mute
     = false
    
        Whether we are set as mute.
$paused
Whether the voice client is currently paused.
        protected
            bool
    $paused
     = false
    
        Whether the voice client is currently paused.
$protocol
The Voice connection protocol.
        protected
            string
    $protocol
     = 'udp'
    
        The protocol to use for the voice connection.
$readOpusTimer
readopus Timer.
        protected
            TimerInterface|null
    $readOpusTimer
     = null
    
        Timer
$ready
Is the voice client ready?
        protected
            bool
    $ready
     = false
    
        Whether the voice client is ready.
$reconnecting
Is the voice client reconnecting?
        protected
            bool
    $reconnecting
     = false
    
        Whether the voice client is reconnecting.
$secret_key
The secret key used for encrypting voice.
        protected
            string
    $secret_key
    
    
        The secret key.
$sentLoginFrame
Have we sent the login frame yet?
        protected
            bool
    $sentLoginFrame
     = false
    
        Whether we have sent the login frame.
$seq
The sequence of audio packets being sent.
        protected
            int
    $seq
     = 0
    
        The sequence of audio packets.
$silenceRemaining
Silence Frame Remain Count.
        protected
            int
    $silenceRemaining
     = 5
    
        Amount of silence frames remaining.
$speaking
Are we currently set as speaking?
        protected
            bool
    $speaking
     = false
    
        Whether we are speaking or not.
$startTime
The time we started sending packets.
        protected
            int
    $startTime
    
    
        The time we started sending packets.
$streamTime
The stream time of the last packet.
        protected
            int
    $streamTime
     = 0
    
        The time we sent the last packet.
$supportedModes
The supported transport encryption modes the voice server expects.
        protected
            array<string|int, string>
    $supportedModes
    
    
        The supported transport encryption modes.
$timestamp
The timestamp of the last packet.
        protected
            int
    $timestamp
     = 0
    
        The timestamp the last packet was constructed.
$udpHeartbeat
The UDP heartbeat timer.
        protected
            TimerInterface
    $udpHeartbeat
    
    
        The heartbeat periodic timer.
$udpIp
The IP the UDP client will use.
        protected
            string
    $udpIp
    
    
        The IP that the UDP client will connect to.
$udpPort
The port the UDP client will use.
        protected
            int
    $udpPort
    
    
        The port that the UDP client will connect to.
$userClose
Is the voice client being closed by user?
        protected
            bool
    $userClose
     = false
    
        Whether the voice client is being closed by user.
$version
The Discord voice gateway version.
        protected
            int
    $version
     = 8
    
        Voice version.
$voice_sessions
The array of voice session IDs.
        protected
            array<string|int, string>
    $voice_sessions
    
    
        The voice sessions.
$voiceWebsocket
The voice WebSocket instance.
        protected
            WebSocket
    $voiceWebsocket
    
    
        The voice WebSocket client.
$volume
The volume the audio will be encoded with.
        protected
            int
    $volume
     = 100
    
        The volume that the audio will be encoded in.
Methods
__construct()
Constructs the Voice Client instance.
    public
                    __construct(Discord &$discord, WebSocket &$websocket, array<string|int, mixed> &$voice_sessions, Channel|string $channel, array<string|int, mixed> $data) : mixed
    Parameters
- $discord : Discord
 - 
                    
The Discord client.
 - $websocket : WebSocket
 - 
                    
The main WebSocket client.
 - $voice_sessions : array<string|int, mixed>
 - $channel : Channel|string
 - 
                    
The channel we are connecting to.
 - $data : array<string|int, mixed>
 - 
                    
More information related to the voice client.
 
Tags
close()
Closes the voice client.
    public
                    close() : void
    Tags
decodeVoicePacket()
Decodes voice packet data.
    public
            static        decodeVoicePacket(string $decrypted, VoiceClient $vc, VoicePacket $voicePacket) : void
    Parameters
- $decrypted : string
 - 
                    
The decrypted voice data.
 - $vc : VoiceClient
 - 
                    
The voice client instance.
 - $voicePacket : VoicePacket
 - 
                    
The voice packet to decode.
 
Tags
ffmpegEncode()
Creates a process that will run FFmpeg and encode `$filename` into Ogg Opus format.
    public
                    ffmpegEncode([string|null $filename = null ][, array<string|int, mixed>|null $preArgs = null ]) : Process
    If $filename is null, the process will expect some sort of audio data
to be piped in via stdin. It is highly recommended to set $preArgs to
contain the format of the piped data when using a pipe as an input. You
may also want to provide some arguments to FFmpeg via $preArgs, which
will be appended to the FFmpeg command before setting the input
arguments.
Parameters
- $filename : string|null = null
 - 
                    
Path to file to be converted into Ogg Opus, or null for pipe via stdin.
 - $preArgs : array<string|int, mixed>|null = null
 - 
                    
A list of arguments to be appended before the input filename.
 
Return values
Process —A ReactPHP child process.
getChannel()
Returns the connected channel.
    public
                    getChannel() : Channel
    Return values
Channel —The connected channel.
getGuild()
Returns the connected guild.
    public
                    getGuild() : Guild
    Tags
Return values
Guild —The connected guild.
getReceiveStream()
Gets a receive voice stream.
    public
                    getReceiveStream(int|string $id) : ReceiveStream
    Parameters
- $id : int|string
 - 
                    
Either a SSRC or User ID.
 
Return values
ReceiveStreamgetRecieveStream()
Gets a receive voice stream.
    public
                    getRecieveStream(int|string $id) : RecieveStream
    use self::getReceiveStream()
Parameters
- $id : int|string
 - 
                    
Either a SSRC or User ID.
 
Return values
RecieveStreamhandleAny()
Handles the any event from the voice server.
    public
                    handleAny(Payload $data) : void
    Parameters
- $data : Payload
 
Tags
handleVoiceServerChange()
Handles a voice server change.
    public
                    handleVoiceServerChange([array<string|int, mixed> $data = [] ]) : void
    Parameters
- $data : array<string|int, mixed> = []
 - 
                    
New voice server information.
 
handleVoiceStateUpdate()
Handles a voice state update.
    public
                    handleVoiceStateUpdate(VoiceStateUpdate $data) : void
    NOTE: This object contains the data as the VoiceStateUpdate Part.
Parameters
- $data : VoiceStateUpdate
 - 
                    
The WebSocket data.
 
Tags
handleWebSocketClose()
Handles a WebSocket close.
    public
                    handleWebSocketClose(int $op, string $reason) : void
    Parameters
- $op : int
 - $reason : string
 
handleWebSocketConnection()
Handles a WebSocket connection.
    public
                    handleWebSocketConnection(WebSocket $ws) : void
    Parameters
- $ws : WebSocket
 - 
                    
The WebSocket instance.
 
handleWebSocketError()
Handles a WebSocket error.
    public
                    handleWebSocketError(Exception $e) : void
    Parameters
- $e : Exception
 - 
                    
The error.
 
initSockets()
Initilizes the WebSocket and UDP socket.
    public
                    initSockets() : void
    isPaused()
Checks if we are paused.
    public
                    isPaused() : bool
    Return values
bool —Whether we are paused.
isReady()
Returns whether the voice client is ready.
    public
                    isReady() : bool
    Return values
bool —Whether the voice client is ready.
isSpeaking()
Checks if the user is speaking.
    public
                    isSpeaking([string|int|null $id = null ]) : bool
    Parameters
- $id : string|int|null = null
 - 
                    
Either the User ID or SSRC (if null, return bots speaking status).
 
Return values
bool —Whether the user is speaking.
pause()
Pauses the current sound.
    public
                    pause() : PromiseInterface
    Tags
Return values
PromiseInterfaceplayFile()
Plays a file/url on the voice stream.
    public
                    playFile(string $file[, int $channels = 2 ]) : PromiseInterface
    Parameters
- $file : string
 - 
                    
The file/url to play.
 - $channels : int = 2
 - 
                    
Deprecated, Discord only supports 2 channels.
 
Tags
Return values
PromiseInterfaceplayOggStream()
Plays an Ogg Opus stream.
    public
                    playOggStream(resource|Process|ReadableResourceStream $stream) : PromiseInterface
    Parameters
- $stream : resource|Process|ReadableResourceStream
 - 
                    
The Ogg Opus stream to be sent.
 
Tags
Return values
PromiseInterfaceplayRawStream()
Plays a raw PCM16 stream.
    public
                    playRawStream(resource|ReadableResourceStream $stream[, int $channels = 2 ][, int $audioRate = 48000 ]) : PromiseInterface
    Parameters
- $stream : resource|ReadableResourceStream
 - 
                    
The stream to be encoded and sent.
 - $channels : int = 2
 - 
                    
How many audio channels the PCM16 was encoded with.
 - $audioRate : int = 48000
 - 
                    
Audio sampling rate the PCM16 was encoded with.
 
Tags
Return values
PromiseInterfacereadOpus()
Reads and processes Opus audio packets from an OGG stream.
    public
                    readOpus(Deferred $deferred, OggStream &$ogg, int &$loops) : mixed
    Parameters
- $deferred : Deferred
 - 
                    
The deferred promise that will be resolved when the stream ends.
 - $ogg : OggStream
 - 
                    
Reference to the OGG stream object to read packets from.
 - $loops : int
 - 
                    
Reference to the loop counter used for timing calculations.
 
Tags
setAudioApplication()
Sets the audio application.
    public
                    setAudioApplication(string $app) : void
    Parameters
- $app : string
 - 
                    
The audio application to set.
 
Tags
setBitrate()
Sets the bitrate.
    public
                    setBitrate(int $bitrate) : void
    This data is now taken from the Channel.
For voice channels, normal servers can set bitrate up to 96000, servers with Boost level 1 can set up to 128000, servers with Boost level 2 can set up to 256000, and servers with Boost level 3 or the VIP_REGIONS guild feature can set up to 384000. For stage channels, bitrate can be set up to 64000.
Parameters
- $bitrate : int
 - 
                    
The bitrate to set.
 
Tags
setMode()
Sets the transport encryption mode for the voice client.
    public
                    setMode(string $mode) : void
    Parameters
- $mode : string
 - 
                    
The transport encryption mode to set for the voice client.
 
Tags
setMuteDeaf()
Changes your mute and deaf value.
    public
                    setMuteDeaf(bool $mute, bool $deaf) : void
    Parameters
- $mute : bool
 - 
                    
Whether you should be muted.
 - $deaf : bool
 - 
                    
Whether you should be deaf.
 
Tags
setSpeaking()
Sets the speaking value of the client.
    public
                    setSpeaking([bool $speaking = true ]) : void
    Parameters
- $speaking : bool = true
 - 
                    
Whether the client is speaking or not.
 
Tags
setVolume()
Sets the volume.
    public
                    setVolume(int $volume) : void
    Parameters
- $volume : int
 - 
                    
The volume to set.
 
Tags
start()
Starts the voice client.
    public
                    start() : bool|void
    Return values
bool|voidstop()
Stops the current sound.
    public
                    stop() : PromiseInterface
    Tags
Return values
PromiseInterfaceswitchChannel()
Switches voice channels.
    public
                    switchChannel(Channel $channel) : void
    Parameters
- $channel : Channel
 - 
                    
The channel to switch to.
 
Tags
unpause()
Unpauses the current sound.
    public
                    unpause() : PromiseInterface
    Tags
Return values
PromiseInterface__insertSilence()
Inserts silence frames recursively.
    protected
                    __insertSilence(Deferred $deferred) : void
    Parameters
- $deferred : Deferred
 - 
                    
The deferred promise to resolve when done.
 
checkForExecutable()
Checks if an executable exists on the system.
    protected
            static        checkForExecutable(string $executable) : string|null
    Parameters
- $executable : string
 
Return values
string|nullcheckForFFmpeg()
Checks if FFmpeg is installed.
    protected
                    checkForFFmpeg() : bool
    Return values
bool —Whether FFmpeg is installed or not.
checkForLibsodium()
Checks if libsodium-php is installed.
    protected
                    checkForLibsodium() : bool
    Return values
boolcreateDecoder()
Creates and starts a decoder process for the given stream source.
    protected
                    createDecoder(object $ss) : Process|null
    Parameters
- $ss : object
 - 
                    
The stream source object containing ssrc and user_id properties.
 
Tags
Return values
Process|null —The created decoder ReactPHP Child Process, or null if decoding is not implemented or supported.
decodeUDP()
Decodes a UDP message to extract the IP address and port, then selects the protocol for voice communication.
    protected
                    decodeUDP(string $message) : void
    Parameters
- $message : string
 - 
                    
The raw UDP message received from the server.
 
decryptVoicePacket()
Decrypts a voice packet received from Discord.
    protected
                    decryptVoicePacket(VoicePacket $voicePacket) : string|false
    Parameters
- $voicePacket : VoicePacket
 - 
                    
The voice packet to decrypt.
 
Return values
string|false —The decrypted voice data as a string, or false if decryption fails (e.g., when AEAD payload is too short)
generateCommit()
    protected
                    generateCommit() : mixed
    generateKeyPackage()
    protected
                    generateKeyPackage() : mixed
    generateWelcome()
    protected
                    generateWelcome() : mixed
    handleAudioData()
Handles raw opus data from the UDP server.
    protected
                    handleAudioData(string $message) : void
    Parameters
- $message : string
 - 
                    
The data from the UDP server.
 
handleClientConnect()
Handles the event when a client connects to the voice server.
    protected
                    handleClientConnect(Payload $data) : void
    Parameters
- $data : Payload
 
Tags
handleClientDisconnect()
Handles the event when a client disconnects from the voice server.
    protected
                    handleClientDisconnect(Payload $data) : void
    Parameters
- $data : Payload
 
Tags
handleCloseVoiceDisconnected()
    protected
                    handleCloseVoiceDisconnected() : void
    handleDaveExecuteTransition()
    protected
                    handleDaveExecuteTransition(object $data) : void
    Parameters
- $data : object
 
handleDaveMlsAnnounceCommitTransition()
    protected
                    handleDaveMlsAnnounceCommitTransition(object $data) : void
    Parameters
- $data : object
 
handleDaveMlsCommitWelcome()
    protected
                    handleDaveMlsCommitWelcome(object $data) : void
    Parameters
- $data : object
 
handleDaveMlsExternalSender()
    protected
                    handleDaveMlsExternalSender(object $data) : mixed
    Parameters
- $data : object
 
handleDaveMlsInvalidCommitWelcome()
    protected
                    handleDaveMlsInvalidCommitWelcome(object $data) : void
    Parameters
- $data : object
 
handleDaveMlsKeyPackage()
    protected
                    handleDaveMlsKeyPackage(object $data) : void
    Parameters
- $data : object
 
handleDaveMlsProposals()
    protected
                    handleDaveMlsProposals(object $data) : void
    Parameters
- $data : object
 
handleDaveMlsWelcome()
    protected
                    handleDaveMlsWelcome(object $data) : void
    Parameters
- $data : object
 
handleDavePrepareEpoch()
    protected
                    handleDavePrepareEpoch(object $data) : void
    Parameters
- $data : object
 
handleDavePrepareTransition()
    protected
                    handleDavePrepareTransition(object $data) : void
    Parameters
- $data : object
 
handleDaveTransitionReady()
    protected
                    handleDaveTransitionReady(object $data) : void
    Parameters
- $data : object
 
handleFlags()
Handles the flags event from the voice server.
    protected
                    handleFlags(Payload $data) : void
    Parameters
- $data : Payload
 
Tags
handleHello()
Handles the "Hello" event from the Discord voice server.
    protected
                    handleHello(Payload $data) : void
    Parameters
- $data : Payload
 
Tags
handlePlatform()
Handles the platform event from the voice server.
    protected
                    handlePlatform(Payload $data) : void
    Parameters
- $data : Payload
 
Tags
handleReady()
Handles the "ready" event for the voice client, initializing UDP connection and heartbeat.
    protected
                    handleReady(Payload $data) : void
    Parameters
- $data : Payload
 - 
                    
The data object containing voice server connection details:
- $data->d['ssrc']: The synchronization source identifier.
 - $data->d['ip']: The IP address for the UDP connection.
 - $data->d['port']: The port for the UDP connection.
 - $data->d['modes']: Supported encryption modes.
 
 
Tags
handleResumed()
Handles the 'resumed' event for the voice client.
    protected
                    handleResumed(Payload $data) : void
    Parameters
- $data : Payload
 - 
                    
Data associated with the resumed event.
 
handleSessionDescription()
Handles the session description packet received from the Discord voice server.
    protected
                    handleSessionDescription(Payload $data) : void
    Parameters
- $data : Payload
 
Tags
handleSpeaking()
Handles the speaking state of a user.
    protected
                    handleSpeaking(Payload $data) : void
    Parameters
- $data : Payload
 - 
                    
The data object received from the WebSocket.
 
handleUndocumented()
Handles undocumented voice opcodes not intended for use by bots.
    protected
                    handleUndocumented(Payload $data) : void
    Parameters
- $data : Payload
 
Tags
heartbeat()
Sends a heartbeat payload to the voice server to maintain the connection.
    protected
                    heartbeat() : void
    Tags
heartbeatAck()
Handles the heartbeat acknowledgement from the voice WebSocket connection.
    protected
                    heartbeatAck(Payload $data) : void
    Parameters
- $data : Payload
 
Tags
identify()
Sends an identify payload to the voice gateway to authenticate the client.
    protected
                    identify() : void
    Tags
insertSilence()
Sends five frames of Opus silence to avoid unintended interpolation when there is a break in the sent data.
    protected
                    insertSilence() : PromiseInterface
    Tags
Return values
PromiseInterface —Resolves after all silence frames have been sent.
mainSend()
Sends a message to the main websocket.
    protected
                    mainSend(Payload|array<string|int, mixed> $data) : void
    Parameters
- $data : Payload|array<string|int, mixed>
 - 
                    
The data to send to the main WebSocket.
 
removeDecoder()
Removes the voice decoder associated with the given SSRC.
    protected
                    removeDecoder(object $ss) : mixed
    Parameters
- $ss : object
 
reset()
Resets the voice client.
    protected
                    reset() : void
    resume()
Resumes a previously established voice connection.
    protected
                    resume() : void
    Tags
selectProtocol()
Selects the UDP protocol for the voice connection and sends the selection payload.
    protected
                    selectProtocol(string $ip, int $port) : void
    Parameters
- $ip : string
 - 
                    
The IP address to use for the voice connection.
 - $port : int
 - 
                    
The port number to use for the voice connection.
 
Tags
send()
Sends a message to the voice websocket.
    protected
                    send(Payload|array<string|int, mixed> $data) : void
    Parameters
- $data : Payload|array<string|int, mixed>
 - 
                    
The data to send to the voice WebSocket.
 
sendBuffer()
Sends a buffer to the UDP socket.
    protected
                    sendBuffer(string $data) : void
    Parameters
- $data : string
 - 
                    
The data to send to the UDP server.