Media Center Edition Internet TV using Silverlight 1.1

http://www.brains-N-brawn.com/mceItvSilver 7/15/2007 casey chesnut



when Media Center first came out, there was no SDK for it, so 3rd party developers were SOL. if you check the MCE newsgroup, you'll find one of the very first posts was from me asking for an SDK. took a while, but then MCE added support for Hosted HTML applications. i can write web apps, but i dislike them, so i waited. then another MCE refresh introduced non-UI plugins ... that's when i started coding for MCE. the Vista MCE version adds 2 UI technologies to MCE : MCML and XBAP. MCML is a markup language targeted at creating MCE apps ... and it sucks.

on the other hand, XBAP rocks ... but has piss poor support from the MCE team. meaning it works, but there's been a # of times when the MCE team has said to ignore XBAP and just use MCML. some of the problems with XBAP in MCE include 1) haven't been able to hook the debugger since VS.NET 2005 SP1 on Vista ... no clue if the MCE team is going to fix this? 2) although XAML was designed to have remote rendering capabilities, there is no XAML renderer on the XBox 360, so the apps only render something like 5 fps over remote desktop. 3) the MediaElement is not hooked by MCE, so an XBAP will have to call PlayMedia() to work properly on an Extender. the moral of the story is i think MCML should die and MCE should adopt Silverlight as its UI framework for 3rd party developers. i.e. the MCE team should not be making UI frameworks, they should be working on APIs that target Media; and leave the UI development up to teams that focus entirely on presentation.

been preaching Silverlight to the MCE team ... and they dont want to hear it. so i decided to take a different approach and write a prototype Silverlight app for MCE. maybe the Silverlight team will see this and realize that MCE/XBox 360/MediaRoom integration would be a good thing and that we are going to need a Silverlight runtime on the XBox 360 and other v2 (Pika) extenders. ultimately, developers need to be able to write a single app that renders on MCE/360/MediaRoom ... without having to use Flash. this prototype app is real rough, but creates a simple app for viewing Internet TV streams within Media Center using Silverlight for its UI.


Silverlight 1.0 Beta / 1.1 Alpha

there are currently 2 early releases for Silverlight. a Silverlight 1.0 beta and a Silverlight 1.1 alpha. this is my 1st real look at Silverlight, so i went to install the 1.1 SDK. but the initial problem was it required Orcas ... which i don't want to install just yet. fell back to Silverlight 1.0, but that got ugly real quick. it doesnt have any UI controls nor does it have code-behind support. forget that, back to 1.1, which has the beginnings of controls and managed code support..


did some searching and found this blog post : Silverlight 1.1 with VS 2005. following that blog post, i was able to work with Silverlight 1.1 within VS 2005. the first step was to create the host HTML page (App.htm) and the javascript to create the Silverlight object tag (App.htm.js). the UI is simple (ItvPage.xaml), its just a ListBox for selecting a category/channel and a MediaElement to play the video stream. both the 1.1 Controls code and XAML is provided, just had to include those files in my project and make sure the XAML was included as an 'Embedded Resource'. first, the ListBox needs to be populated. OnLoaded (ItbPage.xaml.cs), the app makes an HttpRequest for an XML file (Streams.xml) which contains <Category name=""> and <Stream name="" url=""/> elements. it parses the Categories from the XML file and displays the available categories as items in the ListBox. since MCE remote control commands become keyboard presses, i added keyboard support. ends up you can only hook the KeyDown event on the root Canvas and not child controls. from the forums, it looks like this will change in later releases. the root Canvas hooks the KeyDown event and then passes the key press to the ListBox for selecting different items using the up and down arrow keys. speaking of Canvas, Silverlight is currently limited to that element for layout. i'm assuming that later versions will get more Layout options like StackPanel and Grid? now a user can select a category using the Enter key. when a category is selected, the ListBox is reloaded with the available Streams in that category. then a user can select a Stream to play that will hide the ListBox and show the MediaElement. it will also set the Source of the MediaElement to the streams Url and call Play(). the MediaElement has a MediaFailed event, but Silverlight doesnt have a MessageBox to show the error to the user. instead, you have to fire an event in managed code, that is hooked by javascript on the hosting HTML page, which will call javascript alert() to show the exception message. for that, i followed the pattern from this blog post : Calling Javascript from C#. there's a little more happening, but that's pretty much it. NOTE i wrote a different app to harvest MMS streams from an internet TV web site, which are used within this app.



it's hosted here : http://www.mperfect.net/mceItvSilver/App.htm. you will be prompted to install Silverlight 1.1 if necessary.

the Up/Down arrow keys are for navigating the ListBox. Enter/Space for selecting items in the ListBox. Escape/Backspace for navigating back.

you can try it out in MCE, by adding this MCL shortcut to MCE : mceItvSilver.mcl (remove the .txt extension)

NOTE there are many streams that will not play (a reliable test stream is 'News' - 'C-Span 1'). not sure why so many of these streams fail within Silverlight?


these are some of the problems i noticed about working with Silverlight in MCE


here is why we want Silverlight to be a UI model for MCE developers


this article describes how to create a basic Silverlight app for Media Center Edition. even though Silverlight 1.1 is Alpha, it's less painful to work with than MCML. weekend project, so i only worked on this for 2 days.



might revisit after Silverlight is refreshed


finally going to throw together a quick app for streaming DVDs to the 360. later