Demo app: Fix DRM support check for ClearKey

Issue: Issue: #7735
PiperOrigin-RevId: 325900705
This commit is contained in:
olly 2020-08-10 23:26:50 +01:00 committed by Oliver Woodman
parent 4faee07d57
commit bcc4f797b2
3 changed files with 13 additions and 2 deletions

View File

@ -23,6 +23,8 @@
* IMA extension: Upgrade to IMA SDK 3.19.4, bringing in a fix for setting the * IMA extension: Upgrade to IMA SDK 3.19.4, bringing in a fix for setting the
media load timeout media load timeout
([#7170](https://github.com/google/ExoPlayer/issues/7170)). ([#7170](https://github.com/google/ExoPlayer/issues/7170)).
* Demo app: Fix playback of ClearKey protected content on API level 26 and
earlier ([#7735](https://github.com/google/ExoPlayer/issues/7735)).
### 2.11.7 (2020-06-29) ### ### 2.11.7 (2020-06-29) ###

View File

@ -17,7 +17,6 @@ package com.google.android.exoplayer2.demo;
import android.content.Intent; import android.content.Intent;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.media.MediaDrm;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.util.Pair; import android.util.Pair;
@ -47,6 +46,7 @@ import com.google.android.exoplayer2.drm.ExoMediaCrypto;
import com.google.android.exoplayer2.drm.FrameworkMediaDrm; import com.google.android.exoplayer2.drm.FrameworkMediaDrm;
import com.google.android.exoplayer2.drm.HttpMediaDrmCallback; import com.google.android.exoplayer2.drm.HttpMediaDrmCallback;
import com.google.android.exoplayer2.drm.MediaDrmCallback; import com.google.android.exoplayer2.drm.MediaDrmCallback;
import com.google.android.exoplayer2.drm.FrameworkMediaDrm;
import com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.DecoderInitializationException; import com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.DecoderInitializationException;
import com.google.android.exoplayer2.mediacodec.MediaCodecUtil.DecoderQueryException; import com.google.android.exoplayer2.mediacodec.MediaCodecUtil.DecoderQueryException;
import com.google.android.exoplayer2.offline.DownloadHelper; import com.google.android.exoplayer2.offline.DownloadHelper;
@ -485,7 +485,7 @@ public class PlayerActivity extends AppCompatActivity
drmSessionManager = DrmSessionManager.getDummyDrmSessionManager(); drmSessionManager = DrmSessionManager.getDummyDrmSessionManager();
} else if (Util.SDK_INT < 18) { } else if (Util.SDK_INT < 18) {
errorStringId = R.string.error_drm_unsupported_before_api_18; errorStringId = R.string.error_drm_unsupported_before_api_18;
} else if (!MediaDrm.isCryptoSchemeSupported(drmInfo.drmScheme)) { } else if (!FrameworkMediaDrm.isCryptoSchemeSupported(drmInfo.drmScheme)) {
errorStringId = R.string.error_drm_unsupported_scheme; errorStringId = R.string.error_drm_unsupported_scheme;
} else { } else {
MediaDrmCallback mediaDrmCallback = MediaDrmCallback mediaDrmCallback =

View File

@ -75,6 +75,15 @@ public final class FrameworkMediaDrm implements ExoMediaDrm<FrameworkMediaCrypto
private final MediaDrm mediaDrm; private final MediaDrm mediaDrm;
private int referenceCount; private int referenceCount;
/**
* Returns whether the DRM scheme with the given UUID is supported on this device.
*
* @see MediaDrm#isCryptoSchemeSupported(UUID)
*/
public static boolean isCryptoSchemeSupported(UUID uuid) {
return MediaDrm.isCryptoSchemeSupported(adjustUuid(uuid));
}
/** /**
* Creates an instance with an initial reference count of 1. {@link #release()} must be called on * Creates an instance with an initial reference count of 1. {@link #release()} must be called on
* the instance when it's no longer required. * the instance when it's no longer required.