HP Discover 2011 Vienna

How to play MPEG video via Silverlight 3

Microsoft Silverlight is a programmable web browser plug-in that enables features such as animation, vector graphics and audio-video playback which characterize rich Internet applications. Version 2.0, released in October 2008, brought additional interactivity features and support for .NET languages and development tools. Microsoft made the beta of Silverlight 3.0 available on March 18, 2009. The final version is expected to arrive on July 10, 2009.

windowslivewriter_silverlight3sisi3_12161_microsoft_silverlight_c_2

It is compatible with multiple web browser products used on Microsoft Windows and Mac OS X operating systems. Mobile devices, starting with Windows Mobile 6 and Symbian (Series 60) phones, probably will be supported in 2010. A third-party free software implementation named Moonlight is under development to bring compatible functionality to Linux.

Today , MPEG video support for Silverlight 3 is here.It is difficult to implement but you can make it easily through this article.

I am developing Silverlight 3 solutions ; you can use Visual studio 2008 or Expression Blends.But here I am going to use Expression blends because it provides such tools to develop the XAML code you need to for Silverlight solution.Expression Blends is specifically designed with respect to designing purpose.You can download the version of Expression Blends (Blends 3 Preview release) from the Microsoft Expression Blends Official site , here you will find more things related to Microsoft Expression Blends.

image1

Items you will will need to play back an MPEG-4 video in Silverlight are following :

  • A MPEG-4 video (the file extension will be .MP4).
  • Silverlight 3 Player(Latest player can be downloaded from http://silverlight.net ).
  • For instance, there have been two beta versions of the Silverlight 3 Player released. Only the second version will allow you to play back MPEG-4 video.

Now , I am going to start , following are the steps:

Step 1

First you have to do is to create a new a project from the File menu

ssdsdsdsddYou can choose to use either C# or VB.NET as your development language. Silverlight does also support JavaScript and other scripting languages.

Step 2

Blends will now create the files needed for a basic, empty project. You will see in the Projects explorer two sets of files. The progmic files refer to the development files you are working on; the progmicSite  files refer to the built files that will be used to publish your final project.

image3

Step 3

Now you have to add a MPEG4 video file. To do this, right click on the progmic folder and choose “Add Existing Item.”

ssss

Selecting this command will allow you to search your hard drive for an MP4 file. The file will be automatically added to your project.

image5 You are now set to add the XAML code that will allow you to link to this file.

Step 4 : Working with XAML

Silverlight leverages the XML language called XAML to control the layout of objects on the screen. If you are familiar with HTML so you will not find difficulty to work with it.Well here you can able to choose to edit directly in XAML.

Paste the following XAML code into the code pane:

<UserControl
xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation
xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml
x:Class=”MPEG_Video.MainControl”
Width=”640″ Height=”480″>

<Grid x:Name=”LayoutRoot” Background=”White”>
<MediaElement AutoPlay=”True” x:Name=”MPEG_video” Source=”sample.mp4″ Stretch=”Fill” Margin=”0,0,0,0″/>
</Grid>
</UserControl>

The play back of the MPEG-4 video file is controls by the MediaElement.Now you have to build your project and view the video playing back in your Web page through Silverlight.Expect the support for MPEG-4 and video in general to increase in Silverlight as it competes directly with Adobe’s Flash.

Source

Related Posts

View Comments

  1. April says:

    Pretty cool post. I just stumbled upon your site and wanted to say
    that I have really liked browsing your blog posts. Anyway
    I’ll be subscribing to your blog and I hope you post again soon!

  2. well thanks for appreciating our work..we are working with more energy as we slow our speed due to our exams , but now we are here to tell you girls and guys about the technology world. Again thanks a lot

  3. Jamal Fiscel says:

    Hey, I found this blog post while looking for help with Microsoft Silverlight. I have recently changed browsers from Safari to Microsoft IE 6. After the change I seem to have a problem with loading sites that use Microsoft Silverlight. Every time I go on a website that needs Microsoft Silverlight, the page crashes and I get a “npctrl.dll” error. I cannot seem to find out how to fix it. Any help getting Microsoft Silverlight to work is greatly appreciated! Thanks

  4. thanks for the reply.you can use internet explorer 8 download it and then u will not face this problem.thanks again

  5. cool good website yea nice work our review blog will soon be adding reviews on blogs and add them to our websites as the top best 100 websites to visit we also do reviews on product recalls all types of reviews we will get back to you

  6. Great article thx a lot!

Leave a Reply

blog comments powered by Disqus