Which media element to use and Supported Video Stream Types

Jul 23, 2010 at 11:07 AM

Hi;

Hope this is an easy answer for someone...  I am wondering if this player will play mms feeds, isml Live Smooth Streaming, and ISM feeds (smooth Streaming)?  If it does, is it smart enough to know based on the URL in the playlist what media element to use or is there anything special I have to do.  You see, I can't get the player to work on different feeds so I am thinking there is something I am not doing.  Do I have to use SelectMediaPlugin method or will the playlistitem deliverymethod enumeration value enable the right player.  If there is anyone out there who can supply a bit of code or pseudocode or just a speal on how I accomplish making the player automagically play any stream no matter what protocol it uses.  I want to have my player support multiple types ofstreams based on the playlist item or some other value that I can set depending on what playlistitem the user picks.  Any and all help is appreciated and thanks in advance.

 

Cheers;

Brendon

Jul 23, 2010 at 12:29 PM
Edited Jul 23, 2010 at 12:31 PM
There is no auto-magic plugin selection yet based on the url. We had a discussion on this here http://smf.codeplex.com/Thread/View.aspx?ThreadId=218739

The PlayListItem.DeliveryMethod is where you want to go for now. The player does play MMS, ism and isml (my current project is using all 3). Streaming and ProgressiveDownload methods are handled by the Progress plugin. This one wraps a regular MediaElement and will handle MMS . AdaptiveStreaming is handled by the SmoothStreaming plugin.

I agree it would be nice to have it automatically select based on the url. You can override the SelectMediaPlugin method and use your own way. Here's the signature for it
protected virtual IMediaPlugin SelectMediaPlugin(PlaylistItem playlistItem)

So
public class CustomPlayer:SMFPlayer
{
   protected override IMediaPlugin SelectMediaPlugin(PlaylistItem playlistItem)
   {
      //use the playlist item info to select out of the plugins available in _pluginsManager.MediaPlugins

   }
}
Jul 23, 2010 at 1:40 PM

Hi darthobiwan;

Thank you very much for your quick reply...  I really do appreciate it and I would like to clarify this so please forgive me for what may amount to a dumb question.  I understand completely what you so kindly told me... however i want to question how I replace one media player with the other.  I have extended the SMFPlayer public class MYPlayer : SMFPlayer and used myplayer in XAML.  I am wondering how I implement the switch from one media element to the other...  for instance...  Just say I dynamically fill a playlist from a WCF webservice... (this is just an example)  I have set the PlayListItem.DeliveryMethod in each of my webservice returned playlistitems.  I can query the playlistitem to find out what kind of playlistitem it is and what type of stream it is or whatever I choose to put in.  My question is:  How exactly do I tell it which player element to use...  how do i code to replace the mediaelement it uses?  This is my last stumbling block I hope and I hope you can help. 

 

Thanks in advance;

Brendon

 

Jul 23, 2010 at 1:52 PM
When a new PlayListItem is selected in the player SMF calls the SelectMediaPlugin to figure out which media plugin to use for that item. The media plugins wrap the various media elements. Progressive wraps the standard MediaElement and SmoothStreaming wraps the SmoothStreamingMediaElement.

I would recommend looking in the source code for SMF and particularly at that SMFPlayer.SelectMediaPlugin method. SMF uses the Managed Extensibility Framework which supports exposing MetaData on classes without actually creating them. The _pluginsManager.MediaPlugins is actually a lazy loaded collection of metadata on the plugins. From there you can see what DeliveryMethods those plugins use.

Still if you are already setting the DeliveryMethod appropriately on the PlayListItems then you shouldn't have to override that method. It will auto select which plugin supports the method you specified on the item.

Another approach you could take if you still want to auto-select based on the extension of the video is to do it before creating the PlayList. You can do a switch on the DeliveryMethod based on it.

so if(url.Contains(".ism") || url.Contains(".isml"){ item.DeliveryMethod = DeliveryMethods.AdaptiveStreaming;}

Probably best would be to refactor it out into a method that returns the DeliveryMethod based on the Uri passed into it.
Jul 23, 2010 at 1:57 PM

Hi darthobiwan;

Perfect..  thank you very much!!!   That should be all I need to move forward again.  I appreciate your help.

All the best;

Brendon