首页 > 代码库 > android webview 通过html5播放在线视频 切换大屏

android webview 通过html5播放在线视频 切换大屏

1、添加网络访问权限

<uses-permission android:name="android.permission.INTERNET" />


2、webview添加全屏支持

developer官方文档关于html5支持视频播放描述如下:In order to support inline HTML5 video in your application, you need to have hardware acceleration turned on, and set a WebChromeClient. For full screen support, implementations of onShowCustomView(View, WebChromeClient.CustomViewCallback) and onHideCustomView() are required, getVideoLoadingProgressView() is optional.

1)开启硬件加速

2)重写WebChromeClient的onShowCustomView(View, WebChromeClient.CustomViewCallback)onHideCustomView()

通过onShowcustomView对大屏的布局进行加载,隐藏小屏布局;在onHideCustomeView中退出全屏播放,重新显示小屏布局


参考:

http://developer.android.com/reference/android/webkit/WebView.html

http://stackoverflow.com/questions/12708890/youtube-video-not-playing-in-webview-android/12850816#12850816