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