android html5 video

1.At the beginning
Android support html5 with its WebKit module which in the folder “external/webkit”, so it can found the video tag in a website html source code and take the video url from it. But the Webkit of Android does not support html5-video Mimetype by its default setting and many video-websites only offer their html5 version webpage to ipad/iphone Browser ,other client browser could not get the html5 version webpage but the flash version one. So we should modiy the Android source code as following.

 

2.Let Android Browser become a Ipad Browser

The website server can judge if the client browser is ipad/iphone browser by its user- agent. So we can change the android browser’s user-agent to fade our client as a ipad browser to ask the video-websites to offer a html5 version webpage so that we can avoid the flash one. The detail modify is in the following source code of the patch:

packages\apps\Browser\src\com\android\browser\BrowserSettings.java

 

3.Register the Support Mimetypes of the html5-video

Android does not support the Mimetypes of the html5-video by its default setting. So we must manually add the Mimetypes int the html5-video-player source code. The detail modify is in the following source code of the patch:

external\webkit\WebKit\android\WebCoreSupport\MediaPlayerPrivateAndroid.cpp

external\webkit\WebCore\platform\graphics\android\MediaPlayerPrivateAndroid.h

 


You will see we modify the member function of MediaPlayerPrivate named getSupportedTypes(HashSet<String>& types) . We have add almost all the html5-video Mimetype to this function so that Android can detect all the html5-video resource when it login the html5 webpage.

 

4.Add embed tag video resource support in the Android Webkit

www.tudou.com is the most popular video-website in China, many Chinese people prefer to enjoy the video from it. However, this website video resource is not a standard html5-video resource , it use embed tag to package the video resource but not video tag. So we must rewrite the html parser code of Android webkit. The detail modify is in the following source of the patch:

external\webkit\WebCore\html\HTMLEmbedElement.cpp

external\webkit\WebCore\html\HTMLEmbedElement.h


after the modify, we can also enjoy the video from www.tudou.com .

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值