Created
October 22, 2015 18:53
-
-
Save chaosprinz/e06a10dce1c39b5af287 to your computer and use it in GitHub Desktop.
Here is a solution for controlling the mplayer using nodejs. Much cleaner and more efficient than my fifo-solution. Instead of process.stdin i could use a socket or an webservice or whatever, very simple.
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 cp = require("child_process"); | |
var fs = require("fs"); | |
player = cp.spawn("mplayer", | |
["-slave","-idle","-quiet"] | |
); | |
player.stdout.on("data",function(data){ | |
console.log("" + data); | |
}); | |
player.stderr.on("data", function(data){ | |
console.error("" + data); | |
}); | |
process.stdin.setEncoding('utf8'); | |
process.stdin.on('readable', function(){ | |
var chunk = process.stdin.read(); | |
if (chunk !== null){ | |
player.stdin.write(chunk); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment