I can't seem to figure out which element should I add the event listener to for it to work on iOS, I'm listening to these events
['webkitfullscreenchange', 'mozfullscreenchange', 'fullscreenchange', 'MSFullscreenChange'];
and listening on both document
and the element you pass to new YT.Player()
, both are firing just fine on desktop browsers as well as android browsers, but neither fires on iOS (chrome or safari, doesn't matter).
You can check it live here, at the bottom http://youtubeplayer.fxck.cz/ -1, 1, 2, 3
are the standard youtube player events, 1337 is fullscreenchange
from the element, 1338 is fullscreenchange
from document
.
Oh, actually, I think I figured out what the issue was. iOS doesn't support the fullscreen API and it only lets the native video element be taken fullscreen with the native controls, which is what enterFullscreenon the tech does.
If the tech implements supportsFullscreen, videojs will try and enter "full window" mode where it just makes the player div take over the entire screen, kind of faking fullscreen. But otherwise, unless a native video element is being used, I don't think you'd be able to go fullscreen.
The APIs Explorer uses demo credentials by default to make it easier to get started. But you'll use your own API key to run the sample locally. The right side of the fullscreen APIs Explorer shows tabs with code samples in different languages. Select the JavaScripttab.
Using the API's JavaScript functions, you can queue videos for playback; play, pause, or stop those videos; adjust the player volume; or retrieve information about the video being played. You can also add event listeners that will execute in response to certain player events, such as a player state change.
use the following detection ways:
document.onwebkitfullscreenchange
document.onfullscreenchange
document.onmozfullscreenchange
also use a variable to store whether or not fullscreen was entered
isInFullscreen = false;
the moment one of those above get called we just negate the current state. that way we detect fullscreen changes.
jquery approach example:
var isFullscreen = document.fullScreen || document.mozFullScreen || document.webkitIsFullScreen;
$(document).on ('mozfullscreenchange webkitfullscreenchange fullscreenchange',function(){
isFullscreen = !isFullscreen;
});
you will need to have more indicators to ensure compability with every browser out there.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With