Broadcast
The Broadcast class makes you able to create easily a broadcast.
Creating a broadcast
You can easily create a broadcast by using the broadcast class. The Broacast class requires the stream
parameter and has an optional options
parameter. The options
parameter has the following options:
noListeners: If there are no members listening in the voice channel.
play: Continues playing the stream. (default and recommended)
pause: Pauses the stream until someone joins again.
stop: Stops the player and leaves the voice channel.
volume: The volume of the stream. Max 1, min 0.
audiotype: The audio type of the stream.
'arbitrary': For mp3 audio (default)
'ogg/opus': For ogg audio
'webm/opus': For webm audio
'opus': For opus audio
'raw': For raw audio
Pausing a broadcast
You can easily pause a broadcast by using the pause function.
Resuming a broadcast
You can easily resume a broadcast by using the resume function.
Destroy a broadcast
You can destroy a broadcast by using the destroy function. You should first unsubscribe the broadcast of all connections before using this function.
Changing the broadcast volume
You can change the volume of the broadcast by using the volume function. The volume has to be at least 0 and can maximum be 1.
Event listeners
The Broadcast class also has 2 events:
play: When the broadcast starts playing.
end: When the broadcast ended.
Both events return the stream that is playing or has ended.
Recommended is that if you want to play another stream you first destroy the broadcast and then play a new stream. Otherwise the old resource still will be available and can cause memory leaks.
Playing a broadcast
You can play a broadcast by using the Connection class. The Connection class also has some events which are being used for the Broadcast.
Last updated