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 kim-vde
parent ad346fbdbe
commit 361e5d9326
3 changed files with 13 additions and 2 deletions

View File

@ -282,6 +282,8 @@
* Removed support for media tunneling * Removed support for media tunneling
* Removed support for random ABR (random track selection) * Removed support for random ABR (random track selection)
* Removed support for playing back in spherical stereo mode * Removed support for playing back in spherical stereo mode
* Fix playback of ClearKey protected content on API level 26 and earlier
([#7735](https://github.com/google/ExoPlayer/issues/7735)).
* Add Guava dependency. * Add Guava dependency.
### 2.11.7 (2020-06-29) ### ### 2.11.7 (2020-06-29) ###

View File

@ -19,7 +19,6 @@ import static com.google.android.exoplayer2.util.Assertions.checkNotNull;
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;
@ -41,6 +40,7 @@ import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.RenderersFactory; import com.google.android.exoplayer2.RenderersFactory;
import com.google.android.exoplayer2.SimpleExoPlayer; import com.google.android.exoplayer2.SimpleExoPlayer;
import com.google.android.exoplayer2.audio.AudioAttributes; import com.google.android.exoplayer2.audio.AudioAttributes;
import com.google.android.exoplayer2.drm.FrameworkMediaDrm;
import com.google.android.exoplayer2.ext.ima.ImaAdsLoader; import com.google.android.exoplayer2.ext.ima.ImaAdsLoader;
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;
@ -346,7 +346,7 @@ public class PlayerActivity extends AppCompatActivity
showToast(R.string.error_drm_unsupported_before_api_18); showToast(R.string.error_drm_unsupported_before_api_18);
finish(); finish();
return Collections.emptyList(); return Collections.emptyList();
} else if (!MediaDrm.isCryptoSchemeSupported(drmConfiguration.uuid)) { } else if (!FrameworkMediaDrm.isCryptoSchemeSupported(drmConfiguration.uuid)) {
showToast(R.string.error_drm_unsupported_scheme); showToast(R.string.error_drm_unsupported_scheme);
finish(); finish();
return Collections.emptyList(); return Collections.emptyList();

View File

@ -73,6 +73,15 @@ public final class FrameworkMediaDrm implements ExoMediaDrm {
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.