In this article I am explaining 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

1. Visual Studio 2008 Service Pack 1

2. 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.

Silverlight MediaPlayer in the Visual Studion 2008 toolbox

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

Smart Tag to edit properties of SilverLight Media Player

You can also set other parameters like the

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.

 

You can also 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 run the application. The figure below displays the SilverLight Media Player.

SilverLight MediaPlayer playing a Windows Media Video (WMV) File

With this we finish the article. You can download the sample source code using the link below.

Demo
 
Downloads