mirror of
https://github.com/danbulant/discord.js
synced 2026-07-13 07:00:44 +00:00
Better broadcast stuff
This commit is contained in:
parent
a8511ebfaf
commit
8a87cbf404
3 changed files with 5 additions and 6 deletions
|
|
@ -23,7 +23,7 @@ class VoiceBroadcast extends EventEmitter {
|
||||||
* @type {Client}
|
* @type {Client}
|
||||||
*/
|
*/
|
||||||
this.client = client;
|
this.client = client;
|
||||||
this.dispatchers = [];
|
this.dispatchers = new Set();
|
||||||
this.player = new BroadcastAudioPlayer(this);
|
this.player = new BroadcastAudioPlayer(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,8 +29,8 @@ nonce.fill(0);
|
||||||
* @extends {stream.Writable}
|
* @extends {stream.Writable}
|
||||||
*/
|
*/
|
||||||
class StreamDispatcher extends Writable {
|
class StreamDispatcher extends Writable {
|
||||||
constructor(player, { seek = 0, volume = 1, passes = 1, fec, plp, bitrate = 96 } = {}, streams) {
|
constructor(player, { seek = 0, volume = 1, passes = 1, fec, plp, bitrate = 96, highWaterMark = 4096 } = {}, streams) {
|
||||||
const streamOptions = { seek, volume, passes, fec, plp, bitrate };
|
const streamOptions = { seek, volume, passes, fec, plp, bitrate, highWaterMark };
|
||||||
super(streamOptions);
|
super(streamOptions);
|
||||||
/**
|
/**
|
||||||
* The Audio Player that controls this dispatcher
|
* The Audio Player that controls this dispatcher
|
||||||
|
|
@ -82,6 +82,7 @@ class StreamDispatcher extends Writable {
|
||||||
_destroy(err, cb) {
|
_destroy(err, cb) {
|
||||||
if (this.player.dispatcher === this) this.player.dispatcher = null;
|
if (this.player.dispatcher === this) this.player.dispatcher = null;
|
||||||
const { streams } = this;
|
const { streams } = this;
|
||||||
|
if (streams.broadcast) streams.broadcast.dispatchers.delete(this);
|
||||||
if (streams.opus) streams.opus.unpipe(this);
|
if (streams.opus) streams.opus.unpipe(this);
|
||||||
if (streams.ffmpeg) streams.ffmpeg.destroy();
|
if (streams.ffmpeg) streams.ffmpeg.destroy();
|
||||||
super._destroy(err, cb);
|
super._destroy(err, cb);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,3 @@
|
||||||
const prism = require('prism-media');
|
|
||||||
const StreamDispatcher = require('../dispatcher/StreamDispatcher');
|
|
||||||
const BasePlayer = require('./BasePlayer');
|
const BasePlayer = require('./BasePlayer');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -19,7 +17,7 @@ class AudioPlayer extends BasePlayer {
|
||||||
|
|
||||||
playBroadcast(broadcast, options) {
|
playBroadcast(broadcast, options) {
|
||||||
const dispatcher = this.createDispatcher(options, { broadcast });
|
const dispatcher = this.createDispatcher(options, { broadcast });
|
||||||
broadcast.dispatchers.push(dispatcher);
|
broadcast.dispatchers.add(dispatcher);
|
||||||
return dispatcher;
|
return dispatcher;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue