WPF Podcast Player

This post shows a simple WPF application that plays podcasts.  The podcast information comes from RSS feeds.  The user has rudimentary control over a podcast, such as pausing and resuming it, adjusting the volume, and muting the podcast player.  Almost the entire application is in XAML.

In a previous post on my other blog, I showed how to create a very basic podcast player using Silverlight 2.0.  After finishing that project, I wanted to come back to WPF and build a better podcast player.  It was such a relief to return to the feature-rich world of WPF, after living a Spartan existence over in Silverlight land.

Here is what my WPF Podcast Player looks like:

WPF Podcast Player (screenshot)

As you can see, the application definitely does not provide a luxurious experience; it is pretty bare bones.  But it does offer the fundamental things need to start, pause, resume, and stop a podcast.  The only part of the application that required me to write code is pausing and resuming a podcast, since you have to call the Pause and Play methods on MediaElement.  You cannot call those methods from XAML.  In addition, a simple value converter class exists to detect if a podcast is an MP4 file, so that we do not show it (MediaElement does not seem to support that format).

All of the podcast RSS feeds are hard-coded into the ComboBox on top of the UI.  The selected item in the ComboBox is used to get the data source from which all podcasts are retrieved.  Here is how that works:

WPF Podcatcher (data sources)

Since we are binding to an RSS feed, which is an XML document, we can use XPath to pull out the values displayed in each ListBoxItem.  Here is the template used to display a podcast in the ListBox:

WPF Podcast Player (podcast template)

The remainder of the UI is just a bunch of controls which provide the user with a means of consuming and adjusting podcasts.  Here is the XAML for most of the UI:

WPF Podcast Player (controls)

Download the Visual Studio 2008 project here: WPF Podcatcher for VS2008

Download the Visual Studio 2005 project here: WPF Podcatcher for VS2005

Be sure to change the file extension from .DOC to .ZIP and then decompress the file.

8 Responses to WPF Podcast Player

  1. Rob says:

    What about using a ToggleButton for the pause and mute functionality? You could use DataTemplate/DataTrigger to bind different graphics as Content for the buttons based on their state – no code required.

  2. Josh Smith says:

    Rob,

    Sure, there are a million things we could do to spice up the UI. I was more interested in just getting the app to work, and maybe one day I’ll make it look nice. That’s the hard part! 🙂

    Josh

  3. Karl Shifflett says:

    Josh,

    Just went and finished my Christmas shopping. On the way back, this player realling got me thinking. Brain cells bounding around all over the place.

    I need 20 more hours in each day so I can write all these programs that keep poping into my brain.

    After Mole – Unlimited is released, I’ll take a day or two and write it.

    Nice work on this player. It plays Podcasts perfectly!

    Cheers,

    Karl

  4. Josh Smith says:

    Karl,

    I knew this app would get you going!! 🙂

    Have fun!

    Josh

  5. Karl Shifflett says:

    Your a cat, playing with his MOLE!!!!!

  6. Josh Smith says:

    Karl,

    I actually found several uses for Mole while creating this little podcatcher! Mole ROCKS!!!

    Josh

  7. This is a great way to deal with content.

    I’m going to deal with a local xml file for the content and allow easy changes to be saved.

    Funny how we listen to some of the same content.

    I’ll then toss it over the wall to my designer for a look and feel.

  8. Josh Smith says:

    Stephen,

    If I was going to make this a “real” app, the first thing I’d do is externalize the RSS feed source data, too. I just wanted to keep this demo app nice and simple, to show how easy it is to do cool things like bind to RSS feeds in WPF. 🙂

    Thanks,
    Josh