Add back setBitrate

This commit is contained in:
Amish Shah
2017-10-26 14:39:58 +01:00
parent f6959a848f
commit 863e38676f
2 changed files with 12 additions and 3 deletions

View File

@@ -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;

View File

@@ -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 = {}) {