Advertisement
Fer22f

Commit

Dec 18th, 2015
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 1.38 KB | None | 0 0
  1. diff --git a/play-sound.js b/play-sound.js
  2. index c0b7b33..44b26de 100644
  3. --- a/play-sound.js
  4. +++ b/play-sound.js
  5. @@ -5,13 +5,18 @@ var child_process = require('child_process'),
  6.         allSounds = new Set;
  7.  
  8.  module.exports = function(soundPath){
  9. -    var proc = child_process.exec('"'+path.join(__dirname, 'cmdmp3/cmdmp3.exe')+'" "'+
  10. -               soundPath+'"');
  11. +    var os = require("os");
  12. +    var program = (os.platform() === "linux") ? "mplayer" : path.join(__dirname, "cmdmp3/cmdmp3.exe");
  13. +    var proc = child_process.exec('"' + program + '" "' + soundPath + '"');
  14.      console.log("Playing: "+soundPath)
  15.         var sound = {
  16.                 stop: function(){
  17. -                       console.log("Stopping: "+soundPath)            
  18. -                       child_process.spawn("taskkill", ["/pid", proc.pid, '/f', '/t']);
  19. +                       console.log("Stopping: "+soundPath)
  20. +            if (os.platform() === "linux") {
  21. +                child_process.spawn("kill", ['-9', proc.pid]);
  22. +            } else {
  23. +                child_process.spawn("taskkill", ["/pid", proc.pid, '/f', '/t']);
  24. +            }
  25.                         allSounds.delete(sound);
  26.                 }
  27.         }
  28. @@ -26,4 +31,4 @@ module.exports.stopAll = function(){
  29.         allSounds.forEach(function(sound){
  30.                 sound.stop();
  31.         });
  32. -}
  33. \ No newline at end of file
  34. +}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement