HTML5 <视频>Android 上的元素无法播放 [英] HTML5 <video> element on Android does not play

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

问题描述

像下面这样的视频标签在 iPhone 上可以正常播放,但在 Android 上不能播放:

Video tags like below plays fine with iPhone, but not Android:

<video id="video" width="320" height="240" poster="video/placeholder.jpg" autobuffer controls>
  <source src="pr6.mp4" type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"'>
  <source src="pr6.ogv" type='video/ogg; codecs="theora, vorbis"'>
</video>

有了上面的代码,Android连点击剪辑都不能.它只会看到海报图片.

With the above code, Android can't even click the clip. It would just see the poster image.

像下面这样的视频标签适用于 Android:

Video tag like below however works with Android:

<video src="vpr6.mp4" poster="video/placeholder.jpg" onclick="this.play();"/>

但是,我仍然需要多源功能(对于 Firefox ogv 支持...).下面的代码不起作用(如果我将 javascript 粘贴到源标签中,它们也不起作用):

However, I still need to multiple sources capability (for Firefox ogv support…). Below code does not work (nor do they work if I stick the javascript into the source tags):

<video id="video" width="320" height="240" autobuffer controls onclick="this.play();">
  <source src="pr6.mp4" type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"'>
  <source src="pr6.ogv" type='video/ogg; codecs="theora, vorbis"'>
</video>

使用上面的代码,该剪辑在 Android 中是可点击的,但仍然什么都不做.

With above code, the clip is clickable in Android, but still does nothing.

有人可以帮忙吗?

推荐答案

尝试从源列表中删除编解码器.. 可能是您列出的编解码器在 Android 上不存在,所以很卡.

Try to remove the codecs from the source listings.. It might be that the codecs you're listing are not present on Android, so it's choking.

>

如果你使用 src 属性,它会自动检测编解码器,所以它使用其他东西:)

If you use the src attribute, it'll auto-detect the codec, so it's using something else :)

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

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