Skip to content

Instantly share code, notes, and snippets.

@e-jigsaw
Created February 5, 2012 16:55
Show Gist options
  • Save e-jigsaw/1746559 to your computer and use it in GitHub Desktop.
Save e-jigsaw/1746559 to your computer and use it in GitHub Desktop.
Play song in Server and Share with Dropbox!
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