Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

The WPF Podcatcher Series - Part 1 (Introducing Podder)

0.00/5 (No votes)
6 Jan 2008 1  
The first article in a series devoted to a WPF application that plays streaming podcasts off the Internet.
Podder_Screenshot.png

Introduction

Welcome to the first article in a series devoted to a WPF application I wrote, called Podder. Podder allows you to listen to podcasts streamed over the Web. The aim of this article is to introduce Podder and let people around the world start enjoying it. The goal of this entire series, however, is to review interesting aspects of Podder�s design and implementation.

At the time of this writing, the application is incomplete. There are still many features, both big and small, that I intend to add to Podder. However, it is far enough along at this point to get this series off the ground, so I decided that sooner is better than later. The file downloads, located at the top of this article, will most likely change every time there is a new article in the series. Podder is a living project.

Background

A podcast is like a radio show; it is a series of episodes recorded by the same person or people about some particular topic. It can contain any audio content, since it is just a regular audio file, such as MP3. An episode can contain interviews, monologues, music, the sound of one hand clapping, etc. Almost every podcast has an RSS feed associated with it, so that you can easily find all episodes in the podcast, and discover newly released episodes.

A podcatcher is a program that allows you to play podcast episodes. Most podcatchers allow you to subscribe to various podcast RSS feeds, and will automatically notify you when a new episode is available. Podder allows you to maintain a list of podcast RSS feeds, but does not yet provide any notifications when new episodes exist.

The Podder application was created after I had built two simple podcatcher prototypes; the first was in Silverlight and the other in WPF. Podder is much more sophisticated and feature-rich than those two prototypes, but they were excellent learning experiences necessary for me to figure out how to design Podder correctly.

Technologies Used

  • VS2008 & .NET 3.5
  • WPF
  • XLinq
  • C# 3.0

Podder Features

The application has the core features one might expect in a podcatcher, and a few extra bells and whistles that I enjoy using. Here is what you will find in Podder:

  • Store a list of podcast RSS feeds and view all available episodes
  • Stream episodes for immediate playback
  • Standard play, pause, and stop functionality
  • Seek through a podcast, like fast-forward and rewind
  • Indicate which episodes are your favorite, and view them in a �My Favorites� list. That list is persisted between runs of the application.
  • Remember which episodes you have already listened to because they are marked as �finished� when they complete. The list of finished episodes is persisted between runs.
  • Optionally play every episode in a podcast in an endless loop
  • Refresh the list of episodes in a podcast, which is useful for frequently updated podcast feeds
  • Open an episode in an external program (either a Web browser or an MP3 player, depending on the podcast)
  • Tooltip over episode item in ListView displays extra information such as publication date and file size
  • Window sizes, states, and positions persist between runs of the application
  • Various user interface settings persist between runs of the application
  • Pre-loaded with some podcasts, so new users can immediately start listening to episodes
  • Podder will eventually allow you to apply completely different user interfaces at runtime (a.k.a. �structural skinning�)

Picture Gallery

Here are some screenshots of Podder, using the default skin (at this point, it is the only skin). The first image shows the list of favorite episodes and a tooltip over an episode, displaying extra information about it.

Podder_Favorites.png

The next image shows the list of podcasts I have entered into Podder. Notice that the first item in the dropdown allows you to view the list of favorite episodes.

Podder_Podcasts.png

The screenshot below shows the context menu that appears when you right-click on an item in the ListView. The menu item allows you to open an episode in a Web browser or MP3 player, based on the URL provided in the podcast RSS feed�s <link> element. If it is a Web page URL, the page will open in your default browser. If it points directly to an audio file, it will open in your default audio player (such as Windows Media Player).

Podder_OpenInExternalProgram.png

The last image shows the dialog box used to add and remove podcasts to the application�s list of podcast RSS feeds. At the time of this writing, this dialog box does not provide any validation, but it will in a subsequent release.

Podder_ManagePodcasts.png

Points of Interest

There are many interesting things to explore in Podder. This section lists some of them, and the next articles in the series explore some of them in detail.

Structural Skinning

Podder supports what I call �structural skinning�. Structural skinning allows you to apply a completely new user interface to the application at runtime. You can replace all of the controls in the UI, as well as the color schemes, fonts, etc. It uses the Model-View-Controller (MVC) pattern, routed commands, collection views, and dynamic resource references to make this possible. A future article in this series will review this topic in depth. As of this writing, Podder does not have any additional skins, but it will soon.

EpisodePlayer

The application uses WPF�s MediaPlayer class to play episode MP3 files. I subclassed MediaPlayer to create EpisodePlayer, which encapsulates MediaPlayer manipulation and workaround for its quirks. A disproportionately large amount of my development effort was spent on working around strange behavior of MediaPlayer. I have ironed out all the issues, as best as I can.

Reading an RSS Feed with XLinq

A podcast�s RSS feed is just like any RSS feed, it is just an XML document. Since Podder was written against the .NET 3.5 Framework, I used XLinq to transform an RSS feed into instances of my Episode class. Using XLinq made the XML processing much easier.

Serializable Data Model

Podder does not use a database or XML file to save its data. When the window closes, it serializes the data model using BinaryFormatter and saves that binary stream to disk. When the application opens again, it deserializes the data in that file and the application then uses those objects.

The application�s domain classes are in the PodderLib project. Most of those classes derive from my BindableObject base class, which provides an implementation of INotifyPropertyChanged, amongst other things.

Persisted Window Settings

Both the main window and the �Manage Podcasts� dialog box remember their size, state, and location between runs of the app. They both derive from my ConfigurableWindow base class to gain that functionality for free. That class was built specifically for Podder, but can be used in any WPF program.

So Much More�

It is difficult to create a list of �interesting� aspects of an application�s code base, because everyone sees things differently. If you are interested in seeing what else Podder has to offer, I suggest you download the source code and explore it on your own. If you have any questions, feel free to leave a question or comment on this article�s message board.

Not Yet Implemented

  • Ability to dynamically discover and apply external skins
  • Awareness of an active Internet connection, or lack thereof
  • An improved Podcast management dialog
  • User-friendly error handling
  • An aesthetically pleasing UI
  • Notifications of when a new episode exists in one of your feeds
  • A whole lot more!

Special Thanks

Craig Shoemaker, the host of Polymorphic Podcast, provided a lot of helpful feedback, insightful suggestions, and encouragement.

Karl Shifflett helped a lot with testing and submitting bug reports. He also gave some tasteful feature requests.

Sacha Barber indirectly assisted because his article about XLinq helped me get up to speed with XLinq enough so that I could use it to parse RSS feeds.

Revision History

  • January 6, 2008 - Created the article

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here