Monday, March 19, 2012

Silverlight tutorial: Play HD YouTube videos with Silverlight

You can play HD YouTube videos with Silverlight 3 easily. Basically, since Silverlight 3 supports H.264 format you can create your own media player and play high definition video content directly from YouTube in your Silverlight application. Let me show you how you can do it…

Getting started

1. First step is to get URL to the desired video in HD format. YouTube encodes every video in several different formats and for this tutorial I wanted to use HD MP4 format.

2. There are several different ways you can try to obtain URL for the HD video from YouTube. I’ve used the famous Greasemonkey Firefox add-in and YouTube HD Ultimate script. Basic idea is that this scrip will allow you to download YouTube videos in different formats, one of them being the HD MP4.

Okay, I have URL, what’s next?

3. So, by now you have some video URL or you can cheat and use this one:

(It’s Star Trek trailer – yeah I’m a Trekkie wannabe)

4. The rest is very simple – you can just set this URL as a Source for your MediaElement and when you hit F5 you should be able to see and enjoy some HD sweetness in Silverlight.

5. If you are hungry for some XAML code, then it’s here, for your reference:

<MediaElement HorizontalAlignment="Left"
VerticalAlignment="Top"
Source=""/>

Can it be better?

6. Sure it can – instead of using the MediaElement control, I would suggest you to try using the fully blow MediaPlayer control. You will have it under Assets pane in Expression Blend 3 (I assume you are using this one, right?).

Read more: UX Passion
QR: Inline image 1

Posted via email from Jasper-Net