Click here to Skip to main content
12,823,954 members (44,589 online)
Click here to Skip to main content
Add your own
alternative version


18 bookmarked
Posted 25 Sep 2009

Podcast (RSS) to Playlist

, 1 Oct 2009 CPOL
Rate this:
Please Sign up or sign in to vote.
Convert podcast feeds into a variety of playlist formats on the fly by applying XSLT on RSS XML

Windows Media Player

Windows Media Player playing the Channel9 video podcasts as a playlist.


This article and its code provide a simple way to take a podcast feed and convert it to a playlist file/URL that Windows Media Player, Windows Media Center, Winamp or other players can play by applying XSLT on RSS XML.


I use Windows Media Player (WMP) to watch/listen to several video/audio podcasts. The problem is that it’s not the best player for podcasts and doesn't really have any built-in support for them. I've tried applications such as Juice and a few add-ins for Windows Media Center (such as TV Tonic), but they all seemed to always download the podcast files to a local directory and usually needed to be running in the background to keep the directories in sync with the latest episodes.

I wanted something to where I could just click on a link or plug in a URL in WMP and have it automatically start streaming the latest podcast episodes without waiting for anything to download. I also didn't want to ever have to clean up any directories by removing older files or install any other applications or plug-ins. I wanted to be able to click the next/previous buttons on my keyboard (or remote) and be able to skip to the next or previous episodes in the podcast, just like a playlist works.

The key here is that I wanted a RSS podcast feed, to behave just like a playlist in WMP. The problem is that WMP doesn't understand RSS XML, but it does understand the ASX (Advanced Stream Redirector) playlist XML (among other playlist formats). What I decided to do is create a C# script to take the RSS XML and convert it to ASX XML (or other playlist formats) using an XSLT transformation file.

A Solution

The solution here is just a single .ASPX file (RssToPL.aspx) along with whatever playlist format XSLT files you want to support. To keep this example simple, I just placed all the C# code into the single .ASPX file (no code behind). As long as your XSLT files (RssToAsx.xslt, etc.) are in the same directory as the .ASPX file, you should be set.

If you are utilizing this for your own personal use (like me), this can either be placed on your own personal web server (running on your local machine or elsewhere). If you are a content provider producing podcasts, this is a easy way to provide your users several different ways to access your content.


<%@ Page Language="C#" %>
<%@ OutputCache Duration="240" VaryByParam="*" %>


<?xml version="1.0" encoding="utf-8"?>

    <!-- indicates what our output type is going to be -->
    <xsl:output method="xml" encoding="utf-8"
	indent="yes" omit-xml-declaration="yes" />

    <xsl:template match="rss/channel">
        <asx version="3.0">
                <xsl:value-of select="title"/>
                <xsl:value-of select="description" />
            <xsl:apply-templates select="item" />

    <xsl:template match="item">
        <xsl:variable name="item_enclosure" select="enclosure/@url"/>
            <xsl:if test="string-length(enclosure/@url) > 10">
                        <xsl:value-of select="title" />
                        <xsl:value-of select="author" />
                        <xsl:value-of select="description" />

                    <ref href="{$item_enclosure}"/>


This XSLT file will only return items with an enclosure, so you don’t have to worry about RSS feeds that mix in blog entries with the podcast.

To use this ASP.NET script, you just need to pass in the URL of the RSS feed and it will return the ASX file (as either inline XML or as a download). For example: http://[yourhost]/RssToPL.aspx?RssUrl= would return a playlist with the MSDN Channel 9 videos (in reverse chronological order).

To take this a step further, I also wanted to be able to have multiple podcasts show up in the same playlist. For example, I wanted both the ".NET Rocks" and "Hansel minutes" podcasts to show up interwoven together in one playlist, sorted by date (not all the ".NET Rocks" first and then all "Hansel minutes" last).

To do this, I decided to use Yahoo Pipes rather than write my own code. Yahoo Pipes is an awesome tool that basically lets you create custom RSS feeds (among other things) based off multiple sources and be able to manipulate them in many different ways. Yahoo Pipes does a lot more than that, but I won't get into it here. Also, if Yahoo Pipes seems a bit complicated for you, you could also use something like RSS Mix.

Using the Code

On the web server, place the RssToPL.aspx and RssToAsx.xslt into the same directory on your ASP.NET web server. The following table lists the QueryString parameters:

RssUrlThe URL of the podcast RSS feed.
Inline (optional)True or false. If set to true, the XML will show up in the browser window, otherwise the browser will prompt to download the ASX file.
OutType (optional)The output file type of the playlist to return (M3U, WPL, ZPL, WVX, SMIL, PLS, etc.) and define the XSLT file to use. If this parameter is left out, it will default to ASX.

On the client machine (the computer you are using to watch/listen to the podcasts), there are two ways I have effectively used this. One is just by creating a shortcut on your desktop (or some other folder) to the script URL. This way, if you double click the shortcut, it will open Internet Explorer then just prompt you to open the ASX file in Windows Media Player (or your default ASX player), then Internet Explorer automatically closes. I've found this works best with WMP, because it lists all the episodes in the "Now Playing" pane.

The other solution is just to create a hard coded ASX file on your computer that just has a reference to the script URL. For example, place either of the following entries in your ASX file:

<entry><ref href="http://[yourhost]/RssToPL.aspx?RssUrl=[RSSURL]" /></entry>


<entryref href="http://[yourhost]/RssToPL.aspx?RssUrl=[RSSURL]" />

I’ve found this solution works best if you are using Windows Media Center.


  1. I chose the ASX format as the default because I have worked with it before, but outputting to other formats, such as .M3U, .WPL, .ZPL (Zune), .WVX, .SMIL, .PLS, etc., for other players should be as easy as adding another XSLT template file and changing the OutType QueryString parameter. I've included ASX, M3U, WPL XSLT files in the example. Also, I believe ASX playlists will work with other players such as RealPlayer, Winamp, Media Player Classic, Windows Media Player Mobile, VLC, etc., but it isn't something I've extensively tested.
  2. For complex feed URLs (especially URLs with other QueryString parameters in them, you'll probably need to encode the URL (Server.URLEncode) for this script to work properly.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

William Grubbs
Team Leader Kendle
United States United States
No Biography provided

You may also be interested in...

Comments and Discussions

GeneralScript Observations [modified] Pin
ramjam5030-Jan-10 23:43
memberramjam5030-Jan-10 23:43 
GeneralRe: Script Observations Pin
William Grubbs1-Feb-10 19:29
memberWilliam Grubbs1-Feb-10 19:29 
GeneralRe: Script Observations Pin
ramjam502-Feb-10 17:13
memberramjam502-Feb-10 17:13 
GeneralEasy way to merge feeds Pin
dalej29-Sep-09 6:07
memberdalej29-Sep-09 6:07 
GeneralI like Pin
Joel Ivory Johnson29-Sep-09 3:29
memberJoel Ivory Johnson29-Sep-09 3:29 
Simple yet incredibly useful.

Joel Ivory Johnson
My site:
Twitter: J2iNet

GeneralRe: I like Pin
William Grubbs30-Sep-09 6:11
memberWilliam Grubbs30-Sep-09 6:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.170308.1 | Last Updated 1 Oct 2009
Article Copyright 2009 by William Grubbs
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid