HTML5 <video> element on Android

后端 未结 15 2132
逝去的感伤
逝去的感伤 2020-11-22 15:09

According to:

http://developer.android.com/sdk/android-2.0-highlights.html

Android 2.0 should support the HTML5 video element. I haven\'t been able to get th

相关标签:
15条回答
  • 2020-11-22 15:24

    Try h.264 in an mp4 container. I've had much success with it on my Droid X. I've been using zencoder.com for format conversions.

    0 讨论(0)
  • 2020-11-22 15:24

    It's supposed to work, but watch the resolution: Android 2.0 and webkit

    Canvas works right out of the box, while Geolocation seems to not work at all in the Emulator. Of course, I have to send it mock locations to get it to work, so I have no idea what this would be like on an actual phone. I can say the same thing with the video tag. There are issues with it not actually playing the video, BUT I think it’s the fact that the video is a higher resolution than what the Emulator can handle. We’ll know more once someone tries this on a Motorola Droid or other next-gen Android device

    0 讨论(0)
  • 2020-11-22 15:25

    pointing my android 2.2 browser to html5test.com, tells me that the video element is supported, but none of the listed video codecs... seems a little pointless to support the video element but no codecs??? unless there is something wrong with that test page.

    however, i did find the same kind of situation with the audio element: the element is supported, but no audio formats. see here:

    http://textopiablog.wordpress.com/2010/06/25/browser-support-for-html5-audio/

    0 讨论(0)
  • 2020-11-22 15:28

    This works for me:

    <video id="video-example" width="256" height="177" poster="image.jpg">
    <source src="video/video.mp4" type="video/mp4"></source>
    <source src="video/video.ogg" type="video/ogg"></source>
    This browser does not support HTML5
    </video>
    

    Only when the .mp4 is on top and the videofile is not to big.

    0 讨论(0)
  • 2020-11-22 15:29

    If you manually call video.play() it should work:

    <!DOCTYPE html>
    <html>
    <head>
      <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>
    </head>
    <body onload="init()">
    
      <video src="sample.mp4" width="400" height="300" controls></video>
    
      ...
    
    </body>
    </html>
    
    0 讨论(0)
  • 2020-11-22 15:33

    I've just done some experimentation with this, and from what I can tell you need three things:

    1. You must not use the type attribute when calling the video.
    2. You must manually call video.play()
    3. The video must be encoded to some quite strict parameters; using the iPhone setting on Handbrake with the 'Web Optimized' button checked usually does the trick.

    Have a look at the demo on this page: http://broken-links.com/tests/video/

    This works, AFAIK, in all video-enabled desktop browsers, iPhone and Android.

    Here's the markup:

    <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>
    

    And I have this in the JS:

    var video = document.getElementById('video');
    video.addEventListener('click',function(){
      video.play();
    },false);
    

    I tested this on a Samsung Galaxy S and it works fine.

    0 讨论(0)
提交回复
热议问题