Tanmoy
Tanmoy

Reputation: 45662

Video page fullscreen in WP7

I have a WP7 application. It uses Pivot control. In one Pivot I have a Media element. I want to show the Video full-screen when user rotates the phone (From portrait to landscape mode) How to do it? By full-screen I mean only video will be shown in the complete page.

Upvotes: 1

Views: 1400

Answers (2)

Mubashar
Mubashar

Reputation: 12658

Following Code Works for me :)

private void PhoneApplicationPage_OrientationChanged(object sender, OrientationChangedEventArgs e)
    {
        if (e.Orientation == PageOrientation.Landscape || 
            e.Orientation == PageOrientation.LandscapeLeft ||
            e.Orientation == PageOrientation.LandscapeRight)
        {
            TitlePanel.Visibility = System.Windows.Visibility.Collapsed;

            mediaPlayer.Height = Double.NaN;
            mediaPlayer.Width = Double.NaN;

            mediaPlayer.VerticalAlignment = System.Windows.VerticalAlignment.Stretch;
            mediaPlayer.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;

            SystemTray.IsVisible = false;

        }
        else
        {
            TitlePanel.Visibility = System.Windows.Visibility.Visible;

            mediaPlayer.Height = 300;
            mediaPlayer.Width = Double.NaN;

            mediaPlayer.VerticalAlignment = System.Windows.VerticalAlignment.Top;
            mediaPlayer.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;

            SystemTray.IsVisible = true;
        }
    }

Upvotes: 4

Derek Lakin
Derek Lakin

Reputation: 16319

Use the VisualStateManager to define separate portrait and landscape states where the landscape state only has a MediaElement that is full screen. Handle the OrientationChanged event in your page, perform any checks you need to in order to verify that the state change should occur, then update the state accordingly.

Upvotes: 3

Related Questions