NowPlayingWP

I designed this widget with the idea of extending Brandon Fuller’s Now Playing iTunes plugin to WordPress. First and formost, I give full credit to Brandon and his plugin for providing the integration itself with iTunes, and thus this plugin requires that you have a registered copy of Now Playing in order for this plugin to be of any use.

Download NowPlayingWP Version 2.1

Version 2.1 now supports the %PLAYING% tag and fixes the %TIMESTAMP% tag. You can now test the XML file to see if iTunes is stopped by testing the %PLAYING% tag. Finally, you can use all tokens and conditional structures in the pre and post widget formatting.

Version 2.0 contains significant updates. NowPlayingWP now supports pre and post widget formatting, allowing you to control the markup and text justification that NowPlayingWP is presented in. In addition, the plugin also allows you to list previous songs played etc. For more information, see below.

Version 1.0.2 now permits a %TIMESTAMP% token allowing the phrase to display what time the XML file was modified.

Version 1.0.1 Includes a minor bugfix which prevented the settings from being saved. Cheers!

To install:

Unzip the file, and place NowPlayingWP.php in your plugins folder.

Go to your WordPress dashboard and drag and drop the NowPlaying widget to wherever you’d like it.

Adjust the settings for NowPlayingWP by clicking on the icon to the right of the widget.

Specify the NowPlaying XML file and the output phrase. See below for the formatting of the phrase.

You should be good to go from there.

The Phrase:

You can use the following tokens:

  • %PLAYING%
  • %TIMESTAMP%
  • %ARTIST%
  • %ALBUM%
  • %GENRE%
  • %KIND%
  • %TRACK%
  • %NUMTRACKS%
  • %YEAR%
  • %COMMENTS%
  • %TIME%
  • %BITRATE%
  • %RATING%
  • %DISC% – Current Disc Number
  • %NUMDISCS% – Total Number of Discs in Compilation
  • %PLAYCOUNT%
  • %COMPILATION%
  • %URLAMAZON% – Amazon.com URL
  • %URLAPPLE% – iTunes URL
  • %IMAGESMALL% – Small Album Image URL
  • %IMAGE% – Normal Album Image URL
  • %IMAGELARGE% – Large Album Image URL
  • %COMPOSER%
  • %GROUPING%
  • %FILE%
  • %ARTWORKID%

Note that tokens are case sensitive and will not match if goofed up.

The conditional phrase:

Any token can be tested to see if the value actually exists. A condition is established using curly braces. The opening curly brace must immediately be followed by a positive or negative assertion (=, !), then by a token, otherwise it is not recognized as a conditional structure. Anything can trail the conditional token, including other tokens and other conditions. The trailing phrase is what’s returned if the condition is true.

Some may ask what the point of a condition is. It’s to allow for a logical phrase. Your phrase won’t be "Currently listening to Café del Mar by " with the word "by" there if there really is no Artist set in iTunes.

An example:

I am listening to %TITLE%{=%ARTIST% by %ARTIST%}.

Would output:

I am listening to I’ve Got Nothing to Say by The Shins. (If both song title and artist were present)

I am listening to I’ve Got Nothing to Say. (If only the title were present)

This is also a great way to test if Album artwork exists through Apple or Amazon, and to employ it using a phrase which contains HTML markup in it.

Previous Songs Etc.

A long awaited feature to be implemented, NowPlayingWP V2.0 allows you list off previous songs that may be in your Now Playing XML file. Because of the highly variable nature of the number of songs etc., I chose to implement this feature very loosely, which in turn provides you the greatest control.

Previous song data can be accessed by appending a number to the token. For example %TITLE% will output the current song title, as will %TITLE0%. Similarly, %TITLE1% will output the first song title before the current one, just as %TITLE2% will output the second song title before the current one etc. This index feature is applicable on all tokens, ie (%ARTIST2% etc.) and can be tested conditionally to see if it exists.

The easiest way to implement a track list in the NowPlaying phrase would be to repeat a phrase changing the index value appropriately. Testing the %TITLE#% token will prevent an output phrase unless there actually is a history to output.

An example:

{=%TITLE% Blah Blah About Current Song}

{=%TITLE1% Blah Blah About Previous Song}

{=%TITLE2% Blah Blah About Second Previous Song}

{=%TITLE3% Blah Blah About Third Previous Song}

Unless there actually is a Third Previous Song etc. in the XML file, that entire phrase will not be in the output.

Got questions? Email me !

Here’s a link to Brandon Fuller’s NowPlaying iTunes Plugin . I highly recommend you purchase a license. It’s inexpensive and well worth it.