Silverlight: Server-Side Playlists with Arvixe Hosting
Written by Andrew Ivanov Tuesday, 11 September 2012
For Silverlight, a server-side playlist (SSPL) is a sequence of media assets (either audio or video) that allows server administrators to control the sequence of media viewed by users. This playlist can be created statically or dynamically. A server-side playlist used to serve media to Silverlight can be used only for streaming (either on-demand or broadcast); it cannot be used to serve downloaded media. Silverlight uses .wsx configuration files to specify an SSPL that can be served to the client via the MediaElement object. Some advantages of using an SSPL include the following:
- Because the server seamlessly switches between the media files in a playlist, you can customize the viewer experience by combining multiple digital media files into what will appear to the end user to be a single content stream. This minimizes bandwidth spikes by decreasing the number of times that clients must connect to retrieve content.
- When users connect to a site before a live broadcast has started, you can provide media that plays in a loop while users wait for the live broadcast to begin.
- You can use the server object to specify dynamically what media files to stream. In other words, you can edit the playlist even while a client is viewing a stream identified by the playlist.
- You can gain additional control over playback of your media. For example, you can play only a portion of a media file, and you can specify a certain file to play if another file fails to load.
To use a server-side playlist in your Silverlight application, you must create a .wsx file on your server, publish it, and then connect your client (via MediaElement) to the published stream that represents the .wsx file.
A .wsx file is an XML file that defines what you want your playlist to contain and how it should behave. The following .wsx file example specifies three media files to be played, one after the other.
<media id=”video1″ src=”clip1.wmv” />
<media id=”video2″ src=”clip2.wmv” />
<media id=”video3″ src=”clip3.wmv” />
A variety of elements and attributes are supported by .wsx files to provide greater control over media playback than simply playing one video after the other. For example, you can use the clipBegin and clipEnd attributes to serve up a portion of a video. The following example shows how to specify a 15-second portion of a video file to be played.
<media id=”video1″ src=”clip1.wmv” clipBegin=”15s” clipEnd=”30s” />
To play media in your Silverlight-based application, reference your playlist file using a MediaElement. The .wsx file is used on Windows Media Services (WMS) as the source for the on-demand/broadcast publishing point. For example, if the .wsx file is sample_playlist.wsx and the publishing point is Server:8081/samplePlaylist, then the MediaElement definition would be something like the following.
Not All Media Supported. Only Windows Media container files (ASF/WMA/WMV) are supported.