MediaPlayerElement fullscreen button does not hide navigation bar

有些话、适合烂在心里 提交于 2019-12-11 07:11:57

问题


I added a MediaPlayerElement to my XAML as follow:

<MediaPlayerElement x:Name="EmbeddedPlayer" AreTransportControlsEnabled="True" HorizontalAlignment="Stretch">
     <MediaPlayerElement.TransportControls>
          <MediaTransportControls IsSkipBackwardButtonVisible="True" IsSkipBackwardEnabled="True" IsSkipForwardButtonVisible="True" IsSkipForwardEnabled="True"/>
      </MediaPlayerElement.TransportControls>
</MediaPlayerElement>

The problem is that the Fullscreen button provided by MediaTransportControls does NOT hide the navigation bar (the region containing the back, start and search buttons) on phone while I expect it to, just like the system "Movies & TV" app. It only hides the status bar!? (It works on desktop.)

Is there a secret code to allow the navigation bar to be hidden or is it just not possible with 3rd party app? I tried ApplicationView.TryEnterFullScreenMode in my MainPage on Windows 10 Mobile 14393.693 but just like above, the navigation bar is not hidden (only the status bar does).


回答1:


The "Movie & TV" app doesn't hide the navigation bar by default. The reason for why you see it hide the navigation bar by default is that the player is in full window model by default. Double tapped the player of "Movie & TV" app, the player will exit the full window mode and the bar will show.

So if you want have same effects like "Movie & TV" app, you need to set the IsFullWindow property of MediaPlayerElement like follows:

<MediaPlayerElement x:Name="EmbeddedPlayer" AreTransportControlsEnabled="True" HorizontalAlignment="Stretch"   IsDoubleTapEnabled="True" IsFullWindow="True" >
    <MediaPlayerElement.TransportControls>
        <MediaTransportControls />
    </MediaPlayerElement.TransportControls>
</MediaPlayerElement> 

Also you can define a DoubleTapped event for the MediaPlayerElement that double tap will exit the full window mode. Code as follows and now it has same effects as the "Movie & TV" done.

public MainPage()
{
    this.InitializeComponent();
    EmbeddedPlayer.Source = MediaSource.CreateFromUri(new Uri("ms-appx:///Assets/New2.mp4"));
    EmbeddedPlayer.DoubleTapped += EmbeddedPlayer_DoubleTapped; 
}

private void EmbeddedPlayer_DoubleTapped(object sender, DoubleTappedRoutedEventArgs e)
{
    var view = ApplicationView.GetForCurrentView();

    if (view.IsFullScreenMode)
        view.ExitFullScreenMode();
    else
        view.TryEnterFullScreenMode();
}



回答2:


After finding my answer for another problem on casting video to TV, I found out that one MUST NOT use the recommended MediaPlayerElement but the deprecated MediaElement for the navigation bar to be hidden properly.



来源:https://stackoverflow.com/questions/41644934/mediaplayerelement-fullscreen-button-does-not-hide-navigation-bar

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!