Question

I'm using mpg123 in a linux server and I'm trying to control it through a webpage (apache), using links to send different controls.

mpg123 has the -C flag so you can send characters to it. "s" key = start/stop, "f" key = next track... and so on.

I think I can send mpg123 those keys with a fifo, changing mpg123 stdin to the fifo stdout but i don't know how to use the fifo in this case (how to make mpg123 "listen" to another stdin). What I've done is:

mkfifo myfifo
myfifo | mpg123 -C -@ musiclist.txt
And then I've created keys.txt adding some keys to the file:
echo "f" >> keys.txt
echo "s" >> keys.txt

Then:

cat keys.txt >> myfifo.fifo

This does not work. Can someone explain ow can I use fifos to pass messages to a running mpg123? I've googled it but can't find what I want.

This question seems to give me some light, but I still don't know how to make mpg123 listen to the fifo's output.

Thank you in advance,

Was it helpful?

Solution 3

mpg123 has it's own --fifo option

OTHER TIPS

What are you using to pipe myfifo?

I'll assume cat myfifo | mpg123 -C -@ musiclist.txt

cat will close after the first file piped through myfifo. Try using tail -f myfifo | ... instead to keep it open after EOF.

mkfifo myfifo
tail -f myfifo | mpg123 .. &
# send commands
echo .. > myfifo
sleep 5
echo .. > myfifo

tail is optional unless mpg123 exits if it receives EOF on stdin. Otherwise you could use: <myfifo mpg123 ...

& at the end (control operator to execute the command in the background) is optional if you run echo commands in another terminal.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top