Geeks With Blogs
Drewby Made from 60% post-consumer recycled fiber.

I’m a big fan of PlayOn form MediaMall Technologies which is an application that allows you to view videos from popular sites like Hulu, CBS and Netflix on your Xbox 360, Playstation 3 or DLNA-compliant television or set-top-box. I’m also a big fan of Channel9, the “official” unofficial source for developer information from Microsoft.

In a recent release, MediaMall implemented a PlugIn API for PlayOn that allows a developer to add new media sources to the PlayOn menu. Developers have already added several sites including such as Food Network, Adultswim, NBA, NFL, and more (you can get a list here). There is also a generalized player that uses OPML lists of content – there’s a collection of OPML lists here.

I decided to write a PlugIn for PlayOn that would allow me to browse and watch my favorite Channel9 videos and shows. I was delighted to find out that PlayOn is a .NET Framework application and the PlugIn samples were Visual Studio projects. So I already had the skillset to build my own PlugIn.

Here’s a video of the plugin in action so you can get an idea of the experience:

<br /><a href="http://video.msn.com/video.aspx?vid=f5da0992-dc81-4f48-8e85-8528776321e6" target="_new" title="Channel9 PlugIn for PlayOn">Video: Channel9 PlugIn for PlayOn</a>

 

Building a PlayOn PlugIn

The basic functionality of the PlayOn PlugIn is to retrieve a list of videos from some source and translate that list into objects understood by PlayOn. This includes representing some sort of folder structure to PlayOn and then providing the details of a video feed, including the video type (Flash or Windows Media).

There are a couple classes and interfaces provided by PlayOn that you’ll work with when building a PlugIn:

  • IPluginProvider – Primary interface you implement to define your PlugIn
  • IPluginProviderSettings – Interface to implement so your PlugIn shows up in the settings tab of PlayOn
  • IPlayOnHost – An object implementing this interface is provided to your PlugIn from the PlayOn application.
  • SharedMediaFolderInfo – Create a set of folder objects to represent your folder structure.
  • VideoResource – Create a set of video objects to represent video streams (PlayOn also defined audio and image resources)
  • Payload – Used to provide information back to the PlayOn host when it requests data from your PlugIn.

I think the easiest way to learn how to use the API is to look at existing PlugIns. There is a good basic sample PlugIn in C# provided by MediaMall that implements these objects. I’ve also provide the source code in both C# and VB for my Channel9 Plugin. You’ll notice that I did quite a bit of refactoring and I also included the Managed Extensibility Framework to make my development of the PlugIn a little more flexible and testable.

You start building your PlugIn by by implementing IPlugInProvider. PlayOn will initialize your PlugInProvider class when it starts and calls the method SetPlayOnHost. PlayOn passes in the IPlayOnHost that you can hold onto for using later. In this method, implement any initialization code that may require the context of IPlayOnHost.

During initialization, the Channel9 PlugIn creates an in-memory representation of a folder structure (see the NavigationBuilder class in my source code). The folder structure is not tied to anything  so it can look however you’d like and you can use it as a simple menu system for your PlugIn.

For example, there is no navigation (that I know of) on Channel9 for browsing thru personalities such as Bill Gates, Steve Ballmer, etc. But Channel9 does provide Tag searches with RSS feeds. So I’m able to provide several “folders” that represent those Tag searches.

Here’s the folder structure I used:

  • Main Feed – The main RSS feed on Channel9
  • Shows
    • 10-4
    • Continuum
    • The History of Microsoft
    • This Week on Channel 9
    • etc.
  • Media – Lets you browse by media type
    • Video
    • Podcasts
    • Screencasts
  • Technologies (Tag searches)
    • Windows 7
    • Windows Azure
    • Visual Studio
    • etc
  • People (Tag searches)
    • Bill Gates
    • Steve Ballmer
    • Ray Ozzie
    • Scott Guthrie
    • etc.

Interaction with PlayOn

ThisWeekOnChannel9.jpg

  1. After initializing the PlugIn, the PlayOn application will request the root folder using the GetSharedMedia method. To return a folder, add all of the subfolders and videos resources to a Payload object and return it to PlayOn. When the user selects a folder on their Xbox or Playstation, PlayOn will again call GetSharedMedia passing in the Id for that folder.
  2. Eventually you’ll need to load a list of videos from the source website when PlayOn requests a folder with videos. This is likely going to be an Atom, RSS or other XML feed. Otherwise, you’ll have to do a little screen scraping to get a list of videos. Again, add these items to a Payload object and return it to PlayOn.
  3. When the user selects a video to play, PlayOn will call GetSharedMedia with the Id of the video resource. This time, you’ll place a single video in the Payload object and return it.
  4. PlayOn will make one last call to the Resolve method which allows you to create a playlist for the requested video resource. Often this will be just the single video that the user wants to play. You could also combine videos or add advertisements to the stream.

Next Steps for the PlugIn

I’ll continue to add some functionality to the plugin and improve the code over time. I have several ideas to improve the PlugIn.

  • Add some other Microsoft developer oriented audio/video feeds such as Hanselminutes, DotNetRocks, etc. PlayOn is not yet supporting audio feeds yet, but it should be easy to add these once audio is supported.
  • Provide a means for sorting the items in a folder. The Xbox will resort the item list alphabetically, so I’d like to add a prefix scheme to the titles that isn’t annoying but provides control over the sort order.
  • Allow the user to customize the list of feeds using the PlayOn settings panel. This could include adding custom Tag searches.

For now, go download the plugin source code or the Windows Installer package from MSDN Code Gallery. Let me know if you have other suggestions.

Also you can review the PlayOn PlugIn documentation and participate in the unofficial PlayOn PlugIns forums.

Posted on Wednesday, April 29, 2009 11:11 PM | Back to top

Copyright © Drew Robbins | Powered by: GeeksWithBlogs.net