In this article, I am going to explain you about how to play (embed) WMV video file in ASP.NET using Silverlight Media Player. To use the SilverLight Media Player Control in ASP.NET, you will have to first download and install at least: Visual Studio 2008 Service Pack 1 and SilverLight 2.0 SDK.

Once all these have installed, you can start building your Media Player Application. You will have to drag the MediaPlayer component from the Toolbox as shown in figure below:

By default there are no skins available when you install the .SilverLight Tools you can get the skin files in the Program Files\Microsoft SDKs\Silverlight\v2.0\Libraries\Server\MediaPlayerSkin Folder. Just add the skins to your project using Add Existing Items in Visual Studio. Next, using the smart tag to choose the skin and add the Media File to be played:

You can also set other parameters like:

  • Volume - sets the volume of the Media Player Control
  • Auto-Play – determines whether the media file will be auto played or not when it is loaded.

Then, you can try to set the Media Source from code behind as shown below:

C#

protected void Page_Load(object sender, EventArgs e)
{

    MediaPlayer1.MediaSource = "~/files/Butterfly.wmv";
}


VB.Net

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        MediaPlayer1.MediaSource = "~/files/Butterfly.wmv"
End Sub

Once all these settings have been done, you can run the application. The figure below displays the SilverLight Media Player:

Now, you're done!