mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-14 18:43:31 +01:00
Adding volume wrapper
This commit is contained in:
@@ -117,17 +117,19 @@ var VoiceConnection = (function (_EventEmitter) {
|
||||
VoiceConnection.prototype.playStream = function playStream(stream) {
|
||||
var channels = arguments.length <= 1 || arguments[1] === undefined ? 2 : arguments[1];
|
||||
|
||||
var self = this;
|
||||
var self = this,
|
||||
startTime = Date.now(),
|
||||
count = 0,
|
||||
length = 20,
|
||||
retStream = new _StreamIntent2["default"](),
|
||||
onWarning = false,
|
||||
lastVolume = this.volume !== undefined ? this.volume.get() : 1;
|
||||
|
||||
var startTime = Date.now();
|
||||
var count = 0;
|
||||
this.volume = stream;
|
||||
this.playing = true;
|
||||
this.playingIntent = retStream;
|
||||
|
||||
var length = 20;
|
||||
|
||||
self.playing = true;
|
||||
var retStream = new _StreamIntent2["default"]();
|
||||
var onWarning = false;
|
||||
self.playingIntent = retStream;
|
||||
this.setVolume(lastVolume);
|
||||
|
||||
function send() {
|
||||
if (!self.playingIntent || !self.playing) {
|
||||
@@ -409,6 +411,30 @@ var VoiceConnection = (function (_EventEmitter) {
|
||||
});
|
||||
};
|
||||
|
||||
VoiceConnection.prototype.wrapVolume = function wrapVolume(stream) {
|
||||
stream.pipe(this.volume);
|
||||
|
||||
return this.volume;
|
||||
};
|
||||
|
||||
VoiceConnection.prototype.setVolume = function setVolume(volume) {
|
||||
this.volume.set(volume);
|
||||
};
|
||||
|
||||
VoiceConnection.prototype.getVolume = function getVolume() {
|
||||
return this.volume.get();
|
||||
};
|
||||
|
||||
VoiceConnection.prototype.mute = function mute() {
|
||||
this.lastVolume = this.volume.get();
|
||||
this.setVolume(0);
|
||||
};
|
||||
|
||||
VoiceConnection.prototype.unmute = function unmute() {
|
||||
this.setVolume(this.lastVolume);
|
||||
this.lastVolume = undefined;
|
||||
};
|
||||
|
||||
return VoiceConnection;
|
||||
})(_events2["default"]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user