First Textpattern Plugin
I listen to iTunes almost constantly. In an effort to experiment with Textpattern’s cool plugin system, I worote myself a plugin that utilizes Brad Fuller’s What’s Playing script. Essentiall, his script writes the currently playing iTunes for Windows song to a webserver as an XML file.
What I have essentially done is read that file and output it. It’s not that elaborate really. But I’m thinking about utilizing his amazon web services example to get album info as well. We’ll see. For now, the function is essentially:
function it_ituneswin($atts)
{
if(is_array($atts))
extract($atts);
$xml_parser = xml_parser_create();
if(($fp = fopen($xmlfile, “r”)))
{
$data = fread($fp, filesize($xmlfile));
fclose($fp);
xml_parse_into_struct($xml_parser, $data, $vals, $index);
xml_parser_free($xml_parser);
$title = $vals2[“value”];
$artist = $vals5[“value”];
$album = $vals8[“value”];
}
$data = “
$data .= “Current iTunes Song
”;
$data .= $title.” – ”.$artist.”
”;
$data .= “
”;
return $data;
}
?>
Of course it’s used via the textpattern plugin syntax which is very cool, if a little undocumented.
Cheers.
Aaron
Pick up your copy of the WordPress Bible, a wildly popular resource for beginners and experts alike.
Popularity: 1% [?]



Search