Fix arbitrary ffmpeg

This commit is contained in:
abalabahaha
2016-10-02 12:44:59 +09:00
parent c00d209014
commit 76dd4f74da
4 changed files with 28 additions and 22 deletions

View File

@@ -324,23 +324,26 @@ var VoiceConnection = (function (_EventEmitter) {
});
};
VoiceConnection.prototype.playArbitraryFFmpeg = function playArbitraryFFmpeg(ffmpegOptions, volume) {
VoiceConnection.prototype.playArbitraryFFmpeg = function playArbitraryFFmpeg(ffmpegOptions, options) {
var _this3 = this;
var callback = arguments.length <= 2 || arguments[2] === undefined ? function (err, str) {} : arguments[2];
var self = this;
self.stopPlaying();
if (typeof volume === "function") {
// volume is the callback
callback = volume;
}
if (!ffmpegOptions instanceof Array) {
ffmpegOptions = [];
}
var volume = volume !== undefined ? volume : this.getVolume();
if (typeof options === "function") {
// options is the callback
callback = options;
}
if (typeof options !== "object") {
options = {};
}
options.volume = options.volume !== undefined ? options.volume : this.getVolume();
return new Promise(function (resolve, reject) {
_this3.encoder.encodeArbitraryFFmpeg(ffmpegOptions, volume)["catch"](error).then(function (data) {
_this3.encoder.encodeArbitraryFFmpeg(ffmpegOptions, options)["catch"](error).then(function (data) {
self.streamProc = data.proc;
self.instream = data.instream;
var intent = self.playStream(data.stream);