Open yanicklandry opened 3 years ago
Hello,
It means that you are trying to go in fullscreen mode without user interaction. You won't be able to put the user in fullscreen without it, the browser prevents you to do so.
Hi having the same issue, geting "Failed to execute 'requestFullscreen' on 'Element': API can only be initiated by a user gesture.".
I use the following code (simplified)
var fullscreenButton = document.getElementById("fullscreenButton"); `
fullscreenButton.onclick = function()
{
if(!player) return;
player.maximize();
};
where "player" is the furioos player instance created with "new Player()".
Putting fullscreen switches inside onclick events usually prevents this issue, it doesnt in this case. Anything I am doing wrong here?
Edit: Using the recommended way to go fullscreen based on the mozilla documentation I was able to successfully switch to fullscreen using the code above, simply issuing the fullscreen request directly to the container provided to the players constructor as the second argument. So instead of calling maximize() I did the following:
if (!document.fullscreenElement) {
container.requestFullscreen().catch(err => {
alert(`Error attempting to enable full-screen mode: ${err.message} (${err.name})`);
});
} else {
document.exitFullscreen();
}
where "container" was the same DOM element which I provided as the second argument to the Player constructor.
Thanks @peettee , your method actually works.
I made a code to demo it, in order for Furioos support to see that there is a bug with the player.maximize() :
https://furioos-demo-fullscreen-bug.vercel.app
Source code is here : https://github.com/pipemind-com/furioos-demo-fullscreen-bug/blob/main/pages/index.js#L22-L35
I get the following error in Firefox :