From Song Displayer to onAirNow

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.

Tags: , , , , ,

If you enjoyed this post, please consider to leave a comment or subscribe to the feed and get future articles delivered to your feed reader.


I’m glad you find onAirNow useful!
If you send me your additional four lines of code I may include them in future versions of onAirNow. (I’ve already thought about adding some kind of template function to alternatively parse a string to get the info.)

Daniel –

Below is an If..Else from the onAirNowGetInfo() function. The if and the else are yours. The elseif is mine.

if ($currentTuneArtist != “” && $currentTuneTitle != “”) {
return array(‘artist’ => $currentTuneArtist, ‘title’ => $currentTuneTitle, ‘album’ => $currentTuneAlbum);
} elseif ($currentTuneTitle != “”){
$this_song = explode( ‘ – ‘, $currentTuneTitle);
$this_song[2] = substr($this_song[2], 0, (strlen($this_song[2])-4));
return array(‘artist’ => $this_song[0], ‘title’ => $this_song[1], ‘album’ => $this_song[2];

} else {
return false;

I also added the ability for the plugin to know the age of the onAirNow.track file by checking it’s age. If it’s over 7 minutes old then it will display the idle message. I added that to the beginning of onAirNowGetInfo() by adding vriteria to your if statement as follows (the 420 means 420 seconds which equals 7 minutes):

if (file_exists($oan_file) && date(“U”, @filemtime(“$oan_file”)) > time()-420)

My next steps are:
– adding the ability to edit the idle time above through the options page
– the ability to show track number and/or year (with their associated additions to the options page).
I don’t know when I’ll get to do these. My original goal was just to customize it for myself and do anything else as time allows so it may take a while to do these extra things. You are definitely welcome to any code I use when adding these features.

– Dave

OK. I had a little time so I added the ability to edit the idle time mentioned above through the options page. It turned out to be easier than I thought.

I also added the track number with accompanying Admin page functionality and CSS. With this functionality I added a routine to strip a leading zero off of the track number. I did this because in my case when I stream from my MP3 player all single digit track numbers are reported with a leading zero (3 becomes 03).

[…] Thanks to Dave for some ideas! […]

Thanks for leading me to onAirNow. Much appreciated 🙂

I’ve noticed you encountered the same problem I did when trying to use artwork with NowPlaying.

Can you please tell me when is your widget going to be ready?


LexArrow – I’ve sent my code for the widget to Daniel Gattermann, the writer of onAirNow, who told me that it will be integrated into the next version of onAirNow. If there is sufficient interest I will make the widget available here until Daniel releases the next version.


Would it be possible to get a copy of your widgitized version of on air now?

Thanks in advance

Drumbo –

The widget is now available. Click here for more information.

– Dave

Thats great! Thanks Dave – off to go and get it


Can I also ask what application you use to upload the itunes information?

I use Winamp for playing MP3s on my desktop and NowPlaying for uploading from Winamp.

Since I don’t use iTunes I’m not sure what you need to upload from there. However you can start by trying Now Playing for iTunes (which is not related to the one I use for Winamp).

Once again – thanks! I use nowplaying already (the one from Brandon Fuller), but I have problems with the album art so I wanted to see if the one you used would work better for me! Oh well will have to stick to no album art!

Leave a comment