问题描述:
腾讯X5内核WebView的播放HLS视频全屏异常。
解决方法:
WebView初始化中加入以下内容:
try {
if (x5WebView.getX5WebViewExtension() != null) {
Bundle data = new Bundle();
data.putBoolean("standardFullScreen", false);
data.putBoolean("supportLiteWnd", false);
data.putInt("DefaultVideoScreen", 1);
x5WebView.getX5WebViewExtension().invokeMiscMethod("setVideoParams", data);
}
} catch (Exception e) {
e.printStackTrace();
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
// chromium, enable hardware acceleration
x5WebView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
} else {
// older android version, disable hardware acceleration
x5WebView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}
Manifest文件里相关activity加入:
android:configChanges="orientation|screenSize|keyboardHidden"