Skip to content

Instantly share code, notes, and snippets.

@yuanliwei
Created January 13, 2016 17:24
Show Gist options
  • Save yuanliwei/5ddc1cd6c7c013eaa886 to your computer and use it in GitHub Desktop.
Save yuanliwei/5ddc1cd6c7c013eaa886 to your computer and use it in GitHub Desktop.
WebView 支持HTML5 中 Video 视频全屏播放功能
web.setWebChromeClient(new WebChromeClient() {
private CustomViewCallback myCallback;
private View videoView;
@Override
public void onShowCustomView(View view, CustomViewCallback callback) {
if (myCallback != null) {
myCallback.onCustomViewHidden();
myCallback = null;
return;
}
ViewGroup parent = (ViewGroup) web.getParent();
videoView = view;
parent.removeView(web);
parent.addView(view);
myCallback = callback;
}
@Override
public void onHideCustomView() {
ViewGroup parent = (ViewGroup) web.getParent();
if (videoView != null)
parent.removeView(videoView);
parent.addView(web);
myCallback = null;
videoView = null;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment