[Silverlight] use the new mediaplayer control to play HD videos on YouTube

Source: Internet
Author: User

The premise of this article is that you have used silverlight3 (sl3) and installed expression encoder and expression blend3. If you have not installed encoder, you will not be able to use the mediaplayer control.

Sl3 already supports H.264. It is said that Sohu has used sl3 to develop HD applications, but the online address is not found yet :(

Let's talk about how to play YouTube's HD videos in the simplest way.

Here, the primary question is how to obtain the URLs of HD videos on YouTube. We can achieve this by using the Firefox plug-in greasemonkey and YouTube HD ultimate script. I believe it is not difficult to take care of you.

Here I get a URL for instructions and testing. The URL is as follows:

Http://www.youtube.com/get_video? Video_id = euwbiiiwcye & t = vjvqa1ppcfp0qthbkuhvzdm_uyxs8zusquz1jvlphyo = & FMt = 22

The next thing is very simple for those who are familiar with SL. Create a mediaelement control andSourceSet the property to the above address.

    <Canvas x:Name="canvas1">        <MediaElement Source="http://www.youtube.com/get_video? video_id=euwBiiiWcYE&t=vjVQa1PpcFP0qThbkuhvZDM_uyxS8zusQuz1JvlPhyo=&fmt=22"/>    </Canvas>

The use of mediaelement is so simple that when we decide to implement a video player, we must perform a considerable number of extensions on it. Because it neither has a playlist nor has the volume control, progress control, full screen, and other functions, it is definitely not a qualified video player.

So please have a grand debut of our protagonist mediaplayer control!

You can find it in the assets panel of blend3 and drag it to the canvas.

Mediaplayer looks like this.

Here, we only need to describe how to use the playlist. See the following XAML:

        <ExpressionMediaPlayer:MediaPlayer >            <ExpressionMediaPlayer:MediaPlayer.Playlist>                <ExpressionMediaPlayer:Playlist>                    <ExpressionMediaPlayer:Playlist.Items>                        <ExpressionMediaPlayer:PlaylistItemMediaSource="http://www.youtube.com/get_video?video_id=euwBiiiWcYE&amp;t=vjVQa1PpcFP0qThbkuhvZDM_uyxS8zusQuz1JvlPhyo=&amp;fmt=22"Title="Star Trek Trailer" VideoHeight="800" VideoWidth="600"/>                    </ExpressionMediaPlayer:Playlist.Items>                </ExpressionMediaPlayer:Playlist>            </ExpressionMediaPlayer:MediaPlayer.Playlist>        </ExpressionMediaPlayer:MediaPlayer>

You can add multiple playlistitem nodes to add the content of the playlist, which is easier to do in blend.

Is it cool? If you are a designer, you can right-click the mediaplayer control and choose "Edit template"> "edit a copy..." from the menu ..." To define a more niubility template for it.

OK. See you later ~

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.