Playing Mp4 using JwPlayer inside WebView

I am using an http server inside my application (using nanohttpd) that serves as a page that has a video element that plays a video using JwPlayer. Video type: .mp4.

The problem is I can't play videos correctly in my Galaxy Samsung S3 Mini with custom ROM. The audio is ok, but inside the video area everything is black except for the bottom right corner which displays a portion of the web view (glitches). I tried to enable hardware acceleration but it still doesn't work.

The video plays correctly in the android browser browser (accessible via app server), perhaps it is a bug with the WebView or chrome configuration? It also plays correctly in some other devices (Samsung Galaxy S3).

This is the code I am using to set up the WebView:

    webView = (WebView) findViewById(R.id.webview);
    webView.setBackgroundColor(Color.TRANSPARENT);
    if (Build.VERSION.SDK_INT >= 11)
        webView.setLayerType(View.LAYER_TYPE_HARDWARE, null);

    webView.getSettings().setJavaScriptEnabled(true);
    webView.getSettings().setLoadsImagesAutomatically(true);
    webView.getSettings().setPluginState(PluginState.ON);
    webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
    webView.getSettings().setAllowFileAccess(true);

    getWindow().addFlags(128);
    webView.setWebChromeClient(new WebChromeClient() {  
        @Override  
        public boolean onJsAlert(WebView view, String url, String message, final android.webkit.JsResult result)  
        {  
            Log.d(LOGTAG, message);
            new AlertDialog.Builder(view.getContext()).setMessage(message).setCancelable(true).show();
            result.confirm();
            return true;
        }
    });
    webView.getSettings().setUserAgentString("Mozilla/5.0 (Windows; U; Windows NT 6.1; en-GB; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 (.NET CLR 3.5.30729)");

      

These errors are logged by the device when playback starts:

08-29 10:26:31.359: E/chromium(6191): [ERROR:gles2_cmd_decoder.cc(5942)] [.Compositor-Onscreen-0x1490ca0]GL ERROR :GL_INVALID_OPERATION : glUseProgram: program not linked
08-29 10:26:31.359: E/chromium(6191): [ERROR:gles2_cmd_decoder.cc(5718)] [.Compositor-Onscreen-0x1490ca0]GL ERROR :GL_INVALID_OPERATION : glUniformMatrix4fv: wrong uniform function for type

      

Thanks in advance.

+3


source to share





All Articles