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:
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:
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:
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:
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.