Opening HTML5 Video in Full Screen Mode
These days videos come in very good quality and some of the paying sites provide HD quality videos as well. So, it is oftentimes users expand their video players in full screen mode. YouTube allows you to do that as well as myriad other commercially available video players.
HTML5 video control can also be opened in full screen mode with the help of webkitSupportsFullscreen property and webkitEnterFullscreen() method of our video control object. In order to exit out of full screen mode, user needs to press "Esc" button on their keyboard.
Here is HTML5 boilerplate code that allows us to expand and exit full screen mode with ease.
<!DOCTYPE html>
<html>
<head>
<title>HTML5 Video Full Screen Mode Example</title>
<script>
var myVideo;
window.onload = function()
{
myVideo= document.getElementById("myVideoFile");
btnfullMode.addEventListener("click", setFullScreenMode, false);
video.addEventListener("loadedmetadata", makeFullModeVisible, false);
}
function makeFullModeVisible()
{
if (video.webkitSupportsFullscreen)
{
document.getElementById("btnfullMode").style.visibility="visible";
}
}
function setFullScreenMode()
{
video.webkitEnterFullscreen();
}
</script>
</head>
<body>
<div id="video_container">
<video width="320" height="176" src="myVideoFile.mp4" id="myVideoFile" autoplay />
</div>
<br/>
<button type="button" id="btnfullMode" >
Open Video in Full Screen mode
</button>
</body>
</html>