Click to See Complete Forum and Search --> : MP3 Server
horneyrabbit
01-23-2001, 04:56 AM
Hi ppl, okay heres the deal.
I have a dedicated box that has a 1.2 gig hdd in it that i want to sit in the corner very quietly (well quietish anyway) and play music through a soundcard using mpg123. Very simple?? yes, using telnet of course, but....
I want to have a web interface to control firstly the playing, pausing, next, prev, etc. etc.
I have looked at many different ones including goMP and such and have decided to write my own cgi in C to handle this very task.
So...
The question i have is how do i directly pass a variable to a process that is already running..
eg mpg123 -C * (i want to pass 'p' to the process and pause the song)
any suggestions are greatly appreciated.
Rabbit
------------------
I came, I saw, I broke, I left.......
YaRness
01-23-2001, 09:19 AM
sometimes someone has already done what you need, if you just look for it. this program is "A highly interactive Web frontend to mpg123". (quoted from here: http://freshmeat.net/search/?q=mp3+cgi )
http://freshmeat.net/projects/gomp/
it's got a few dependencies.. one of which at least is a perl module, but that's easy to install. yell if you need help.
------------------
"Assembly of Japanese bicycle require great peace of mind."
Registered Linux User #188285 http://counter.li.org/
nanode
01-23-2001, 01:49 PM
I know a dude how has a web based jukebox - where people can place requests. It will take a few dozen requests at a time, if/when it has no requests it will randomly select a song from a playlist.
I'm pretty sure this was all php/mysql stuff.
I can lookup the URL if anyone is interested.
r00t619
01-23-2001, 07:36 PM
What nanode is getting at is the following webpage:
http://streamcast.sourceforge.net/
The interesting links to look at from here are the Stream-DB and the PHPstream. There is also a demo you can run from the following links. http://www.linuxnewbie.org/ubb/biggrin.gif
r00t619
horneyrabbit
01-25-2001, 08:59 PM
Thanks for the feedback but as i mentioned i have looked at those options before and there isnt one that i particularly like compared to what i think i can create myself, also a good chance to move back into c coding again as i havent touched on it for a while http://www.linuxnewbie.org/ubb/redface.gif
Okay, i really dont want to have to use them because i have so much trouble using mysql, and the fact that the system it is running on is not very quick (133) i dont want to have huge background processing going on while the tunes are playing, so, could somebody please tell me how i could possibly go in,
firstly
Running a command from inside a cgi script
secondly
pass extra commands to that process while it is running
------------------
I came, I saw, I broke, I left.......
Stuka
01-26-2001, 01:29 AM
Here's a thought, but it will require some multithreading/synchronization issues:
1. Have a process that starts up, opens a playlist, and sends a new MP3 to the player (possibly via a 'system' call) every so often (maybe even w/a delay determined from the MP3 file itself?).
2. Start a second thread (CGI-type) that adds new requests to the playlist. This thread could just be waiting for the appropriate CGI request, I suppose - I don't know the details here....
3. Use some sort of file locking/mutex to keep the two processes from opening the playlist simultaneously.
Please don't ask me for many details...I know very little about CGI programming - but I might be able to assist w/the other stuff.
horneyrabbit
01-27-2001, 04:25 AM
Okay i gave up with c and decided to start learning Python, after about six hours of reading i decided to just head first into a cgi script that plays an mp3 file and displays the output of the song title to the web page, now the problems begin
okay the mp3 starts playing just fine http://www.linuxnewbie.org/ubb/smile.gif)
but the page takes about a minute to display on the page, its like its waiting for mpg123 to stop running or something, i have tried throwing mpg123 to the background but it still makes no difference
heres the code so far, and if it looks ugly then please tell me, as i said i only started doing this today
-------
#!/usr/bin/python
import string, os, cgi
#initialize directories
mymusicpath = "/home/mydir/music/"
song = "*"
t = mymusicpath + songlist
#run mpg123
os.system("mpg123 -q %s%s" % (mymusicpath, song))
#print web page
print "Content-type: text/html\n"
print "<html><head><title>MPlayer3</title></head>"
print "<body>Now Playing: %s\n</body></html>" % (t)
-----
i've also tried to swap the html around with the os.system command to see if it was actually waiting for mpg123 but it made no difference
i tried passing & (eg. mpg123 /home/mydir/music/* &) at the end of mpg123 as well to see if it would free the process from the script but it made no difference that way either
any ideas would be well appreciated
------------------
I came, I saw, I broke, I left.......
[This message has been edited by horneyrabbit (edited 27 January 2001).]
miller
01-28-2001, 03:09 PM
If you run mpg123 with the -R option, it runs in interactive mode. This was made for the mpg123 fontends. Chech out README.remote in the mpg123 distribution dir for how it works.
So, my idea is that when you start playing a song with your cgi program, it opens a named pipe (mkfifo(3)) for input and output, forks a new process and redirects stdin and stdout to the named pipes, and then execv's mpg123 -R. You can then write commands to the named pipe connected to stdin of mpg123 to start playing the song.
Then, when you want to pause, skip, etc, you can just have your CGI script open the named pipe for output, and write the command to mpg123.
The only problem is that I don't know anything about CGI, so you may not be able to fork and exec from inside the CGI program. If you can though, I think this might be the best way to do it.
Actually, the best thing to do would be to download those other ones to see how they communicate with mpg123 from within the CGI script.