Skip to main content

Microsoft Silverlight

Answered Question Full screen silverlight 2 PlayerRSS Feed

(0)

Frank87
Frank87

Member

Member

5 points

59 Posts

Full screen silverlight 2 Player

I have a player within a silverlight 2 web application. I need to set the player to fullscreen, but there are no properties that do that. How can I do it ??

davidezordan
davidezo...

Contributor

Contributor

5684 points

872 Posts

Silverlight MVP

Re: Full screen silverlight 2 Player

Hi,

check out this code:

http://www.shinedraw.com/animation-effect/silverlight-vs-flash-switching-to-full-screen/

Thanks, Davide

Silverlight MVP

Blog Twitter Silverlight Experts

Frank87
Frank87

Member

Member

5 points

59 Posts

Re: Re: Full screen silverlight 2 Player

 I've tried to use that code, but my application crashes if I use it...

MoHassan
MoHassan

Member

Member

467 points

149 Posts

Re: Re: Full screen silverlight 2 Player

Hello,

You can't set silverlight control to fullscreen automatically, you need a user generated event like button. 

First create button and react to the click event handler using the code below.

private void FullButtonClick(object sender, RoutedEventArgs e)

{

App.Current.Host.Content.IsFullScreen = !Application.Current.Host.Content.IsFullScreen;

}

Good luck

Hassan

Frank87
Frank87

Member

Member

5 points

59 Posts

Re: Re: Re: Full screen silverlight 2 Player

 My code is exactly like yours, but it doesn't work...

at this line:

 

 private void FullScreen_Click(object sender, RoutedEventArgs e)
        {
            Application.Current.Host.Content.IsFullScreen = !Application.Current.Host.Content.IsFullScreen;
        }
 

my application crashes, and I have to end it with task manager, because it doesn't respond...

MoHassan
MoHassan

Member

Member

467 points

149 Posts

Re: Re: Re: Full screen silverlight 2 Player

Hello,

Paste you code here both the XMAL and the code behind for this event, I will try to regenerate on my machine.

 

Good luck

Hassan

Frank87
Frank87

Member

Member

5 points

59 Posts

Re: Re: Re: Full screen silverlight 2 Player

 The button that generates the fullscreen is this:

(xaml)

<Button Height="39" HorizontalAlignment="Right" Margin="0,0,350,187" VerticalAlignment="Bottom" Width="45" Content="Button" x:Name="FullScreen" Template="{StaticResource ButtonControlTemplate6}" Click="FullScreen_Click"/>

 

 (page.xaml.cs)

 

 

private void FullScreen_Click(object sender, RoutedEventArgs e)
        {            
            Application.Current.Host.Content.IsFullScreen = !Application.Current.Host.Content.IsFullScreen;
        }

  

 in the Content_FullScreenChanged there is this:

  

void Content_FullScreenChanged(object sender, EventArgs e)
        {
            double screenWidth = Application.Current.Host.Content.ActualWidth;
            double screenHeight = Application.Current.Host.Content.ActualHeight;           
        }

 

Once I click on the button, my application crashes...

Frank87
Frank87

Member

Member

5 points

59 Posts

Re: Re: Re: Re: Full screen silverlight 2 Player

 Now it works, I don't know why, because I haven't made any change...

 however, this code sets the fullscreen of the application, not the fullscreen of the player, so I've changed the width and the height of the player, and also the alignment(in the button), but it changed only the width and height, not the alignment...

how can I do to set the player in fullscreen ??

MoHassan
MoHassan

Member

Member

467 points

149 Posts

Answered Question

Re: Re: Re: Re: Full screen silverlight 2 Player

void Content_FullScreenChanged(object sender, EventArgs e)

{

if (App.Current.Host.Content.IsFullScreen)

{

//Set everything you that need to be set here like the content of the button, the width and the height of the player and Collapse all the controls you do not want to see.

this.Width = App.Current.Host.Content.ActualWidth;this.Height = App.Current.Host.Content.ActualHeight;

FullScButton.Content = "Exit Full Screen";

}

else

{

//reset everything to the original size and reverse everything you did.

this.Width = 800; this.Height = 900;

FullScButton.Content = "Full Screen";

}

}

 

Good luck

Hassan

Frank87
Frank87

Member

Member

5 points

59 Posts

Re: Re: Re: Re: Re: Full screen silverlight 2 Player

 Thank you Hassan !! now it works

 

I have another question: my media element has 2 bars, one on the top and one on the bottom of the player. Is there any way to eliminate them ?

 

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities