Search code examples
phpscriptingmplayeropenbsd

Is it possible to control mplayer from another program easily?


I'm setting up a computer running OpenBSD that I wish to play all the music I will ever want. I want it to basically set in a corner and do it's thing. The problem with that is that I want to control it from wherever I am. I can do that (though not extremely easily) with ssh from my computer. I think it'd be really cool to control(as in, choose songs, skip, pause, volume control, etc) it from a simple web page so I could access it from my phone, as well as my computer.

So, I'd prefer to use mplayer for this. Is there any way of controlling mplayer from say a PHP script or something similar?


Solution

  • http://www.mplayerhq.hu/DOCS/tech/slave.txt

    You can start up mplayer in command receival mode. Create a named pipe first:

    mkfifo /tmp/mplayercontrol
    mplayer -slave -input file=/tmp/mplayercontrol
    

    Which in turn can be controlled via PHP easily:

    file_put_contents("/tmp/mplayercontrol", "pause");
    

    If you run mplayer and PHP on the same server, that should already do it.