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

@@ -83,18 +83,19 @@ export default class VoiceConnection extends EventEmitter {
}
playStream(stream, channels=2) {
var self = this,
startTime = Date.now(),
count = 0,
length = 20,
retStream = new StreamIntent(),
onWarning = false,
lastVolume = this.volume !== undefined ? this.volume.get() : 1;
var self = this;
this.volume = stream;
this.playing = true;
this.playingIntent = retStream;
var startTime = Date.now();
var count = 0;
var length = 20;
self.playing = true;
var retStream = new StreamIntent();
var onWarning = false;
self.playingIntent = retStream;
this.setVolume(lastVolume);
function send() {
if (!self.playingIntent || !self.playing) {
@@ -371,4 +372,28 @@ export default class VoiceConnection extends EventEmitter {
});
}
wrapVolume(stream) {
stream.pipe(this.volume);
return this.volume;
}
setVolume(volume) {
this.volume.set(volume);
}
getVolume() {
return this.volume.get();
}
mute() {
this.lastVolume = this.volume.get();
this.setVolume(0);
}
unmute() {
this.setVolume(this.lastVolume);
this.lastVolume = undefined;
}
}