Skip to main content

Microsoft Silverlight

Unanswered Question FullScreen!RSS Feed

(1)

mseredynski
mseredynski

Member

Member

8 points

7 Posts

FullScreen!

Our current media player has an HTML button that, when clicked, puts the video in full-screen.  Or, we can capture the double-click event on that object, and do the same thing.

According to MSDN: "A Silverlight control can only enable full-screen mode in response to a set of user-initiated actions. These actions correspond to the MouseLeftButtonDown, MouseLeftButtonUp, KeyDown, and KeyUp events. If you try to set the FullScreen property to true in a Loaded event, the property setting is ignored. This condition on limiting the actions that enable full-screen mode ensures that the user is always the initiator of full-screen mode behavior."

So, we want to achieve the same behaviour in the Silverlight player that we're building; we want to have an HTML button that the user can click on, that should change the player to full-screen mode.

We cannot use XAML for this.  We're trying to create an entirely chrome-less Silverlight player at this point (the people that skin our players do not have the skills to be editing XAML yet!), that duplicates functionality of our existing Windows Media ActiveX control.  We fully intend to revisit XAML and use all the eye-candy; but not at this stage.

So; how?! 



 

nerddawg
nerddawg

Member

Member

516 points

123 Posts

Microsoft

Re: FullScreen!

Perhaps this will work: 

// your HTML button calls this Javascript function
function toggle_fullScreen()
{
    var silverlightControl = document.getElementById("SilverlightControl"); // assuming that is the name of your plug-in
    silverlightControl.content.fullScreen = !silverlightControl.content.fullScreen; 
  
}

// make sure this event is registered with the Silverlight plug-in when
// you instantiate it i.e. onFullScreenChange="myFullScreenChangedHandler"
// this function will get called when your Silverlight plug-in's full screen change
// event fires. Here you will ensure your media element has the relevant size
function myFullScreenChangedHandler(sender, args)
{
  
    var silverlightControl = sender.getHost();
    
    var mediaPlayer = sender.findName("media"); // assuming you have a media element in XAML with this name
    mediaPlayer.width = silverlightControl.content.actualWidth;
    mediaPlayer.height = silverlightControl.content.actualHeight;

}

There's a detailed example in the quickstarts: http://silverlight.net/quickstarts/silverlight10/media.aspx#fullscreen

Ashish Shetty | Program Manager | Microsoft
Blog: http://nerddawg.blogspot.com

mseredynski
mseredynski

Member

Member

8 points

7 Posts

Re: FullScreen!

That's not quite what we want to achieve.  What we are building is a UI-less media-player, controlled via HTML controls.  What you seem to be suggesting is "click something in the media-player that makes it change to full-screen, and then set the dimensions of your HTML element that the media-player sits in".

We explicitly cannot use XAML user-interface elements to support that kind of approach at this stage. Our XAML has to be as simple as having a Canvas and a MediaElement in it; nothing further.

What we might accomplish is our own double-click Silverlight event-handler, that triggers full-screen.  Fine.  We know how to do that (and, by the way, can we please have a more flexible set of Silverlight mouse-events[1]?).  What we need (unfortunately :( ) is to make that action controllable from the outside world, because our clients (and their viewers) are used to existing behaviour and features.

Also, we would like to be able to specify full-screen info message (Silverlight is using its own message), or even disable it for more seamless transition from users' experience point of view.

[1] More flexible mouse-events:

OnDoubleClick (where the interval is read from user system preferences, or some developer-settable config),

More properties to the EventArgs, for example IsContextMenuClick, AltIsDown, CtrlIsDown, ShiftIsDown (or did we fail to RTFM?)

deepak_gedia
deepak_g...

Member

Member

4 points

7 Posts

Re: Re: FullScreen!

we used this code using XAML but its goes to fullscreen mode and then on press ESC it wont is this is the code problem or the media problem becoz i have used the same code as written and if we gives the clip to media Element then the fullsvrin is not happening.. can u discribe how the actually fullscreen works.

thank,

Deepak

 

edmaia
edmaia

Member

Member

34 points

7 Posts

Re: FullScreen!

For security reasons, Silverlight only allows you to enter full-screen mode in response to some user input (mouse click or key press).  In the current implementation, Silverlight only knows whether user input happened if the input is given to the control directly.  I understand your scenario, but at this point your best bet is to use the double-click workaround you mention.

As far as changing the full-screen info message, the main reason it exists is again for the end-user's sake, to let them kow FS mode was entered and how they can exit if they wish.  We are looking at ways to improve the experience in future versions.

Finally, with respect to the DoubleClick and EventArgs, thanks for the feedback.  I will make sure this is tracked for future versions of Silverlight.

Ed Maia
Silverlight Developer

ramses0
ramses0

Member

Member

2 points

2 Posts

Re: FullScreen!

 FYI if you're still listening to this thread, we have a similar requirement, and have had to do the following:

 1 - Add single-click handler on media element to trigger fullscreen.

 2 - Add "requestFullScreen()" function (HTML) that shows three things

  a. Cover entire area with 50% opacity white rectangle

  b. Show animated click mouse cursor

  c. Show localizable text saying "Click Video for Full Screen" (with text shadow)

 ...all that crap basically does the same thing as clicking on the video (trigger fullscreen), but we too have a button outside of the media element.  :^)

Good luck!  MS, would it be possible to get some sort of page-level permission (a-la: allowScriptAccess) that removes the "click to go fullscreen" requirement?  It is quite challenging for streaming media implementors without going towards implementing a full silverlight player, often in addition to supporting Flash video playback.

 The other option would be to do something where you make the silverlight element "really large" with javascript, but still inside of browser chrome (kindof like what NBCOlympics.com did).

--Robert

ramana12
ramana12

Member

Member

13 points

19 Posts

Re: Re: FullScreen!

I am trying to DISABLE fullscreen option, when user double click on the video ?

How do I do that ?

Any help.... or hints ???

 

thanks in advance

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities