Adding volume wrapper

This commit is contained in:
Aaron Scherer
2016-02-09 15:12:21 -08:00
parent c8acc17d8e
commit 3c64cfce4a
7 changed files with 266 additions and 80 deletions

View File

@@ -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"]);