Reasons to choose between MediaElement and SMF

Mar 3, 2012 at 6:41 AM


We have a MediaElement based palyer. We need to add more functionality like time scrubbing, subtitles, multiple audio tracks and it's shuffling, latency prrof operations (Smooth streaming is not a requirement), etc.

I am wondering if I should replace older MediaElement based player with SMF based one.

What could be complelling reasons I could put on table to get a positive nod?




Mar 8, 2012 at 12:33 PM


I've been using SMF for some time, instead of a custom built library on top of the raw Media Element.

SMF gets you a bunch of functionality for free, plugins, subtitles, handling of multiple tracks and such. It also has the advantage of being designated by Microsoft as the way to do it, so you can be pretty sure new Silverlight/Smooth Streaming releases will be tested to not break SMF.

I am rather happy with that choice.

- Loke

Mar 8, 2012 at 1:20 PM

Same as Loke above, I'm using it even when I don't need most of the functionality.

For me a slight downside is the size of the generated XAP, I've got a very very basic player at more than 800 KB, which might or might not matter, depending on target audience.

Mar 9, 2012 at 9:18 AM

Thanks for your's clear that SMF is the way to go.

However, currently SMF seems to support only URI/Stream based source.

MediaElement supports MediaStreamSource. Is there any way to convert this MediaStreamSource to any other source that SMF supports?



Mar 9, 2012 at 11:15 AM


You could probably implement that as a custom MediaPlugin

- Loke

Mar 9, 2012 at 11:37 AM


There is hardly any documentation around that topic.

I tried to create a customer MediaPlugin by adding another class implementing IMediaPlugin.

Struggling to integrate it with playlistitem. There are some additional properties that has become available now(Like MediaPluginRequiredMetaData). But end-to-end story is missing.

Is there any sample available on creating custom MediaPlugin and also using it in SMF Player?


Mar 13, 2012 at 3:45 PM


I dont think there is a sample for that plugin type yet. You are probably best of looking at the ProgressiveMediaPlugin

- Loke

Mar 15, 2012 at 7:09 AM


I have now added a MediaPlugin class (Looking at ProgressiveMediaPlugin).

This plugin seems to be getting called as it is hitting the Load() event in this class. I have added following code in this even -

if (MediaElement == null)
                MediaElement = new MediaElement();
                MediaElement.MediaOpened += MediaElement_MediaOpened;
                MediaElement.MediaFailed += MediaElement_MediaFailed;
                MediaElement.MediaEnded += MediaElement_MediaEnded;
                MediaElement.CurrentStateChanged += MediaElement_CurrentStateChanged;
                MediaElement.MarkerReached += MediaElement_MarkerReached;
                MediaElement.BufferingProgressChanged += MediaElement_BufferingProgressChanged;
                MediaElement.DownloadProgressChanged += MediaElement_DownloadProgressChanged;
                MediaElement.LogReady += MediaElement_LogReady;

Again, this is simply a copy of ProgressiveMediaPlugin.

Next challenge I am facing now is how to load this MediaPlugin.

Do I have to create another custom player class implementing SMF?

How do I now set the MediaStreamSource to SMF Player(My original requirement)?


Mar 15, 2012 at 9:01 AM

The plugin should be loaded by simply referencing it in your project.

For the MediaStreamSource it should be initialized in your plugin, as the source when the source is normally set.

- Loke

Mar 15, 2012 at 9:27 AM

You can make sure that your plugin is selected using some metadata.

For my own Media Plugin, I've added something like this:

public class ...

Then, when I create the PlaylistItem, I add this as required metadata:


Then it never fails to load *my* plugin instead of the default. Of course you have to properly set the SupportedDeliveryMethods attribute too.

Mar 16, 2012 at 11:18 AM


Ok...In My custom plugin, I added a custom property for MediaStreamSource
 private MediaStreamSource _mediastreamSource;
        public MediaStreamSource CustomMediaSS
                return _mediastreamSource;
                if (MediaElement != null)
                    _mediastreamSource = value;
My code behind is like this..
            OpenFileDialog objOpenFileDialog = new OpenFileDialog();
            bool? dialog = objOpenFileDialog.ShowDialog();
            if (dialog.Value)
                PlaylistItem playlistItem = new PlaylistItem();
                playlistItem.StreamSource = objOpenFileDialog.File.OpenRead();
                //playlistItem.MediaSource = 
                //    new Uri("https://XYZ/mediaServer/get?id=d9f8e53b-63dd-4abf-bb5d-9c7d04e749e4");
                playlistItem.Title = "Local media file";
                player.Playlist.Insert(0, playlistItem); //insert at beginning of existing playlist
                player.GoToPlaylistItem(playlistItem); //play the new playlistitem
My custom plug-in gets called which initialzes MediaElement internally.
But I want to pass the URI from codebehind. As can be seen I have commented MediaSource Proerty. I had tried it before but It fails to invoke property MediaStreamSource in the plugin.
How can I set MediaStreamSource custom property in mypugin from codebehind?
Aug 11, 2014 at 12:38 PM
just a guess, have found in other cases that MediaElement has to be added to the visual tree as a child, or to the app's resources in the XAML. So in this case, if the plugin is a visual object added to the visual tree by SMFPlayer, then it has to have the MediaElement it wraps in it as its own child