mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-15 11:03:30 +01:00
Fixed process removing
This commit is contained in:
@@ -26,8 +26,14 @@ var AudioEncoder = (function () {
|
||||
var enc = cpoc.spawn("ffmpeg", ["-i", file, "-f", "s16le", "-ar", "48000", "-ac", "1", "-af", "volume=1", "pipe:1"]);
|
||||
|
||||
enc.stdout.on("readable", function () {
|
||||
callback(null, enc.stdout);
|
||||
resolve(enc.stdout);
|
||||
callback(null, {
|
||||
proc: enc,
|
||||
stream: enc.stdout
|
||||
});
|
||||
resolve({
|
||||
proc: enc,
|
||||
stream: enc.stdout
|
||||
});
|
||||
});
|
||||
|
||||
enc.stdout.on("end", function () {
|
||||
|
||||
@@ -39,11 +39,14 @@ var VoiceConnection = (function (_EventEmitter) {
|
||||
this.playingIntent = null;
|
||||
this.playing = false;
|
||||
this.streamTime = 0;
|
||||
this.streamProc = null;
|
||||
this.init();
|
||||
}
|
||||
|
||||
VoiceConnection.prototype.stopPlaying = function stopPlaying() {
|
||||
this.playing = false;
|
||||
this.playingIntent = null;
|
||||
if (this.streamProc) this.streamProc.kill();
|
||||
};
|
||||
|
||||
VoiceConnection.prototype.playRawStream = function playRawStream(stream) {
|
||||
@@ -171,9 +174,10 @@ var VoiceConnection = (function (_EventEmitter) {
|
||||
|
||||
var self = this;
|
||||
return new Promise(function (resolve, reject) {
|
||||
_this.encoder.encodeFile(stream)["catch"](error).then(function (stream) {
|
||||
_this.encoder.encodeFile(stream)["catch"](error).then(function (data) {
|
||||
|
||||
var intent = self.playRawStream(stream);
|
||||
self.streamProc = data.proc;
|
||||
var intent = self.playRawStream(data.stream);
|
||||
resolve(intent);
|
||||
callback(null, intent);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user