mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
Fix arbitrary ffmpeg
This commit is contained in:
@@ -124,11 +124,11 @@ var AudioEncoder = (function () {
|
||||
});
|
||||
};
|
||||
|
||||
AudioEncoder.prototype.encodeArbitraryFFmpeg = function encodeArbitraryFFmpeg(ffmpegOptions, volume) {
|
||||
AudioEncoder.prototype.encodeArbitraryFFmpeg = function encodeArbitraryFFmpeg(ffmpegOptions, options) {
|
||||
var _this3 = this;
|
||||
|
||||
return new Promise(function (resolve, reject) {
|
||||
_this3.volume = new _VolumeTransformer2["default"](volume);
|
||||
_this3.volume = new _VolumeTransformer2["default"](options.volume);
|
||||
|
||||
var command = _this3.getCommand();
|
||||
|
||||
@@ -136,8 +136,8 @@ var AudioEncoder = (function () {
|
||||
if (!command) return reject(new Error('FFMPEG not found. Make sure it is installed and in path.'));
|
||||
|
||||
// add options discord.js needs
|
||||
var options = ffmpegOptions.concat(['-f', 's16le', '-ar', '48000', '-ac', 2, 'pipe:1']);
|
||||
var enc = _child_process2["default"].spawn(command, options);
|
||||
var ffmpegOptions = ffmpegOptions.concat(['-f', 's16le', '-ar', '48000', '-ac', 2, 'pipe:1']);
|
||||
var enc = _child_process2["default"].spawn(command, ffmpegOptions);
|
||||
|
||||
_this3.hookEncodingProcess(resolve, reject, enc);
|
||||
});
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -107,9 +107,9 @@ export default class AudioEncoder {
|
||||
});
|
||||
}
|
||||
|
||||
encodeArbitraryFFmpeg(ffmpegOptions, volume) {
|
||||
encodeArbitraryFFmpeg(ffmpegOptions, options) {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.volume = new VolumeTransformer(volume);
|
||||
this.volume = new VolumeTransformer(options.volume);
|
||||
|
||||
var command = this.getCommand();
|
||||
|
||||
@@ -117,13 +117,13 @@ export default class AudioEncoder {
|
||||
if (!command) return reject(new Error('FFMPEG not found. Make sure it is installed and in path.'));
|
||||
|
||||
// add options discord.js needs
|
||||
var options = ffmpegOptions.concat([
|
||||
var ffmpegOptions = ffmpegOptions.concat([
|
||||
'-f', 's16le',
|
||||
'-ar', '48000',
|
||||
'-ac', 2,
|
||||
'pipe:1'
|
||||
]);
|
||||
var enc = cpoc.spawn(command, options);
|
||||
var enc = cpoc.spawn(command, ffmpegOptions);
|
||||
|
||||
this.hookEncodingProcess(resolve, reject, enc);
|
||||
});
|
||||
|
||||
@@ -283,20 +283,23 @@ export default class VoiceConnection extends EventEmitter {
|
||||
})
|
||||
}
|
||||
|
||||
playArbitraryFFmpeg(ffmpegOptions, volume, callback = function (err, str) { }) {
|
||||
playArbitraryFFmpeg(ffmpegOptions, options, callback = function (err, str) { }) {
|
||||
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((resolve, reject) => {
|
||||
this.encoder
|
||||
.encodeArbitraryFFmpeg(ffmpegOptions, volume)
|
||||
.encodeArbitraryFFmpeg(ffmpegOptions, options)
|
||||
.catch(error)
|
||||
.then(data => {
|
||||
self.streamProc = data.proc;
|
||||
|
||||
Reference in New Issue
Block a user