How to Create the ControllerContainerControl as its own UserControl and operate the SMFPlayer?

Apr 7, 2011 at 4:29 PM

Hi
I need to keep the ControllerContainerControl as it own UserControl outside of the SMFPlayer.  In effect I need to do 3 thrings

(1) Create a separate ControllerContainerControl  - I opened up in Blend and made the ControllerContainerControl as it own UserControl.  Other than spewing out a ton of XAML, the ControlStripContainer UserControl does show up nicely in the designer.
(2) Hide/Remove the ControllerContainerControl.  I am having the same issue as of this thread.  Trying to set the IsControlStripVisible to false has no impact.   Any suggestions?
(3) Hook up the events (both ways) from the ControllerContainerControl UserControl to operate on the SMFPlayer - Not sure how to go about doing this.

Any help is greatly appreciated.
rockmeister 

Apr 8, 2011 at 3:08 PM

2. You'll want to look at the "ControlStripStates" in the theme. By default the ControlStripNotVisible state does not do anything. The Visibility property is bound on the ControllerContainer but if it's not working (I personally haven't used it yet.. I normally only change the visibility in full screen mode with a custom mouseover state)

3. This is going to be very ugly, you will need to extend the SmfPlayer class and add a new TemplatePart, then override OnApplyTemplate and get a reference to that part. Then you will need to basically either map the parts within your user control to their counterparts SmfPlayer is expecting, then do their wireup events or you will need to add tons more code. I HIGHLY recommend going and looking at the source code of SMF, particularly the SMFPlayer.TemplateDefinition.cs file under Microsoft.SilverlightMediaFramework.Core\TemplateDefinitions\SmfPlayer\ . This is where all the different controls are wired up. The OnApplyTemplate() method is where all the magic happens. There are many parts of the SMFPlayer source that utilize the Protected fields set up in OnApplyTemplate. It does a good job handling them missing since everything basically is run through the IfNotNull<T>(Action<T>) extension method. But if you want them to actually function it will need them to be populated with the object. 

If you need to beyond that where your user control is hiding those elements (or replacing them with different types of elements) you will need to do some pretty extensive rewrite of parts of SMFPLayer.cs and SMFPlayer.TemplateDefinitions.cs

Apr 8, 2011 at 4:08 PM

Thanks for the pointers.  Much Appreciated.  I was hoping for a simpler way to accomplish.  C'est la vie.  I am going to be Mr. Mom for the next 7 days,  I will give it a shot the following weekend.
rockmeister

May 17, 2011 at 11:47 AM

Have a look at this post: http://blogs.microsoft.nl/blogs/ux/archive/2011/05/02/building-a-custom-video-player-with-the-player-framework-for-the-web-desktop-and-the-phone.aspx

It might describe what you need. In the session on Channel 9 I show how to change the ControllerContainer to show up dynamically for instance.

May 18, 2011 at 4:03 PM

Hi Tirion
I had actually looked at the video couple of weeks back when Mike Taulty blogged about it  "http://mtaulty.com/CommunityServer/blogs/mike_taultys_blog/archive/2011/05/06/customising-a-smurf-or-creating-a-custom-silverlight-media-player.aspx".  It was very helpful.  Thanks!.

Based on the video, I realized that all I need was to place my custom control on the PlayerRoot grid row 0 in order to make the custom control show up on top of the playing video.  I ended up extending the SMFPlayer and override OnApplyTemplate.  Please let me know if there is a better way to accomplish the same.

    public class SMFMediaPlayer : SMFPlayer
    {
        public SMFMediaPlayer()
            : base()
        {
        }

        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
            // My custom UserControl            
            EditorView editorView = new EditorView();
            Grid.SetRow(editorView, 0);
            PlayerRoot.Children.Add(editorView);
        }

    }

May 24, 2011 at 1:37 PM

Why not just add that control in the XAML of the template? I prefer doing as much as possible without code :)

Martin