Created
February 5, 2012 16:55
-
-
Save e-jigsaw/1746559 to your computer and use it in GitHub Desktop.
Play song in Server and Share with Dropbox!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var exec = require('child_process').exec; | |
var spawn = require('child_process').spawn; | |
function playSong() { | |
exec("ls *.mp3 *.m4a", function(e, stdo, stde) { | |
var tmp = stdo.split("¥n"); | |
if(tmp.length == 1) return; | |
var afplay = spawn("afplay", [tmp[0]]); | |
afplay.on("exit", function(e) { | |
exec("rm -f "+tmp[0], function(){ | |
playSong(); | |
}); | |
}); | |
}); | |
} | |
playSong(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment