Add method to play back the output from an arbitrary ffmpeg cmd

This commit is contained in:
meew0
2015-12-23 23:20:19 +01:00
parent 4d6adfd289
commit d09c26c7c1
2 changed files with 60 additions and 0 deletions

View File

@@ -253,6 +253,33 @@ export default class VoiceConnection extends EventEmitter {
})
}
playArbitraryFFmpeg(ffmpegOptions, callback = function (err, str) { }) {
var self = this;
self.stopPlaying();
if (typeof options === "function") {
// options is the callback
callback = options;
options = {};
}
return new Promise((resolve, reject) => {
this.encoder
.encodeArbitraryFFmpeg(ffmpegOptions)
.catch(error)
.then(data => {
self.streamProc = data.proc;
self.instream = data.instream;
var intent = self.playStream(data.stream);
resolve(intent);
callback(null, intent);
});
function error(e = true) {
reject(e);
callback(e);
}
})
}
init() {
var self = this;
console.log("\n\nendpoint:", this.endpoint, "\n\n");