Inline video in Android browsers

0
No votes yet
Your rating: None

HTML:

<video id="video" autobuffer height="240" width="360">
<source src="BigBuck.m4v">
<source src="BigBuck.webm" type="video/webm">
<source src="BigBuck.theora.ogv" type="video/ogg">
</video>

JavaScript:

<script>
  function init() {
    enableVideoClicks();
  }

  function enableVideoClicks() {
    var videos = document.getElementsByTagName('video') || [];
    for (var i = 0; i < videos.length; i++) {
      // TODO: use attachEvent in IE
      videos[i].addEventListener('click', function(videoNode) {
        return function() {
          videoNode.play();
        };
      }(videos[i]));
    }
  }
</script>

http://stackoverflow.com/…t-on-android

Keywords: Android, JavaScript