Re: Sending data to persistent process stdin

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ville Mattila wrote:
> Hello readers,
> 
> I have been thinking of making a simple web-based interface to control
> my media center box (running debian linux). Being a bit enthustiatic, I
> thought I could use some generic tools for playing media files and write
> the whole UI by my own.
> 
> I found mpg123 program that can be run in "remote mode" (mpg123 -R) so
> that playback can be controlled via stdin. Writing "LOAD <mp3 file>" to
> the stdin will begin output, "PAUSE" will stop it and so on.
> 
> How could I use PHP and its process functions to send something to stdin
> of a persistent process? I would like to run mpg123 only once,
> whichafter a few PHP scripts would send data and proper commands to its
> stdin. Maybe a kind of daemon process would be needed? Anyway, sending
> data to a daemon can be problematic... Maybe a kind of socket wrapper?
> Well - I have no experience about socket functions of PHP...
> 
> Tips and tricks are welcome, or should I just go to the local hi-tech
> market and by a CD player LOL :D
> 

I have done something similar using both mpg321 and madplay.  However I
used signals rather than holding open stdin.  It's a little ugly but
very simple, From memory:
STOP pauses
CONT resumes
QUIT causes it to stop playing and terminates the process
To play a new song, start a new process.
USR1 does something, I think USR2 does something too.  I just can't
remember what.

There should be documentation for mpg123 that explains all the signals
and how it reacts.  If not you could find it fairly easily by browsing
the source.


David

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux