1

Setting of webview

if (Build.VERSION.SDK_INT >= 19) {
            webview.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
            webview.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);
        }
        webview.getSettings().setAllowContentAccess(true);
        webview.getSettings().setAllowUniversalAccessFromFileURLs(true);
        webview.getSettings().setAllowFileAccessFromFileURLs(true);
        webview.getSettings().setLoadWithOverviewMode(true);
        webview.getSettings().setUseWideViewPort(true);
        webview.getSettings().setJavaScriptEnabled(true);
        webview.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
         myWebview.setWebContentsDebuggingEnabled(true);
        webview.getSettings().setDomStorageEnabled(true);
        webview.getSettings().setSupportZoom(true);

        webview.getSettings().setSupportMultipleWindows(true);
        webview.getSettings().setAppCachePath(getActivity().getFilesDir().getAbsolutePath() + "/cache");
        webview.getSettings().setDatabaseEnabled(true);
        webview.getSettings().setDatabasePath(getActivity().getFilesDir().getAbsolutePath() + "/databases");

      webview.getSettings().setSaveFormData(true);

        webview.getSettings().setPluginState(WebSettings.PluginState.ON);
        webview.getSettings().setAllowFileAccess(true);
        webview.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
        webview.getSettings().setMediaPlaybackRequiresUserGesture(false);
        webview.getSettings().setSupportMultipleWindows(true);

        if (Build.VERSION.SDK_INT >= 21) {
            webview.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);

        }
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            webview.setLayerType(View.LAYER_TYPE_HARDWARE, null);
        } else {
            webview.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
        }


        webview.getSettings().setAppCacheEnabled(true);
        webview.getSettings().setLoadsImagesAutomatically(true);
        webview.setWebChromeClient(new WebChromeClientCustomPoster());

        webview.getSettings().setUserAgentString("Mozilla/5.0 (Linux; Android 4.4; Nexus 5 Build/_BuildID_) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/30.0.0.0 Mobile Safari/537.36");

But web view to show the only thumbnail of the video Problem only in kitkat

5
  • KitKat is old. Double check the video encoding format. As WebView code is tied to KitKat OS version if you are connecting to a site that you have no control over, there are limited options depending on what you are try to do & device environment. Providing a logcat when failing might help. Commented Mar 9, 2021 at 5:42
  • may be this creates issue Access denied finding property "acodec.video.buflogging" or [INFO:CONSOLE(1)] "Uncaught TypeError: Cannot read property 'play' of undefined", or may be this evaluateJavascript=javascript:(function() { document.getElementsByTagName('video')[0].play(); })() Commented Mar 9, 2021 at 6:10
  • You should specify what hardware you are testing on. While sounds similar not sure if relevant: Android KitKat (4.4) video autoplay does not work anymore in webview Commented Mar 9, 2021 at 6:33
  • Hardware is Android Tv Daiwa Supportive version Android 4.4.2 Commented Mar 9, 2021 at 6:35
  • Does WebView auto play video on different Android 4.4 hardware - like a Nexus 4 or Samsung device running 4.4? If so then TV ODM issue. Or site is using modern HTML5 which doesn't work on old WebView. If you are required to get it working, one alternative is to switch out the webview engine with something more modern as I suggested in this answer but video playing is unknown, and APK size gets large. Commented Mar 9, 2021 at 7:01

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.