Jump to content


Photo

Impossible to access fullscreen in HTML5


  • Please log in to reply
8 replies to this topic

#1 alexandervrs

alexandervrs

    GMC Member

  • GMC Member
  • 423 posts
  • Version:GM:Studio

Posted 26 June 2012 - 04:50 PM

A little while ago I created an extension to launch a HTML5 game in true fullscreen using the browser's Fullscreen API.
GameMaker's window_set_fullscreen() is not doing "true" fullscreen but rather fills the browser window leaving the browser chrome still in the view.
The F10 fullscreen is doing the job well however it has not an option to keep aspect ratio. Furthermore, I might need fullscreen to be launched from another key press or mouse click from e.g. an options screen and not from the F10 key.

My extension allows to keep aspect ratio properly and can be called from any key or mouse click. However when used as an extension from within GameMaker, it seems the game overrides my calls somehow and uses window_set_fullscreen() or so it seems. I never got a clear answer as to what causes this.
Why can't I access the Fullscreen API with my extension? Why does GM interfere?

You can try a fullscreen example here. (Uses the same codebase as the extension) So you can see aspect ratio and calling through keys and mouse events is possible.
You can download a gmz to see the problem here. Press Space to try and go Fullscreen and Escape to exit.

Edited by alexandervrs, 26 June 2012 - 04:53 PM.

  • 0

#2 Lune

Lune

    hic quoque transibit

  • GMC Member
  • 526 posts
  • Version:GM:Studio

Posted 26 June 2012 - 07:10 PM

I'm pretty sure true fullscreen is something that only the user can make happen via the browser. I don't know about you, but I don't want apps taking my screen without permission, and that would be all too easy if they could go fullscreen automatically.

EDIT: Never mind. Apparently it is possible. I don't know that I like that. Sorry I don't have an answer.

Edited by Lune, 26 June 2012 - 07:11 PM.

  • 0

#3 alexandervrs

alexandervrs

    GMC Member

  • GMC Member
  • 423 posts
  • Version:GM:Studio

Posted 26 June 2012 - 07:17 PM

I'm pretty sure true fullscreen is something that only the user can make happen via the browser. I don't know about you, but I don't want apps taking my screen without permission, and that would be all too easy if they could go fullscreen automatically.

EDIT: Never mind. Apparently it is possible. I don't know that I like that. Sorry I don't have an answer.


Yes the Fullscreen feature is a new proposal to the W3C, it currently works for webkit-based browsers (Chrome, Safari 5.1) and Firefox. Initially intended for video but you can now "full-view" any specific elements you want.
Although the user needs to initiate fullscreen himself by either clicking with the mouse or pressing a keyboard key, you cannot automatically start fullscreen without the user taking action. :)

Edited by alexandervrs, 27 June 2012 - 06:08 PM.

  • 0

#4 Mike.Dailly

Mike.Dailly

    Evil YoYo Games Employee

  • Administrators
  • 1503 posts
  • Version:GM:Studio

Posted 28 June 2012 - 11:57 AM

Okay, yes you can CALL fullscreen, but it'll only fill the browser. However, if you press F10, it will GO fullscreen.

This is because the spec for fullscreen mode on HTML5 requires user input, and the request to go fullscreen must come from "inside" that event - directly. You can't fake it, or throw it yourself.
This means we "could" "remember" you wanted to go fullscreen and only do so when a user presses a button or key, but I don't like that as it's a delayed reaction, and would be a terrible user experience.

So, if you want to go fullscreen, you'll need to tell them (in the game, or on the web page) to press F10. This doesn't work in IE (surprise surprise) as they haven't implemented this spec.

So this is by design... sorry. Not much we can do about it.
  • 0

#5 alexandervrs

alexandervrs

    GMC Member

  • GMC Member
  • 423 posts
  • Version:GM:Studio

Posted 28 June 2012 - 12:24 PM

Okay, yes you can CALL fullscreen, but it'll only fill the browser. However, if you press F10, it will GO fullscreen.

This is because the spec for fullscreen mode on HTML5 requires user input, and the request to go fullscreen must come from "inside" that event - directly. You can't fake it, or throw it yourself.
This means we "could" "remember" you wanted to go fullscreen and only do so when a user presses a button or key, but I don't like that as it's a delayed reaction, and would be a terrible user experience.

So, if you want to go fullscreen, you'll need to tell them (in the game, or on the web page) to press F10. This doesn't work in IE (surprise surprise) as they haven't implemented this spec.

So this is by design... sorry. Not much we can do about it.

I don't understand this at all, sorry. If you see in my example, I've used a keydown javascript event and the browser goes properly in Fullscreen, I don't fake it or throw it myself or anything. So I am using user input.
But when I do the same from within the GM HTML5 game it just fills the browser window, like window_set_fullscreen() overriding my extension and taking over. Is this true and if so why does this happen? Don't you do keyboard events with keydown and keyup? I don't get what is the difference. I use a Keyboard Event and since it is user input that should launch fullscreen from my extension.

Don't you add event listeners to the document.body/window for keyboard events like this?

document.body.addEventListener('keydown', function(event) {
	switch(event.keyCode) {
		case 70: //F key
			ex_fullscreen_toggle(); //toggle fullscreen function here
		break;
	}
}, false);

This code above will switch to true fullscreen. What GameMaker does differently and that above doesn't seem to work!?

Edited by alexandervrs, 28 June 2012 - 12:39 PM.

  • 0

#6 Mike.Dailly

Mike.Dailly

    Evil YoYo Games Employee

  • Administrators
  • 1503 posts
  • Version:GM:Studio

Posted 28 June 2012 - 02:44 PM

This is basically what I'm saying.... it HAS to be on a user input, you can't "programmatically" do it, and because of this, you can't use window_set_fullscreen() properly.

Sure, you could use that on HTML5, and we could "remember", so that on the NEXT user input, we toggle to fullscreen, but that's a terrible user experience. You could set it when you run, and a user could be sitting watching an intro, then press a key and it suddenly goes fullscreen. We don't like that at all - it's horrible. Events like this should happen when the user expects them to.

So because of this, Fullscreen mode is tied to F10 so that it swaps to fullscreen mode when the user selects it.

As to "faking it", I was refering to trying to programmatically set fullscreen, NOT when the user pressed a mouse/key. I tried throwing keydown or mouse events, but unless it was generated by the system, the fullscreen API didn't kick off. So it has to be USER initiated.

I half agree with this, because you wouldn't want all these ads suddenly taking over your screen all the time, you want to "select" the stuff that does that.

So yes.... F10 for fullscreen - although you can disable that in the game preferences.
  • 0

#7 alexandervrs

alexandervrs

    GMC Member

  • GMC Member
  • 423 posts
  • Version:GM:Studio

Posted 28 June 2012 - 07:19 PM

This is basically what I'm saying.... it HAS to be on a user input, you can't "programmatically" do it, and because of this, you can't use window_set_fullscreen() properly.

Sure, you could use that on HTML5, and we could "remember", so that on the NEXT user input, we toggle to fullscreen, but that's a terrible user experience. You could set it when you run, and a user could be sitting watching an intro, then press a key and it suddenly goes fullscreen. We don't like that at all - it's horrible. Events like this should happen when the user expects them to.

So because of this, Fullscreen mode is tied to F10 so that it swaps to fullscreen mode when the user selects it.

As to "faking it", I was refering to trying to programmatically set fullscreen, NOT when the user pressed a mouse/key. I tried throwing keydown or mouse events, but unless it was generated by the system, the fullscreen API didn't kick off. So it has to be USER initiated.

I half agree with this, because you wouldn't want all these ads suddenly taking over your screen all the time, you want to "select" the stuff that does that.

So yes.... F10 for fullscreen - although you can disable that in the game preferences.


I agree, fullscreen launching should be limited to user input (mouse, keyboard and later on joystick). However I don't see why we can't call window_set_fullscreen() from a a Keyboard or Mouse event and work properly. I don't want it to happen automatically, I acknowledge HTML5/browser limitations.

I just finished my extension, added some workarounds to bypass GameMaker's conflicts*1 and now it just works with mouse and key input.
Are you sure that something doesn't conflict? I could provide my uncompressed source code for the extension so you can play with it.

*1 My html file worked without those workarounds so it's definitely something wrong with how GM does fullscreen

Edited by alexandervrs, 28 June 2012 - 09:14 PM.

  • 0

#8 Mike.Dailly

Mike.Dailly

    Evil YoYo Games Employee

  • Administrators
  • 1503 posts
  • Version:GM:Studio

Posted 28 June 2012 - 10:48 PM

GML Keybaordmand mouse events dont get called from inside the JavaScript event, they are stored and called from inside the main game loop. This keeps things consistent with other versions and event orders. Because of this, GML is unable to set full screen mode.
  • 0

#9 alexandervrs

alexandervrs

    GMC Member

  • GMC Member
  • 423 posts
  • Version:GM:Studio

Posted 28 June 2012 - 10:57 PM

Ah alright, I understand now.
And since my extension worked, all's well. :)
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users