mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-14 10:33:30 +01:00
Fixed multiple ffmpeg/avconv processes being alive
This commit is contained in:
@@ -93,8 +93,6 @@ var AudioEncoder = (function () {
|
||||
return new Promise(function (resolve, reject) {
|
||||
var enc = _child_process2["default"].spawn(self.getCommand(), ['-loglevel', '0', '-i', file, '-f', 's16le', '-ar', '48000', '-ac', 2, 'pipe:1', '-af', '"volume=' + (options.volume || 1) + '"'], { stdio: ['pipe', 'pipe', 'ignore'] });
|
||||
|
||||
console.log(['-loglevel', '0', '-i', file, '-f', 's16le', '-ar', '48000', '-af', '"volume=' + (options.volume || 1) + '"', '-ac', 2, 'pipe:1'].join(" "));
|
||||
|
||||
enc.stdout.once("readable", function () {
|
||||
resolve({
|
||||
proc: enc,
|
||||
|
||||
@@ -91,6 +91,9 @@ var VoiceConnection = (function (_EventEmitter) {
|
||||
VoiceConnection.prototype.stopPlaying = function stopPlaying() {
|
||||
this.playing = false;
|
||||
this.playingIntent = null;
|
||||
if (this.streamProc) {
|
||||
this.streamProc.kill();
|
||||
}
|
||||
if (this.instream) {
|
||||
//not all streams implement these...
|
||||
//and even file stream don't seem to implement them properly...
|
||||
@@ -222,14 +225,6 @@ var VoiceConnection = (function (_EventEmitter) {
|
||||
}
|
||||
};
|
||||
|
||||
VoiceConnection.prototype.test = function test() {
|
||||
this.playFile("C:/users/amish/desktop/audio.mp3").then(function (stream) {
|
||||
stream.on("time", function (time) {
|
||||
console.log("Time", time);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
VoiceConnection.prototype.playFile = function playFile(stream) {
|
||||
var _this = this;
|
||||
|
||||
@@ -237,6 +232,7 @@ var VoiceConnection = (function (_EventEmitter) {
|
||||
var callback = arguments.length <= 2 || arguments[2] === undefined ? function (err, str) {} : arguments[2];
|
||||
|
||||
var self = this;
|
||||
self.stopPlaying();
|
||||
if (typeof options === "function") {
|
||||
// options is the callback
|
||||
callback = options;
|
||||
@@ -265,6 +261,7 @@ var VoiceConnection = (function (_EventEmitter) {
|
||||
var callback = arguments.length <= 2 || arguments[2] === undefined ? function (err, str) {} : arguments[2];
|
||||
|
||||
var self = this;
|
||||
self.stopPlaying();
|
||||
if (typeof options === "function") {
|
||||
// options is the callback
|
||||
callback = options;
|
||||
|
||||
@@ -88,16 +88,6 @@ export default class AudioEncoder {
|
||||
'-af', '"volume=' + (options.volume || 1)+'"'
|
||||
], { stdio: ['pipe', 'pipe', 'ignore'] });
|
||||
|
||||
console.log([
|
||||
'-loglevel', '0',
|
||||
'-i', file,
|
||||
'-f', 's16le',
|
||||
'-ar', '48000',
|
||||
'-af', '"volume=' + (options.volume || 1) + '"',
|
||||
'-ac', 2,
|
||||
'pipe:1',
|
||||
].join(" "));
|
||||
|
||||
enc.stdout.once("readable", function () {
|
||||
resolve({
|
||||
proc: enc,
|
||||
|
||||
@@ -62,6 +62,9 @@ export default class VoiceConnection extends EventEmitter {
|
||||
stopPlaying() {
|
||||
this.playing = false;
|
||||
this.playingIntent = null;
|
||||
if (this.streamProc) {
|
||||
this.streamProc.kill();
|
||||
}
|
||||
if(this.instream){
|
||||
//not all streams implement these...
|
||||
//and even file stream don't seem to implement them properly...
|
||||
@@ -196,17 +199,9 @@ export default class VoiceConnection extends EventEmitter {
|
||||
}
|
||||
}
|
||||
|
||||
test() {
|
||||
this.playFile("C:/users/amish/desktop/audio.mp3")
|
||||
.then(stream => {
|
||||
stream.on("time", time => {
|
||||
console.log("Time", time);
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
playFile(stream, options=false, callback = function (err, str) { }) {
|
||||
var self = this;
|
||||
self.stopPlaying();
|
||||
if (typeof options === "function") {
|
||||
// options is the callback
|
||||
callback = options;
|
||||
@@ -232,6 +227,7 @@ export default class VoiceConnection extends EventEmitter {
|
||||
|
||||
playRawStream(stream, options=false, callback = function (err, str) { }) {
|
||||
var self = this;
|
||||
self.stopPlaying();
|
||||
if (typeof options === "function") {
|
||||
// options is the callback
|
||||
callback = options;
|
||||
|
||||
Reference in New Issue
Block a user