Video horizontal alignment in PlaylistItem with UniformToFill??

Nov 15, 2013 at 9:57 PM
Hi all!

May be I don's see smth obvious... but I can't set video horizontal alignment to center in UniformToFill streatch mode.

My video stream is 1280720 (playlistItem in UniformToFill stretch mode), my SMFPlayer has size 500500 pixels. In my player I see left part of the video image, but I want to see center part.

I've tried many ways to do it, but without any result:
  1. Changing HorizontalContentAlignment and VerticalAlignment to Center will give no effect.
  2. Moreover, in smfPLayer template there are PlayerRoot (Grid) with MediaPresenterElement (ContentControl). Changing all possiible alignments to Center gives no effect.
  3. I've found that there is SmoothStreamingMediaElement in MediaPresenterElement Content. Centering video in SmoothStreamingMediaElement is simple task with Templates (.. in Control Template I should set only HorizontalAlignment and VerticalAlignment to inner Media Element and video is centered).
    I try to assign appropriate template to this ContentControl's SmoothStreamingMediaElement:
            SmoothStreamingMediaElement mediaElem = MediaPresenterElement.Content as SmoothStreamingMediaElement;
            Style centerStyle = App.Current.Resources["SmoothStreamingMediaElementStyle1"] as Style;

            if (mediaElem != null && centerStyle != null)
                mediaElem.Style = centerStyle;
But get error in Browser: Unhandled Error in Silverlight Application
Code: 4004
Category: ManagedRuntimeError
Message: System.InvalidOperationException: Operation is not valid due to the current state of the object.
in Microsoft.Web.Media.SmoothStreaming.SmoothStreamingMediaElement.OnApplyTemplate()
in System.Windows.FrameworkElement.OnApplyTemplate(IntPtr nativeTarget)

If I assign this template without SMFPlayer for another SmoothStreamingMediaElement it works ine.

I can't see other ways to do it. Is it possible? If yes - could you help me?

Thanks a lot for reading.