Reputation: 3762
I'd like to play the video automatically in fullscreen mode when clicked the play button. So far, I have to click two buttons (go to fullscreen and play). Is there some html attribute that can join these two actions?
Upvotes: 1
Views: 1220
Reputation: 59
There's not a single attribute for this, but you can solve this with JavaScript:
document.getElementById("videoplayer").addEventListener("playing", event => {
const player = document.getElementById("videoplayer");
if (player.requestFullscreen)
player.requestFullscreen();
else if (player.webkitRequestFullscreen)
player.webkitRequestFullscreen();
else if (player.msRequestFullScreen)
player.msRequestFullScreen();
})
<video id="videoplayer" src="https://www.w3schools.com/tags/movie.mp4" controls></video>
Please note, that it doesn't work in this snippet environment.
Upvotes: 1