Dela via


How to enable full window video rendering

[ This article is for Windows 8.x and Windows Phone 8.x developers writing Windows Runtime apps. If you’re developing for Windows 10, see the latest documentation ]

Use MediaElement.IsFullWindow to enable and disable full window video rendering in a Windows Runtime app using C++, C#, or Visual Basic.

Roadmap: How does this topic relate to others? See:

What you need to know

Technologies

  • Windows Runtime

Prerequisites

Instructions

Step 1: Built in transport controls

Windows 8.1 introduces new built in transport controls for the MediaElement class. These controls have a full window button which toggles full window rendering on and off. To enable the built in transport controls, set AreTransportControlsEnabled to true.

Here is some code that creates a MediaElement with the built in transport controls enabled and the AutoPlay property set to false.

<MediaElement x:Name="mediaPlayer" 
              Source="Videos/video1.mp4" 
              Width="400" 
              AutoPlay="False"
              AreTransportControlsEnabled="True" />

Step 2: Programmatically set full window

Windows 8.1 introduces a new full window property on the MediaElement called IsFullWindow. Setting IsFullWindow enables and disables full window rendering.

When programmatically setting full window rendering in your app, you should always use the IsFullWindow instead of doing it manually. IsFullWindow insures that system level optimizations are performed which improve performance and battery life. If full window is not set up correctly, these optimizations may not be enabled.

Here is some code that creates an AppBarButton that toggles full window rendering.

<Page.BottomAppBar>
    <AppBar>
        <AppBarButton Icon="FullScreen" 
                      Label="Full Window"
                      Click="FullWindow_Click" />
    </AppBar>
</Page.BottomAppBar>
private void FullWindow_Click(object sender, object e)
{
    mediaPlayer.IsFullWindow = !media.IsFullWindow;
}

Roadmaps

Roadmap for Windows Runtime apps using C# and Visual Basic

Roadmap for Windows Runtime apps using C++

Designing UX for apps

Adding multimedia

Samples

XAML media playback sample

Media playback, start to finish

Tasks

Quickstart: video and audio

Quickstart: create a media player application

Reference

MediaElement

IsFullWindow

Other resources

Supported audio and video formats

Optimize media resources