mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-13 10:03:31 +01:00
47 lines
1.3 KiB
JavaScript
47 lines
1.3 KiB
JavaScript
const EventEmitter = require('events');
|
|
const BroadcastAudioPlayer = require('./player/BroadcastAudioPlayer');
|
|
const DispatcherSet = require('./util/DispatcherSet');
|
|
const PlayInterface = require('./util/PlayInterface');
|
|
|
|
/**
|
|
* A voice broadcast can be played across multiple voice connections for improved shared-stream efficiency.
|
|
*
|
|
* Example usage:
|
|
* ```js
|
|
* const broadcast = client.createVoiceBroadcast();
|
|
* broadcast.playFile('./music.mp3');
|
|
* // Play "music.mp3" in all voice connections that the client is in
|
|
* for (const connection of client.voiceConnections.values()) {
|
|
* connection.playBroadcast(broadcast);
|
|
* }
|
|
* ```
|
|
* @implements {VolumeInterface}
|
|
* @implements {PlayInterface}
|
|
*/
|
|
class VoiceBroadcast extends EventEmitter {
|
|
constructor(client) {
|
|
super();
|
|
/**
|
|
* The client that created the broadcast
|
|
* @type {Client}
|
|
*/
|
|
this.client = client;
|
|
this.dispatchers = new DispatcherSet(this);
|
|
this.player = new BroadcastAudioPlayer(this);
|
|
}
|
|
|
|
/**
|
|
* The current master dispatcher, if any. This dispatcher controls all that is played by subscribed dispatchers.
|
|
* @type {?BroadcastDispatcher}
|
|
*/
|
|
get dispatcher() {
|
|
return this.player.dispatcher;
|
|
}
|
|
|
|
play() {} // eslint-disable-line no-empty-function
|
|
}
|
|
|
|
PlayInterface.applyToClass(VoiceBroadcast);
|
|
|
|
module.exports = VoiceBroadcast;
|