locked
MediaElement fullscreen toggle

    Question

  • I want to replicate the isfullsceenwindows functionality of mediaelement but with overlays over the videoplayback. I want my costum controls and overlay so i can not use transportcontrols or set isfullscreenwindow. If i remove mediaelement from its parent and add it tot he roodgrid it losses buffer and state. How can i have fullscreen with overlays without losing buffer? I heard solutions that hide every element in the page except the medieelement but i don't think that solution fits me. I am building a videoplayer library and i don't know in advance in what layout is my player is going to be used.
    Friday, March 13, 2015 11:44 AM

All replies

  • Hello,

    Removing the MediaElement (ME) from the visual tree will immediately reset the control and you will lose your video source. This is by design as the ME is derived from UIElement. If I understand your question correctly you are trying to transition the ME from a sub control on the XAML page to full screen. Unfortunately XAML does not have a concept of full screen. Because of this you have to resize the ME to the dimensions of the screen to simulate full screen. If the ME is embedded in another control that can occlude the ME then resizing the ME control may cause it to be occluded by the parent control. In other words there is no way to easily cause the ME to appear full screen if it is occluded by it's parent. You can remove the ME from it's current parent and add it directly to the root of the visual tree (as you have already tried) and resync the source and position and restart playback. Another option is to use two ME. One bound to the occluding parent and one to the root of the visual tree. You can then keep the two MEs in sync and transition between them by showing and hiding the MEs as appropriate.

    I hope this helps,

    James 


    Windows SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/


    Friday, March 13, 2015 9:09 PM
    Moderator
  • thank you very much for your answer. How would i sync the two ME (and have only one to the buffering, that is what i am trying to do in the first place: remove unnecessary buffering.)? With the Binding keyword? like:

    <MediaElement Name:"FullsceenME" Source="{Binding ElementName=NormalMediaElement, Path=NormalMediaElement.Source}"/>

    Monday, March 16, 2015 9:57 AM
  • Hello,

    Syncing is easy via the position parameter. Unfortunately I don't believe that there is an easy way to "remove unnecessary buffering". Disconnecting and reconnecting to the media source will require data to be lost on disconnection and buffered on reconnection. The only solution I can come up with would require that you create a custom MediaStreamSource and share it between the two instances of the MediaElement. You could theoretically create a local file cache that could be used after reconnecting. In theory this should work but I've never talked with anyone who has tried it.

    I hope this helps,

    James


    Windows SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/

    Monday, March 16, 2015 10:22 PM
    Moderator
  • Hy.

    Creating a MediaStreamSource for every video format available on windows is gona be expensive and hard to maintain. I tried your ideea of having two mediaelelemnts. One was collapsed, one visible, and i set the binding of the source of one media element to the other. The media element that is collapsed stutters playback for 5~10 seconds before starting to play normaly when the visibility is toggled. it happens just on the first toggle. The following toggles have no effect on the playback

    Tuesday, March 17, 2015 8:44 AM