Enhancing Media Experience in Silverlight with Microsoft Media Platform (MMPPF)



When Silverlight was introduced it was merely considered a Player Framework because of its capability to handle Rich media. This is one of the first technologies to handle true 720p and 1080p HD media. Since its evolution, Silverlight 1 to Silverlight 5 the digital media experience improved a lot. So this article we will take a dig into media concepts and its integration with Silverlight along with various options available.

This article will focus extensively on the Microsoft Media Platform Player Framework (MMPPF) from Microsoft , an open source player framework and it's implementation.

image

Media ,Streaming, Silverlight .......Journey So far

Silverlight 1 introduced the MediaElement object to enable rich media experience. MediaElement is a control region which enables rendering of audio as well video files. It supports Windows Media Video (WMV), Windows Media Audio (WMA), and MP3 files/ Containers. A detailed list of the formats and protocols supported, can be found with this link Supported Media Formats, Protocols, and Log Fields. The Media element object supports Downloading and Streaming of media content to the client side over HTTP. Other than these specified container types the Silverlight provides an option for MediaStreamSource, which enables you to deliver media that doesn't come under the supported container type.

Other than format another important aspect of Media rendering is, how the content is going to be delivered to the client. This is what is called the delivery method. There are various methods for content delivery such as Streaming, Progressive Download, Smooth Streaming etc etc .The MediaElement decides the delivery method based on file format type and the URI .

The Default delivery behaviour of mediaElement is progressive download. If you use the MediaElement with an URL that starts with http: or https:, Silverlight begins a progressive download. If you use the MediaElement with a URL that starts with mms:, Silverlight attempts to stream it, and falls back on a progressive download if streaming fails. Make a note that mediaElement doesn't support Smooth Streaming.

Before going forward let's have a quick look into various delivery methods and their comparisons.

Progressive Download Streaming (Traditional) Smooth Streaming or Adaptive Streaming
Simple HTTP download of files HTTP based yet stateful (Not exactly HTTP but a modified version of HTTP) Hybrid combination of HTTP streaming with file chunk download
Download a file chunks to client system and user have access to the content downloaded Media sent as a series of packet to client Media source is divided into many short segments and encoded .Chunks downloaded to client and played in linear sequence.
Doesn't consider the client environment Can have multiple versions of file and based client environment can decide which version to send Depending upon CPU and bandwidth usage changes the streaming quality level
User can navigate between the downloaded portion User can seek forward/backward of track Smooth seeking
Longer Initial Time for playback than Streaming Fast Start-up , No buffering ,

If you want to explore in detail the above topics, have a look into the whitepaper published at Microsoft portal.

In the age of live streaming and on demand video the the smooth Streaming comes to rescue which delivers the best on a given network and client environment. So this leads to Microsoft Media Platform based player which makes it possible at client side to recognize the source content and enable smooth streaming.

Microsoft Media Platform: Player Framework 2.5

MicrosoftMediaPlatform (MMPPF) is an open source project from Microsoft that supports media plugins such as Smooth Streaming, Progressive Download and Windows Media streaming,.

image

Is this sufficient to use MMPPF? Why does anyone use the framework and what are the benefits it offers??. The list below shows some of it's profound features in the current version 2.5 that are worth a descrpition:

  • Support for Windows Phone as well as Silverlight
  • Media Plugins based on your choice (Smooth Streaming/Progressive Download /WMS)
  • Slow Motion
  • Playline Marker
  • Customization and Branding
  • Logging
  • Advertisement Support
  • Extensibility with Plugin
  • Streaming Graph Overlay

A more detailed description of the feature list can be found Here .

IIS Smooth Streaming

Make a note that the regular Streaming, Progressive Download is the default and requires a minimum of extra effort. Smooth streaming requires the files to be stored as chunks of different bit rate so that it can be streamed smoothly to the client. Here the client choose which bitrate chunk to be downloaded based on client environment.

Sometimes however managing so many chunks of files can be a difficult task at server so IIS Smooth streaming comes into picture.With IIS Smooth Streaming, file chunks are created virtually upon client request, but the actual video is stored on disk as a single full-length file per encoded bit rate. This offers tremendous file-management benefits.

But for IIS smooth streaming, the IIS server needs to be adequately configured and the video file needs to be encoded. There are many server / CDNs available which offer a smooth streaming service, however if you want to configure your server to support smooth streaming then refer to this article.

Player download and Codeplex Source

Before jumping to a sample application let me share with you the download link and project hosted at codeplex. It comes as a MSI package which can be installed. Basically it is a set of dlls which can be referred to in the project based on requirements.

Download Installation – : http://smf.codeplex.com/releases/view/63434#DownloadId=222617

Project on Codeplex –:http://smf.codeplex.com/

Creating a simple Media Player Project

SETTING UP THE PROJECT

Either you can download the binaries or else the complete MSI package which will add MMPPF template to the project window. Once you download the binaries as mentioned above you find a set of assemblies which can be used based on scenarios. But for a very basic application we need to add the following assemblies into the project:

SNAGHTML5a119e

Once you drag and drop the Microsoft.SilverlightMediaFramework.Core.dll to the toolbox, the SMFPlayer control allows you to use the control directly over the page. (As the project was previously called as Silverlight Media Player (SMF) don't bother about the control name).

image

On use of this control VS will include the xmlns:smf=http://schemas.microsoft.com/smf/2010/xaml/player namespace .

1
2
3
<Grid x:Name="LayoutRoot" Background="White">
<smf:SMFPlayer HorizontalAlignment="Stretch" Margin="0" Name="sMFPlayer" VerticalAlignment="Stretch" />
</Grid>
QUICK PLAYING MEDIA SOURCE

PlayList and PlayListItem are the basics of MMPPF. PlayListItem indicates the Media source object which is going to be added to the Playlist collection of media. Each individual playItem has the option to choose its mode of delivery to the client. The following source shows creation of a Playlist item from a media source.

1
2
3
4
5
6
7
8
9
//Create a new PlayList Item
PlaylistItem item=new PlaylistItem();
item.DeliveryMethod = Microsoft.SilverlightMediaFramework.Plugins.Primitives.DeliveryMethods.Streaming;
//Add PlaylistItem to the Media playlist
sMFPlayer.Playlist.Add(item);
sMFPlayer.Play();

Due to security reasons or whatever it does not support relative source to the playlist instead you can use an absolute Uri path for the media item. In the same manner that a video Uri is supported an Audio playback is supported.

PLAYING A SMOOTH STREAMING

As I mentioned, an IIS based smooth streaming needs the server to be configured and for demonstration I am going to use the sample media source hosted over playready.directtaps.net. The smooth streaming media source comes as .ism extension. Well direct use of this extension will not allow you to play the media. Instead you have to use the complete link including "/Manifest". This manifest files define the relationships between the media tracks, bit rates and files at server.

SNAGHTML61cb1d

1
2
3
4
5
6
7
PlaylistItem item = new PlaylistItem();
item.ThumbSource = new Uri(thumbImgUri);
item.DeliveryMethod = Microsoft.SilverlightMediaFramework.Plugins.Primitives.DeliveryMethods.AdaptiveStreaming;
//Add PlaylistItem to the Media playlist
sMFPlayer.Playlist.Add(item);

Have a look at the difference between Progressive download and IIS smooth streaming at live link provided at the end of the article.

image

Embedding the Media Player to WordPress or Non Silverlight Site

Embedding the smooth streaming media player needs the XAP file which can be downloaded from here. Include the XAP file within the root directory of your hosting provider and in the new wordpress post switch to HTML view where you can use following code .

1
2
3
4
5
6
7
<object data="data:application/x-silverlight-2," height="100%" type="application/x-silverlight-2" width="100%">
<param name="source" value="SmoothStreamingPlayer.xap" />
<param name="minRuntimeVersion" value="4.0.50401.0" />
<param name="autoUpgrade" value="true" />
</object>

Since the above example is for smooth streaming it supports only ism file, media source that only support IIS 7 smooth streaming. In case you want to host your own media URL then it needs progressive media player which can be downloaded here.

Sample Embedded player (Smooth Streaming ) demonstration Link- : Embedded Player

Final Words

The Media player framework offers many features which I have hardly touched on, such as Logging, Analytics and Plugin .MMPPF is quite promising and one stop solution for all media rendering activities. Hope this article will give you a complete picture of Media handling capability that Silverlight does offer. Please feel free to post your views and comments.

Live Link and source code

Live Link -:http://manaspatnaik.com/app/MSMediaPlayerFrameworkTestPage.html

Source Code –: MSMediaPlayerFramework.zip

Additional Links and Reading

Beginners Guide on Media Technologies -http://msdn.microsoft.com/en-us/library/ms867173.aspx

Smooth Streaming Assets –:http://playready.directtaps.net/smoothstreaming/

Customizing MMPPF –:http://channel9.msdn.com/Events/DevDays/DevDays-2011-Netherlands/Devdays009


Similar Articles