mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-20 21:43:33 +01:00
Fix for the playArbitraryFFmpeg issue (#351)
* This should probably fix #346 * Updated docs for playArbitraryFFmpeg
This commit is contained in:
@@ -88,7 +88,7 @@ This method is used in much the same way as `playFile`, except it plays data bac
|
|||||||
|
|
||||||
| See voiceConnection.playFile_ for usage information.
|
| See voiceConnection.playFile_ for usage information.
|
||||||
|
|
||||||
playArbitraryFFmpeg(options, `callback`)
|
playArbitraryFFmpeg(ffmpegOptions, `volume`, `callback`)
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
This method can be used to play data obtained from an arbitrary call to ffmpeg. Note that the array of options given as the parameter will
|
This method can be used to play data obtained from an arbitrary call to ffmpeg. Note that the array of options given as the parameter will
|
||||||
|
|||||||
@@ -147,9 +147,9 @@ export default class AudioEncoder {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
encodeArbitraryFFmpeg(ffmpegOptions) {
|
encodeArbitraryFFmpeg(ffmpegOptions, volume) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this.volume = new VolumeTransformer(1);
|
this.volume = new VolumeTransformer(volume);
|
||||||
|
|
||||||
// add options discord.js needs
|
// add options discord.js needs
|
||||||
var options = ffmpegOptions.concat([
|
var options = ffmpegOptions.concat([
|
||||||
|
|||||||
@@ -277,20 +277,20 @@ export default class VoiceConnection extends EventEmitter {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
playArbitraryFFmpeg(ffmpegOptions, callback = function (err, str) { }) {
|
playArbitraryFFmpeg(ffmpegOptions, volume, callback = function (err, str) { }) {
|
||||||
var self = this;
|
var self = this;
|
||||||
self.stopPlaying();
|
self.stopPlaying();
|
||||||
if (typeof options === "function") {
|
if (typeof volume === "function") {
|
||||||
// options is the callback
|
// volume is the callback
|
||||||
callback = options;
|
callback = volume;
|
||||||
}
|
}
|
||||||
if (typeof options !== "object") {
|
if (!ffmpegOptions instanceof Array) {
|
||||||
options = {};
|
ffmpegOptions = [];
|
||||||
}
|
}
|
||||||
options.volume = options.volume !== undefined ? options.volume : this.getVolume();
|
var volume = volume !== undefined ? volume : this.getVolume();
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this.encoder
|
this.encoder
|
||||||
.encodeArbitraryFFmpeg(ffmpegOptions)
|
.encodeArbitraryFFmpeg(ffmpegOptions, volume)
|
||||||
.catch(error)
|
.catch(error)
|
||||||
.then(data => {
|
.then(data => {
|
||||||
self.streamProc = data.proc;
|
self.streamProc = data.proc;
|
||||||
|
|||||||
Reference in New Issue
Block a user