androidwebviewwebchromeclient

Unable to play DRM content with WebChromeClient


I'm trying to build a simple webview in Android Pie that is able to play DRM content, using for example Bitmovin or Shaka Player. I have collected some snippets from other stackoverflow posts, but while Bitmovin/Shaka can apparently detect widevine support and play sound, the video isn't loading.

Here's my code so far:

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

    browser.setWebChromeClient(new WebChromeClient(){
       @Override
       public void onPermissionRequest(PermissionRequest request) {
           String[] resources = request.getResources();
           for (int i = 0; i < resources.length; i++) {
               if (PermissionRequest.RESOURCE_PROTECTED_MEDIA_ID.equals(resources[i])) {
                   request.grant(resources);
                   return;
               }
           }
           super.onPermissionRequest(request);
    }});

    browser.getSettings().setJavaScriptEnabled(true);
    browser.getSettings().setDomStorageEnabled(true);

    browser.loadUrl("https://bitmovin.com/demos/drm");

Any idea what could be missing?


Solution

  • It was failing because the device only had widevine L3, it worked for L1