Microsoft Media Platform Player Framework, make video fullscreen from button press (or double clicking on video)

StackOverflow https://stackoverflow.com/questions/12718517

문제

I just started playing around with windows 8 development and I'm trying to figure out how to make a video whose source is from a url pop to full screen from either a button press or by double clicking on the area where the video is playing. Any idea on how to do that? As a followup, i'd also have to be able to minimize it back to it's normal playing window. Any ideas on how to do this using xaml C#?

reference: http://playerframework.codeplex.com/wikipage?title=Windows%208%20Metro%20Player:%20Install%20and%20configure%20-%20XAML/C

도움이 되었습니까?

해결책

The player framework has a boolean property called IsFullScreen to manage the fullscreen state. However, you need to do the work yourself to hide extra elements on the page and/or resize the mediaplayer. The recommended approach is to set this property and handle the IsFullScreenChanged event. For example:

<Grid Style="{StaticResource LayoutRootStyle}" x:Name="LayoutRoot">
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="Auto"/>
        <ColumnDefinition Width="*"/>
    </Grid.ColumnDefinitions>
    <Border x:Name="LeftPanel" Background="Red" Width="40"/>
    <mmppf:MediaPlayer x:Name="player" Grid.Column="1" IsFullScreenVisible="True" Source="http://smf.blob.core.windows.net/samples/videos/wildlife.mp4"/>
</Grid>

public MainPage()
{
    this.InitializeComponent();
    player.DoubleTapped += player_DoubleTapped;
    player.IsFullScreenChanged += player_IsFullScreenChanged;
}

void player_IsFullScreenChanged(object sender, RoutedPropertyChangedEventArgs<bool> e)
{
    LeftPanel.Visibility = e.NewValue ? Visibility.Collapsed : Visibility.Visible;
}

void player_DoubleTapped(object sender, DoubleTappedRoutedEventArgs e)
{
    player.IsFullScreen = !player.IsFullScreen;
}

Note: there is also a property on MediaPlayer call IsFullScreenVisible that you can set to true to show the fullscreen toggle button in the default control strip.

다른 팁

I used this code for fullWindow. It works but in full window it uses default transportcontrols

private void MediaPlayer_IsFullScreenChanged(object sender, Windows.UI.Xaml.RoutedPropertyChangedEventArgs<bool> e)
            {
                Microsoft.PlayerFramework.MediaPlayer mp = (sender as Microsoft.PlayerFramework.MediaPlayer);
                mp.IsFullWindow = !mp.IsFullWindow;
            }
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top