mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 00:23:30 +01:00
Add back setBitrate
This commit is contained in:
@@ -86,6 +86,14 @@ class StreamDispatcher extends Writable {
|
||||
if (this._writeCallback) this._writeCallback();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the bitrate of the current Opus encoder.
|
||||
* @param {number} value New bitrate, in kbps
|
||||
* If set to 'auto', the voice channel's bitrate will be used
|
||||
* @returns {boolean} true if the bitrate has been successfully changed.
|
||||
*/
|
||||
setBitrate(value) { return this.player.setBitrate(value); }
|
||||
|
||||
_step(done) {
|
||||
if (this.pausedSince) {
|
||||
this._writeCallback = done;
|
||||
|
||||
@@ -51,12 +51,13 @@ class AudioPlayer extends EventEmitter {
|
||||
* Set the bitrate of the current Opus encoder.
|
||||
* @param {number} value New bitrate, in kbps
|
||||
* If set to 'auto', the voice channel's bitrate will be used
|
||||
* @returns {boolean} true if the bitrate has been successfully changed.
|
||||
*/
|
||||
setBitrate(value) {
|
||||
if (!value) return;
|
||||
if (!this.opusEncoder) return;
|
||||
if (!value || !this.streams.opus || !this.streams.opus.setBitrate) return false;
|
||||
const bitrate = value === 'auto' ? this.voiceConnection.channel.bitrate : value;
|
||||
this.opusEncoder.setBitrate(bitrate);
|
||||
this.streams.opus.setBitrate(bitrate * 1000);
|
||||
return true;
|
||||
}
|
||||
|
||||
playUnknownStream(stream, options = {}) {
|
||||
|
||||
Reference in New Issue
Block a user