Channel9 PlugIn for PlayOn

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.

Adding WPF Controls to the Visual Studio 2010 Start Page

Jason posted a great episode on our new 10-4 show on Channel9 that covers customizing the Visual Studio 2010 start page. The start page is defined in XAML (Markup language for Windows Presentation Foundation), so adding new tabs, buttons and other functionality is as easy as editing the XAML in Visual Studio or any text editor.

You can do even more than just edit the XAML. Because the start page is using XAML and Windows Presentation Foundation, you can also add your own WPF controls to the mix. Build your WPF control just as you would normally and place the assembly containing the control in C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\Components. For example, create a build status control that queries your build server for the status of the most recent build:

MyControlLibrary

Watch Jason’s 10-4 episode to learn how to copy the StartPage into your personal documents folder and edit the XAML file. To register your control, place a XAML namespace declaration at the top of the file:

New Picture

Then, add the control to the XAML at the location you want it to appear in the start page. In my case, this is simply adding the tag <my:MyBuildControl /> above the Welcome to Visual Studio 2010 CTP text. The start page will automatically reload in Visual Studio once your save the XAML file.

StartPage

Now you can add just about any functionality you’d like to make easily available within the Visual Studio start page. I’m really looking forward to the various customizations that developers come up with and share with the community.

One other note: When you copy the StartPage.xaml file into your documents directory, you’ll also notice a C# Project (.csproj) file. If you open the C# project file and then open the StartPage.xaml file from this project, the appropriate references will be set so that the StartPage shows up in the WPF designer. Once you add your custom control to the start page, you’ll need to add an assembly reference to this C# project file in order to continue using the WPF designer. Right click the project, select Add Reference and point it at your assembly in the Components directory I referenced above.

WPF designer

New Video Podcast Called 10-4

Our team just launched a new video podcast called 10-4 that will cover the new features in Visual Studio 2010 and the .NET Framework 4.0.

Episode 1: Downloading and Using the Visual Studio 2010 September CTP

For this first episode of 10-4, we’ll look at how to download and use the Virtual PC image of the Visual Studio 2010 September CTP. We’ll give you tips on how to download this massive (7GB+ compressed) VPC, show you how to get past some pesky expiration issues, and get you started with the CTP walkthroughs. Lastly we’ll cover where to get assistance and provide your feedback about this release.

In future episodes we’ll dive more deeply into the technical underpinnings of Visual Studio 2010 and the .NET Framework 4.0, but for this first episode we wanted to make sure everybody could get the CTP and follow along at home.

If you have ideas for the show or topics that you want covered, please let us know! We’ll be releasing one episode a week. You can provide your feedback in the comments of the show or email us at 10-4 at microsoft.com.