Add optional streamOptions to playStream() functions (#663)

* Adding playStream options

Added optional volume and seek properties

* fixed code formatting

Edited my code styling to match with the rest of d.js

* Added Default Variable

* Added Documentation

Added documentation for the streamOptions parameter
Added a default value for seek in FFmpegConverterEngine
Removed redundantcy

* Fixed docs for voiceConnection

* Change _updateMember's notSame check from && to || (#665)

* Fixed git merge fail

* Built Docs. Again.........

* Hopefully finally fixed
This commit is contained in:
Perry Berman
2016-09-08 19:49:52 -07:00
committed by Schuyler Cebulskie
parent 4be7a1bfd1
commit f7a542f12b
7 changed files with 33 additions and 21 deletions

View File

@@ -25,8 +25,9 @@ class VoiceConnectionPlayer extends EventEmitter {
};
}
convertStream(stream) {
const encoder = this.converterEngine.createConvertStream();
convertStream(stream, { seek = 0, volume = 1 }) {
const options = { seek: seek, volume: volume };
const encoder = this.converterEngine.createConvertStream(options.seek);
const pipe = stream.pipe(encoder.stdin);
pipe.on('unpipe', () => pipe.destroy());
this.processMap.set(encoder.stdout, {
@@ -88,11 +89,13 @@ class VoiceConnectionPlayer extends EventEmitter {
});
}
playPCMStream(pcmStream) {
const dispatcher = new StreamDispatcher(this, pcmStream, this._streamingData);
playPCMStream(pcmStream, { seek = 0, volume = 1 }) {
const options = { seek: seek, volume: volume };
const dispatcher = new StreamDispatcher(this, pcmStream, this._streamingData, options);
dispatcher.on('speaking', value => this.setSpeaking(value));
dispatcher.on('end', () => this.killStream(pcmStream));
dispatcher.on('error', () => this.killStream(pcmStream));
dispatcher.setVolume(options.volume);
this.dispatcher = dispatcher;
return dispatcher;
}