A little while ago I wrote about my experience with Song Displayer. Song Displayer is a WordPress plugin that, together with a WinAmp plugin called DoSomething to display the song currently playing in WinAmp in your WordPress blog.
I wasn’t totally happy with Song Displayer or DoSomething. Song Displayer was just too plain and DoSomething kept crashing. So I began to look for other options. And I found one.
To replace DoSomething I found something called, appropiately enough, Now Playing. I configured it to work with Song Displayer and finally had a setup that wouldn’t crash.
While I was configuring Now Playing to work with my Song Displayer setup I noticed a link on the bottom of the page for a WordPress plugin called onAirNow. onAirNow is more advanced yet easier to use than Song Displayer. It has an options page in the WordPress Admin section as opposed to having to change options directly in the code as you have to do with Song Displayer.
onAirNow had the same malady as Song Displayer that was a problem for me. That is, it depends on ID3 tags being set up properly to get it’s information. That means that there is a field for the artist, album & title of the track it’s trying to display information for. This is fine for normal use but when I use WinAmp I am usually streaming MP3s from my portable MP3 player. When streaming tracks there is data in the title field only. The data in the title field isn’t what would be there if I were listening to the track in a standard way. It’s the actual file name. For example as I write this I’m listening to The Ocean by Led Zeppelin which is on the album Houses Of The Holy. When playing this track normally it will contain the following data:
Artist: Led Zeppelin
Album: Houses Of The Holy
Title: The Ocean
But when it’s streaming it will look something like this:
Title: Led Zeppelin – Houses Of The Holy – The Ocean.mp3
As I mentioned before, Song Displayer had the same issue and I fixed it there. Fixing it here was quite different but the same idea. I was able to do a much more elegant solution with onAirNow. After I implemented the fix in Song Displayer I could only display tracks properly when I streamed them. But my fix for onAirNow allows me to stream or play tracks regularly. And it only took a four lines of code to do it!
One of the features in Song Displayer was actually missing from onAirNow. Or at least it was handled differently. In order to display a message that says that nothing is playing onAirNow expects to see the file uploaded by Now Playing (or any other media player plugin that suits the same purpose) to upload a file with a specific code in it. Now Playing does not offer the functionality to upload a file when the player is idle (or closed) so onAirNow would alway report that the last track played before WinAmp was closed would be playing until the next time Now Playing would sent it a file.
Song Displayers idle message works differently. It checks the age of the uploaded file to determine if it should put up the idle message. In other words, if the last file was uploaded over 7 minutes ago (the default) Song Displayer puts up the idle message.
I added this waiting period feature to onAirNow in addition to it’s current functionality so that both approaches work. I have not yet added the functionality to adjust the time setting from the options page (I plan on doing that soon) so the setting is set to 7 minutes for now.