Podcastplayer in flash! Php script to convert RSS to XSPF

Big Sound, Little Ears

photo credit: …Tim

Create your own free flash based podcast / mp3 player

I like the flashbased XSPF mp3 player. I had planned to rewrite the actionscript so that it could read rss with enclosures instead, but I liked the possibility to have unique pictures on each track, and I wanted to check out the XSPF format.

So I wrote a PHP script that uses DOMXML and xpath to convert an existing rss to xspf, it even have a search function of sorts.

I’m going to use it on a project I’m working on after a little more tweaking but I wanted to share it with other people who has a podcast and want a quick open source way to present their podcasts on their website.

Localino meets elePHPant
photo credit: Chregu

<?php

$path = “http://podkast.nrk.no/program/radioresepsjonen.rss”;

$showfile = file_get_contents($path);

if(!$doc = domxml_open_mem($showfile)) {

echo “Error while parsing the document…”;

exit;

}

$xpath = xpath_new_context($doc);

$root = $doc->document_element();

//debugging

//echo domxml_version();

//var_dump(xpath_eval_expression($xpath, ‘/rss/channel/item’)); //http://no.php.net/manual/sv/function.xpath-eval-expression.php

//debugging – memory dump

//echo $doc->dump_mem( true, ‘UTF-8′ ) ; //http://no.php.net/manual/sv/function.domdocument-dump-mem.php

//print ” Path: <a href=\”$path\”>$path</a><br>\n”;

//print ” Showfile: <a href=\”$showfile\”>$showfile</a><br>\n”;

//print ” domDoc: <a href=\”$domDoc\”>$domDoc</a><br>\n”;

//print ” root: <a href=\”$root\”>$root</a><br>\n”;

// playlist plus search function

$playlist = $xpath->xpath_eval(“/rss/channel/item[contains(translate(title,’abcdefghijklmnopqrstuvwxyzæøåö’, ‘ABCDEFGHIJKLMNOPQRSTUVWXYZÆØÅÖ’), ‘”.strtoupper($_REQUEST[“search”]).”‘)]”);

//debug

//print “playlist found: “.count($playlist->nodeset).”\n”;

print “<?xml version=\”1.0\” encoding=\”UTF-8\” ?>\n”;

print “<playlist version=\”0\” xmlns=\”http://xspf.org/ns/0/\”>\n”;

print ” <title>Put clever title here, or get it from the rss</title>\n”;

print ” <annotation>Description of some sort</annotation>\n”;

print ” <creator>Who made this</creator>\n”;

print ” <info>http://link to more info</info>\n”;

print ” <location>http://yourdomain.com/doesnreallymatter/rss2xspf.php</location>\n”;

print ” <license></license>\n”;

print “<trackList>\n”;

foreach ($playlist->nodeset as $tracklist) {

$description = “”;

$title = “”;

$enclosureurl = “”;

//$enclosureurl = $tracklist->get_attribute(“length”);

//$spor = $tracklist->get_attribute(“spor”);

//$sangid = “$arkivnr-$spor”;

foreach ($tracklist->child_nodes() as $child) {

if ($child->node_name() == “title”) $title = $child->get_content();

if ($child->node_name() == “description”) $description = $child->get_content();

if ($child->node_name() == “enclosure”) $enclosureurl = $child->get_attribute(“url”);

}

print “<track>\n”;

print ” <location>$enclosureurl</location>\n”;

print ” <image>hassan/bilder/else150.jpg</image>\n”;

print ” <annotation>$title</annotation>\n”;

print ” <info></info>\n”;

print ” <info_text>$description</info_text>\n”;

print ” </track>\n”;

}

print “</trackList>\n”;

print “</playlist>\n”;

?>

Copypaste the above code into a new file and save it as rss2xspf.php and upload it to your server to test if you have domxml support. (If you don’t it will say something like Call to undefined function: domxml_open_mem. In that case, tough luck, find a new host.)

Download the exellent XSPF flash based mp3 player here: XSPF Web Music Player (Flash) – Plays MP3 on your website

Read more about XSPF over at http://www.xspf.org/

And please drop a comment if you use it and like or have problems.

You can also send me an email at morten.skogly _at_ gmail dot com.

There’s a lot of room for improvement, like using the rss image in place of a staticly defined image, or inserting a random image, or doing som web2.0 stuff like snarfing the images from amazon or whatever, please let me know if you make something superclever with it :)

Idea for your site: You can use del.icio.us to make your own mp3 podcast, visit bands you like bookmark the mp3s you like with del.icio.us, go there to get the rss, and your set to go, you have the same music on your site as on your ipod :) (You might have to use feedburner.com as a gobetween to create the enclosures and make it itunes-compatible.)

Updated: 06.04.2008: Unless you really really digg the XSPF player linked up above, I suggest you use the superb Jeroen Media Player instead. It is open source and supports both XSPF and RSS directly. It takes up more space, but it has video support and a very cool javascript api.

Podcast review – NashvilleStandUp.com

I’ve been a subscriber for the podcast from NashvilleStandup.com, but ended it today. Here is the email I sent them:



comments:

Just wanted to say sayonara. Ive downloaded some of your shows as podcasts, and have come to the conclusion that they, well, suck. I’m 6 minutes into the 15th of october show, and so far there has not been anything worth listening to, just noise, crappy sound, internal backslapping and general boredom.

Here’s a tipoftheday for ya: Editing

Here’s another: Add some more standup jokes, and add previews to the beginning so the listener at least have something to look forward to.

Oh, and another: It is cool to actually be able to hear what people say, put on headsets so you can hear whats actually recorded, the sound on that show was just awful, the first 6 mindsplittingly bad minutes of it.

There are very few standup podcasts available, so you have very few competitors, but that doesnt give you carte blanche to do bad work. The listeners deserve better.

Bye!

m.

I hope they get their act together. I love standup, but the only other podcast I’ve got in this genre is the Tom Shillue Live Comedy Podcast, only updated once every blue moon. Please, happy podcasters out there, whip out that mike and record some more standup for me. I know you can do a better job than the Nashville standup crew.

N’Sup – NashvilleStandUp.com – Stand-up comedy news, events, links and info from Nashville, Tennessee

On Del.icio.us: , ,

Beyond Organic Radio Show – About the Show

Came across Beyond Organic on the Aural Traditions podcast, that did a rebroadcast of their excellent Permaculture show and though I would check out their site. And here is an oddity: They provide their entire archive as mp3 for download, but no podcast feed in sight. To me that is like a man dying of thirst sitting a foot from a river. I sent them an email begging them to create a feed, I hope it comes up soon. I’m just to lazy to download manually and import to Itunes etc. That is a rather strange effect of Itunes, its so easy to use that is simply carves new media habits into me in just a few months. I’ve dropped live radio and even on demand shows completely, if it ain’t provided as a podcast, I couldn’t care less.

Except that is, in the case of the Beyond Organic show. Maybe.

Beyond Organic Radio Show – About the Show:

The Beyond Organic radio show is an unique environmental radio and multimedia program, addressing issues of organic food and farming, social and environmental sustainability.

The show offers news, interviews and research that fills a void left by public and private broadcasters.

On Del.icio.us: , , , ,

Radio Clash Mash Up Podcast – a weekly podcast of mixes, mash-ups, and more!

Radio Clash Mash Up Podcast – a weekly podcast of mixes, mash-ups, and more!: “Well, Radio Clash is a weekly mashup podcast from your host, Tim in London, UK and includes mash-ups (of course), mixes, weird covers and more! Bringing you the history of mash ups, bootleg events, news & views of the bootlegging scene since November 2004.”

Recommended by Tracks Up the Tree (The return of the human tangent)

PodcastChapterTool – Voxmedia Wiki

PodcastChapterTool – Voxmedia Wiki: “Apple’s chapter system adds an entire new dimension to podcasts. For the first time, true podcast ecommerce, or pCommerce for short, is possible. Chapters add the ability to embed links and graphics displayed in sync with the podcast. Now podcasters can discuss a product or website, place a graphic representation for it on the screen and simultaneously provide a hyperlink that, when clicked, would give the podcaster credit for that clickthrough and tie in to existing e-commerce systems. Additionally all new types of podcasts are now possible: Artwork podcasts that actually show the artwork they are discussing, story-based podcasts that use the chapter art as illustrations, soundseeing tours that show pictures of what the tour guide is discussing and more.”

iTunes adds podcast directory

Oh my, this is kind of a big thing. iTunes have finally gotten around to building a podcast downloader into their fine software. This will give a big boost to the popularity of podcasting. Hats off everyone, glad to get rid of ipodder (house of wax version) og doppler.

Blabla: “Apple – iTunes – Podcasts Directory: “Try this on the Internet: Search through thousands of podcasts, find a few that really speak to you, then devise a way to collect every single episode. In minutes. Or you could just visit the iTunes Podcast Directory. Find free podcasts from everywhere, all in one place.”

2600 | Off The Hook

2600 | Off The Hook

Off The Hook is the hacker’s view of the emerging technology, and the threats posed by an increasingly Orwellian society. Hear updates on security flaws from the hacker perspective, as well as the latest news from within the hacker community.

Harvest the podcast

http://www.2600.com/rss.xml

Hilton ‘House’ waxing high-tech

Hilton ‘House’ waxing high-tech: “Paris Hilton has had some ill-fated encounters with technology as evidenced by her T-Mobile Sidekick and digital video incidents, but she’s still keen to try the latest thing. The multimedia starlet has agreed to podcast about her social and press events in the buildup to the May 6 release of her upcoming feature film, ‘House of Wax.'”

Get the podcasts here: http://houseofwaxmovie.warnerbros.com/podcast.html