Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/play-sound.js b/play-sound.js
- index c0b7b33..44b26de 100644
- --- a/play-sound.js
- +++ b/play-sound.js
- @@ -5,13 +5,18 @@ var child_process = require('child_process'),
- allSounds = new Set;
- module.exports = function(soundPath){
- - var proc = child_process.exec('"'+path.join(__dirname, 'cmdmp3/cmdmp3.exe')+'" "'+
- - soundPath+'"');
- + var os = require("os");
- + var program = (os.platform() === "linux") ? "mplayer" : path.join(__dirname, "cmdmp3/cmdmp3.exe");
- + var proc = child_process.exec('"' + program + '" "' + soundPath + '"');
- console.log("Playing: "+soundPath)
- var sound = {
- stop: function(){
- - console.log("Stopping: "+soundPath)
- - child_process.spawn("taskkill", ["/pid", proc.pid, '/f', '/t']);
- + console.log("Stopping: "+soundPath)
- + if (os.platform() === "linux") {
- + child_process.spawn("kill", ['-9', proc.pid]);
- + } else {
- + child_process.spawn("taskkill", ["/pid", proc.pid, '/f', '/t']);
- + }
- allSounds.delete(sound);
- }
- }
- @@ -26,4 +31,4 @@ module.exports.stopAll = function(){
- allSounds.forEach(function(sound){
- sound.stop();
- });
- -}
- \ No newline at end of file
- +}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement