播放HTML5视频的浏览器 - 对于大多数Android设备的工作原理是什么? [英] Playing HTML5 Videos in Browser -- What Works for Most Android Devices?

查看:405
本文介绍了播放HTML5视频的浏览器 - 对于大多数Android设备的工作原理是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让HTML5的视频在移动设备上播放。他们似乎在iOS的最新版本上运行正常,但我得到了很多的矛盾与Android设备。

I'm trying to get HTML5 videos to play on mobile devices. They seem to run fine on the latest version of iOS, but I'm getting a lot of inconsistency with Android devices.

我使用video.js和监听缩略图像一个点击,这反过来替换为HTML5视频元素,并自动播放。下面code平出不上Android模拟器的工作(点击缩略图什么都不做)。当我尝试在我自己的DROID RAZR,它开始加载视频,然后在浏览器死机。这发生在本地浏览器的的浏览器,它告诉我这件事情本机的设备。

I'm using video.js and listening for a click on a thumbnail image, which in return replaces the element with a HTML5 video and plays it automatically. The following code flat out doesn't work on the Android emulator (clicking on a thumbnail does nothing). When I try it on my own Droid Razr, it begins to load the video and then the browser freezes up. This happens in the native browser and Chrome, which tells me it's something native to the device.

$(".video").live("click", function(e) {
    e.preventDefault();
    $(this).replaceWith("<video id='" + $(this).data("video-id") + "' class='video-js' preoload='auto' width='100%' height='100%' poster='" + $(this).data("video-poster-url") + "'><source type='video/mp4; codecs=\"avc1.42E01E, mp4a.40.2\"' src='" + $(this).data("video-url")  + "'></video>");

    video  = _V_($(this));
    video.ready(function() {
       this.play();
       this.requestFullScreen();
    });
});

在HTML结束是:

The HTML ends up being:

<video id='fv3530' class='video-js' preoload='auto' width='100%' height='100%' poster='/posters/fv3530.jpg'>
    <source type='video/mp4; codecs="avc1.42E01E, mp4a.40.2" src='/videos/fv3530.mp4'>
</video>

是否有人知道为什么会导致Android设备来完全冻结了,我能做些什么,使影片在大多数Android设备上运行一致?

Does anybody know why this would cause an Android device to totally freeze up, and what I can do to make videos run consistently on most Android devices?

谢谢!

推荐答案

删除键入源属性宣言。这通常会导致与Android的问题,老版本更是如此。

Remove the type attribute from the source declaration. This usually causes issues with Android, older versions especially.

您源声明应该仅仅是:

<source src='/videos/fv3530.mp4'>

我有href="http://tobymanley.com" rel="nofollow">小网站已经工作HTML5视频在Android(只是测试它在我的HTC Desire运行Android 2.2

I have a small site which has a working HTML5 video on Android (just tested it on my HTC Desire running Android 2.2).

这篇关于播放HTML5视频的浏览器 - 对于大多数Android设备的工作原理是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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