我正在尝试并且未能正确显示全屏视频。
我的WebChromeClient实现onHideCustomView和onShowCustomView。我的布局有单独的布局,用于显示视频和显示webView。问题是,有时它可以正常工作,有时则不然。它只发生在一个网站上。我注意到,该视频在JW播放器7.2.2上正确全屏,而在JW播放器6.12.4945上经常失败。
点击全屏按钮或双击视频时的外观如下。请注意,视频上方有网站内容,屏幕底部有空视图:https://drive.google.com/file/d/0B942jMuE3MylMVZQNVp6X0Y2ZGc/view?usp=sharing
webChromeClient = new WebChromeClient() {
@Override
public void onProgressChanged(WebView view, int newProgress) {
super.onProgressChanged(view, newProgress);
progressBar.setProgress(newProgress);
}
@Override
public void onHideCustomView() {
fullscreen = false;
showUI();
mVideoView.removeAllViews();
}
@Override
public void onShowCustomView(View view, CustomViewCallback callback) {
fullscreen = true; //for onBackPressed
hideUI();
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
mVideoView.addView(view, params);
}
};
<RelativeLayout
android:id="@+id/root"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<RelativeLayout
android:id="@+id/contentView"
android:layout_width="match_parent"
android:layout_height="match_parent"></RelativeLayout>
<RelativeLayout
android:id="@+id/videoView"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</RelativeLayout>