From f6e9cc850215aa058c81b7452f7592e4cd57fb72 Mon Sep 17 00:00:00 2001 From: Armands Malejev Date: Tue, 26 Apr 2022 02:44:37 +0300 Subject: [PATCH] VEX-6891: Android: Infinite loading when closing & reopening the player on low end devices (#27) On low end devices when replaying same content too quickly DRM could fail with an uncaptured error (DrmSessionException). To prevent this we now check for that error and retry DRM one more time. --- .../java/com/brentvatne/exoplayer/ReactExoplayerView.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java b/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java index b86deacb..15526b27 100644 --- a/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java +++ b/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java @@ -34,6 +34,7 @@ import com.google.android.exoplayer2.DefaultLoadControl; import com.google.android.exoplayer2.DefaultRenderersFactory; import com.google.android.exoplayer2.ExoPlaybackException; import com.google.android.exoplayer2.drm.MediaDrmCallbackException; +import com.google.android.exoplayer2.drm.DrmSession.DrmSessionException; import com.google.android.exoplayer2.ExoPlayerFactory; import com.google.android.exoplayer2.Format; import com.google.android.exoplayer2.PlaybackParameters; @@ -1291,7 +1292,7 @@ class ReactExoplayerView extends FrameLayout implements if (cause instanceof DefaultDrmSessionManager.MissingSchemeDataException) { errorCode = "3004"; errorString = getResources().getString(R.string.unrecognized_media_format); - } else if(cause instanceof MediaDrmCallbackException) { + } else if(cause instanceof MediaDrmCallbackException || cause instanceof DrmSessionException) { errorCode = "3005"; errorString = getResources().getString(R.string.unrecognized_media_format); if (!hasDrmFailed) { @@ -1300,6 +1301,7 @@ class ReactExoplayerView extends FrameLayout implements playerNeedsSource = true; updateResumePosition(); initializePlayer(); + setPlayWhenReady(true); return; } } else { @@ -1317,6 +1319,7 @@ class ReactExoplayerView extends FrameLayout implements playerNeedsSource = true; updateResumePosition(); initializePlayer(); + setPlayWhenReady(true); return; } } @@ -1373,7 +1376,8 @@ class ReactExoplayerView extends FrameLayout implements public void setSrc(final Uri uri, final String extension, Map headers) { if (uri != null) { boolean isSourceEqual = uri.equals(srcUri); - + + hasDrmFailed = false; this.srcUri = uri; this.extension = extension; this.requestHeaders = headers;