Android 6中android webview youtube视频中全屏模式下的问题

问题描述 投票:1回答:1

Android 6怎么了?请帮助我解决这个问题。

logcat第一行中的**************是一个短链接。要查看该链接,请单击here

我尝试了许多其他链接,但Android 6中存在相同的问题。

Logcat:

I/chromium: [INFO:CONSOLE(0)] "requestFullscreen() is deprecated on insecure origins, and support will be removed in the future. You should consider switching your application to a secure origin, such as HTTPS. See************* for more details.", source:  (0)
E/eglCodecCommon: glUtilsParamSize: unknow param 0x000085b5
E/eglCodecCommon: glUtilsParamSize: unknow param 0x000085b5
D/EGL_emulation: eglMakeCurrent: 0x9e67de60: ver 2 0 (tinfo 0x996d7240)
E/eglCodecCommon: glUtilsParamSize: unknow param 0x000085b5
W/AwContents: onDetachedFromWindow called when already detached. Ignoring
D/EGL_emulation: eglMakeCurrent: 0x9e67dda0: ver 2 0 (tinfo 0x996d7240)
D/EGL_emulation: eglMakeCurrent: 0x9e67de60: ver 2 0 (tinfo 0x996d7240)
D/EGL_emulation: eglMakeCurrent: 0x9e67dda0: ver 2 0 (tinfo 0x996d7240)
W/ResourceType: No known package when getting value for resource number 0x02040005
W/System.err: android.content.res.Resources$NotFoundException: String resource ID #0x2040005
        at android.content.res.Resources.getText(Resources.java:312)
        at android.content.res.Resources.getString(Resources.java:400)
        at android.content.Context.getString(Context.java:409)
        at org.chromium.content.browser.ContentVideoView.initResources(ContentVideoView.java:186)
        at org.chromium.content.browser.ContentVideoView.<init>(ContentVideoView.java:174)
        at org.chromium.content.browser.ContentVideoView.createContentVideoView(ContentVideoView.java:365)
        at org.chromium.base.SystemMessageHandler.nativeDoRunLoopOnce(Native Method)
W/System.err:     at org.chromium.base.SystemMessageHandler.handleMessage(SystemMessageHandler.java:53)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:148)
        at android.app.ActivityThread.main(ActivityThread.java:5417)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
A/chromium: [FATAL:jni_android.cc(249)] Check failed: false. Please include Java exception stack in crash report
A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 9796 (m.di.battlegame)
E/eglCodecCommon: glUtilsParamSize: unknow param 0x000085b5
Process 9796 terminated.

Java代码:

                webView=(WebView)findViewById(R.id.webview);

                webView.setWebChromeClient(new MyCrome(){

                });



                webView.getSettings().setJavaScriptEnabled(true);




                videourl="<html><body>"+description+"<br><iframe width=\"100%\" height=\"90%\" src=\"https://www.youtube.com/embed/"+videoid+"\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"></iframe></body></html>";

                webView.loadData(videourl,"text/html","utf-8");











public class MyCrome extends WebChromeClient {



        private View mCustomView;
        private WebChromeClient.CustomViewCallback mCustomViewCallback;
        protected FrameLayout mFullscreenContainer;
        private int mOriginalOrientation;
        private int mOriginalSystemUiVisibility;

        MyCrome() {}


        public Bitmap getDefaultVideoPoster()
        {
            if (HowtoActivity.this == null) {

                return Bitmap.createBitmap(50, 50, Bitmap.Config.ARGB_8888);
                //return null;
            }
            //return BitmapFactory.decodeResource(HowtoActivity.this.getApplicationContext().getResources(), 2130837573);

            return Bitmap.createBitmap(50, 50, Bitmap.Config.ARGB_8888);
        }

        public void onHideCustomView()
        {



            ((FrameLayout)HowtoActivity.this.getWindow().getDecorView()).removeView(this.mCustomView);
            this.mCustomView = null;
            HowtoActivity.this.getWindow().getDecorView().setSystemUiVisibility(this.mOriginalSystemUiVisibility);
            HowtoActivity.this.setRequestedOrientation(this.mOriginalOrientation);
            this.mCustomViewCallback.onCustomViewHidden();
            this.mCustomViewCallback = null;

        }



        public void onShowCustomView(View paramView, WebChromeClient.CustomViewCallback paramCustomViewCallback)
        {
            if (this.mCustomView != null)
            {
                onHideCustomView();
                return;
            }

            this.mCustomView = paramView;
            mCustomView.setBackgroundColor(Color.BLACK);
            this.mOriginalSystemUiVisibility = HowtoActivity.this.getWindow().getDecorView().getSystemUiVisibility();
            this.mOriginalOrientation = HowtoActivity.this.getRequestedOrientation();
            this.mCustomViewCallback = paramCustomViewCallback;
            ((FrameLayout)HowtoActivity.this.getWindow().getDecorView()).addView(this.mCustomView, new FrameLayout.LayoutParams(-1, -1));
            HowtoActivity.this.getWindow().getDecorView().setSystemUiVisibility(3846);
        }
        }


以上显示webview youtube视频的代码。我在android 9和android 10上测试完美。但在android 6中,它给了我loglog上面的错误或异常显示

java android android-webview android-6.0-marshmallow webchromeclient
1个回答
0
投票

我解决了我的问题。它仅在模拟器中发生。

© www.soinside.com 2019 - 2024. All rights reserved.