c# - How to change mediaelement to scale in portrait and fullscreen in landscape mode on Windows Phone 8.1? -


i having difficulty trying change <mediaelement /> fullscreen automatically when phone rotated in landscape mode. right now, video play fullscreen when tap lower right button scales full screen when tap on it, don't want that. in portrait mode, trying make <mediaelement /> fit according width of phone's screen , i'm not sure how or i'm doing wrong layout issues.

here's layout have in xaml:

mainpage.xaml:

<grid>     <grid.columndefinitions>         <columndefinition width="*" />     </grid.columndefinitions>     <grid.rowdefinitions>         <rowdefinition height="*" />         <rowdefinition height="auto" />     </grid.rowdefinitions>     <stackpanel width="auto" height="250" background="green" orientation="horizontal" verticalalignment="top">         <mediaelement x:name="media"                   source="http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4"                   autoplay="true"                   aretransportcontrolsenabled="true"                   horizontalalignment="center"                    verticalalignment="top"                    stretch="uniformtofill"                   width="auto"                   height="auto"                       />     </stackpanel> </grid> 

updated code orientation changes:

i debugged method , go through if statement when phone in landscape mode, when tilt phone in portrait, doesn't recognize anything. missing recognize portrait event handler when phone put portrait? mediaelement seems stuck in isfullwindow = true , never checks again orientationchanged event method become isfullwindow = false.

void mainpage_orientationchanged(displayinformation sender, object args) {     var orientation = displayinformation.getforcurrentview().currentorientation; // current orientation of display     if (orientation == displayorientations.landscape || orientation == displayorientations.landscapeflipped) // if orientation landscape...     {         media.isfullwindow = true; // puts media element in full screen while in landscape     }     else //if (orientation == displayorientations.portrait || orientation == displayorientations.portraitflipped)     {         media.isfullwindow = false; // puts media element out of full screen in portrait         //media.width = window.current.bounds.width; // set bounds of video width width of screen     } } 

a simple fix set isfullwindow="true" in media element property in xaml media element play in full screen no matter orientation.(though going in landscape mode). can set media element property isfullwindow true using c# per requirement


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

Kivy: Swiping (Carousel & ScreenManager) -