mp3 player
Saturday, July 10, 1999, at 06:56AM
By Eric Richardson
Over the last few days I finally got my mp3 player rewrite working. Shared memory was a real pain (as was trying to implement multi-threading in Perl), but yesterday it suddenly started working. Click for more about the architecture.
The mp3 player is comprised of three parts: a server, a player, and the client.
The server sleeps a lot. It's main job is to sit around holding the shared memory and spawn players when the client tells it to. It's a really simple script (a whole 99 lines).
When a player is spawned by the server it looks to see what file it should be playing, logs to the database, and then spawns an mpg123 process to do the actual playing. It then waits around for that to finish. If it recieves a SIG{USR2} it will either restart the song (respawn itself) or exit early (closing the mpg123 process) depending on what message it's sent by the client.
The client does all the playlist manipulation. It adds songs to the server's song array (either a file or a whole directory of files) via the shared memory. It's also in charge of telling the server when to start and stop playing. At any time the client is able to add songs to the song array, move songs around in the array, or delete songs from the array. It also has a little randomize feature to resort the playlist randomly.
I'll probably stick this up at eScripting soon. Eventually I want to program a GTK frontend to it (the client is currently text), but I haven't had time yet.