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 .

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章