Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Full screen video toggle HTML

Tags:

html

video

The video tag in HTML 5 is really fascinating. I need to know whether it is possible to let users toggle full screen play. I dont wanna use any other video plugin. I just need to use the video tag. So is this possible. Please help me out....

like image 681
Srivathsan Avatar asked Jun 23 '12 18:06

Srivathsan


People also ask

How do I show custom video controls even in fullscreen?

You have to call the enterFS method on the container element, not on the video one. So the answer is to use the Fullscreen API on the container element rather than the <video> element. This enables providing custom controls in that container which is now all in fullscreen.

How do I enable full screen in HTML?

Full-screen can be activated for the whole browser window by pressing the F11 key. It can be exited by pressing the Esc button. It is also possible to make a specific element in the page to enter and exit full-screen mode programmatically using Javascript Fullscreen API.


2 Answers

You can use the following code to create a button that will take the video into full screen mode.

Javascript code:

<script type="text/javascript">
function goFullscreen(id) {
  var element = document.getElementById(id);       
  if (element.mozRequestFullScreen) {
    element.mozRequestFullScreen();
  } else if (element.webkitRequestFullScreen) {
    element.webkitRequestFullScreen();
  }  
}
</script>

Html code:

<video class="video_player" id="player" width="100%" controls="controls" autoplay="autoplay">
  <source src="INPUT VIDEO URL HERE"/>
  Your browser does not support the HTML5 video tag.  Use a better browser!
</video>
<button onclick="goFullscreen('player'); return false">
  View Fullscreen!
</button>
like image 150
godofyouall Avatar answered Sep 26 '22 18:09

godofyouall


Yes. It is possible. However, there are some limitations in most browsers. It is currently only supported (as of June 2012) in Webkit-based browsers like Safari and Chrome.

Please check the following:

  1. http://videojs.com/
  2. http://blog.jilion.com/2011/07/27/world-s-first-true-html5-fullscreen-video (works only in Safari)
  3. http://easyhtml5video.com/
  4. http://johncblandii.com/2011/07/html5-video-fullscreen.html
like image 35
Geocrafter Avatar answered Sep 26 '22 18:09

Geocrafter