Explain how can Silverlight use ASX files - Silverlight

Explain how can Silverlight use ASX files.

An ASX file is an XML file in which media files are specified in the playlist. Using ASX files in silver is pretty simple. Assign the ‘ source’ property of a MediaElement object to the ASX file name.

The following is an example of ASX file.
<ASX version = "3.0">
<TITLE>MyFirst ASX Application</TITLE>
<ENTRY>
<TITLE>MyVideo</TITLE>
<AUTHOR>MyName</AUTHOR>
<COPYRIGHT>(c)2010 A company name</COPYRIGHT>
<REF HREF = "xbox.wmv" />
</ENTRY>
</ASX>


Later this .asx file need to assigned to the ‘Source’ property of MediaElement in XAML file.
<MediaElement>
.
.
Source=”myasxfile.asx”
.
</MediaElement>

Finally, add event handlers for supporting the MediaElement. The following functions are used for stopping, pausing and playing events on CurrentStateChanged event.
function media_stop(sender, args)
{
   sender.findName("MediaPlayer").stop();
}

function media_pause(sender, args)
{
   sender.findName("MediaPlayer").pause();
}

function media_begin(sender, args)
{
   player = sender.findName("MediaPlayer");
   player.play();
}

function media_state_changed(sender, args)
{
   // Obtain the text block for displaying the status var mediaStateTextBlock = sender.findName("mediaStateTextBlock");
   // Obtain the media state object
   var media = sender.findName("MediaPlayer");
   mediaStateTextBlock.Text = media.CurrentState;
}
Silverlight application life-cycle
Silverlight application life-cycle - The entry point of Silverlight applications is Silverlight Application class. It provides various services which is commonly needed by Silverlight application...
Role of Silverlight Plugin in the Silverlight Application
The Silverlight plug-in loads the core services of Silverlight followed by Silverlight Common Language Runtime. CLR creates domains for applications...
Purpose of Storyboard.TargetProperty - Silverlight
Using Storyboard.TargetProperty, the properties of an object can be assigned with values. The objects are referred by Storyboard.TargetName attribute. The following snippet illustrates the change of width and color of a rectangle object...
Post your comment