Recently I decided it would be a good idea to rebuild the part of the project that actually played the songs.
I’ve added various plugin hooks. The idea is blatantly borrowed the idea from wordpress.
They basically have an array of functions that need to be ran during a specific event.
Since I have to run this thing in 2 different processes, the ‘player’ and the ‘picker’ process. I have 2 hook systems.
PLAYER HOOKS
————
before_play(function_name);
This is executed just before mplayer plays a song.
Things this could be useful for:
* ‘station id’ every x songs.
* a ‘notify’ sound if the song is rated 11.
* ices metatag update.
* remount script for network drives.
PICKER HOOKS
————
on_songchange(function_name);
* A Song logger
* scan for new songs
* osd
* id3 tag sync.
* rename previous song according to it’s dbinfo. Found in
$player->previousSong
wait_loop(function_name);
* Do something every 5 seconds. The Picker process sleeps for 5 seconds, and
then checks if the song has changed.
a. This is useful to check mountpoints and remount if needed.
- The plugins I’ve made for the player process:
- remount.php
- remounts the drive if the mp3 does not exist.
- The plugins I’ve made for the picker process:
- remount.php
- Also checks every 5 seconds. Probably doesn’t need to be a player process, however I wanted to demonstrate how you could have a plugin work in both the player, and picker processes.
- log.php
- Log what songs are being played into a clf format for parsing by webalizer. Agents are ‘artists’ and ‘pages’ are songs. Nice way to tell what’s getting played, and how often.M.
- osd.php
- On screen display of the current song and ratings of specified users. Eventually I plan on adding a wait_loop osd when people login/logout.
- scan.php
- This is almost a ‘required’ plugin. Because if you’re not scanning directories for new songs, then how are you going to hear the new stuff? – almost complete.