HTML5 <视频>Android 上的元素 [英] HTML5 <video> element on Android

查看:29
本文介绍了HTML5 <视频>Android 上的元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据:

http://developer.android.com/sdk/android-2.0-亮点.html

Android 2.0 应支持 HTML5 视频元素.我无法使用摩托罗拉 Droid 使其工作,并且无法成功查看任何 HTML5 视频示例页面上的视频.由于目前不支持 QuickTime 或 Flash,这是我能想到的在网页中嵌入 mp4 视频的唯一其他方法.有没有人有这方面的运气?

Android 2.0 should support the HTML5 video element. I haven't been able to get this to work using a Motorola Droid, and haven't been able to successfully view a video on any of the HTML5 video example pages out there. Since there currently isn't support for QuickTime or Flash, this is the only other thing I can think of for embedding mp4 video in a web page. Has anyone had any luck with this?

推荐答案

我刚刚对此做了一些实验,据我所知,您需要三件事:

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

  1. 调用视频时不得使用 type 属性.
  2. 您必须手动调用 video.play()
  3. 视频必须编码为一些非常严格的参数;使用 iPhone 上的 Handbrake 设置并选中Web Optimized"按钮通常可以解决问题.

看看这个页面上的演示:http://broken-links.com/tests/视频/

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

AFAIK,这适用于所有支持视频的桌面浏览器、iPhone 和 Android.

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

这是标记:

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

我在 JS 中有这个:

And I have this in the JS:

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

我在三星 Galaxy S 上进行了测试,效果很好.

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

这篇关于HTML5 &lt;视频&gt;Android 上的元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆