Created
January 13, 2016 17:24
-
-
Save yuanliwei/5ddc1cd6c7c013eaa886 to your computer and use it in GitHub Desktop.
WebView 支持HTML5 中 Video 视频全屏播放功能
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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