Videos
To allow a webview to play a DRM content you have to grant RESOURCE_PROTECTED_MEDIA_ID permission to the webview.
You can do it by override of WebChromeClient#onPermissionRequest
As a sample:
@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);
}
setAllowContentAccess() (I couldn't find the allowContentAccess() you mentioned) is used for accessing local content files on the device, not for protected content.
Protected content viewing enabling is usually controlled by the user, not the developer unfortunately. For example, for the default browser Chrome according to this help article:
Chrome will play protected content by default.
If you don't want Chrome to play protected content by default, you can change your settings:
- On your Android phone or tablet, open the Chrome app Chrome.
- To the right of the address bar, tap More More and then Settings.
- Tap Site settings and then Media and then Protected Content.
- Select Ask first.
Since accessing protected content requires the site viewing information about your device, I expect this isn't available through a WebView.
There is a full built-in framework available (since API level 11) for managing DRM content that should be used instead.
I'm using Windows 7, my Chrome is on version 109 and this issue started yesterday.
Spotify says:
Playback of protected content is not enabled.
Visit Spotify Support to learn how to enable playback in your browser.
and sends me to https://support.spotify.com/uk/article/web-player-help/?utm_source=open&utm_campaign=drm_error&utm_medium=web
There, it tells me I need Chrome 87 or above, but I have version 109. The other suggestion on the page (turn on play protected content) I did, but it made no difference.
Netflix also tells me to allow protected content. I tried the method in these comments and it let me open Spotify but whenever I clicked a song, it skips through 15 different songs, plays the first 10 seconds then crash. Today, it went back to the previous error message