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.
This commit is contained in:
Armands Malejev 2022-04-26 02:44:37 +03:00 committed by GitHub
parent 6815044013
commit f6e9cc8502
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -34,6 +34,7 @@ import com.google.android.exoplayer2.DefaultLoadControl;
import com.google.android.exoplayer2.DefaultRenderersFactory; import com.google.android.exoplayer2.DefaultRenderersFactory;
import com.google.android.exoplayer2.ExoPlaybackException; import com.google.android.exoplayer2.ExoPlaybackException;
import com.google.android.exoplayer2.drm.MediaDrmCallbackException; 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.ExoPlayerFactory;
import com.google.android.exoplayer2.Format; import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.PlaybackParameters; import com.google.android.exoplayer2.PlaybackParameters;
@ -1291,7 +1292,7 @@ class ReactExoplayerView extends FrameLayout implements
if (cause instanceof DefaultDrmSessionManager.MissingSchemeDataException) { if (cause instanceof DefaultDrmSessionManager.MissingSchemeDataException) {
errorCode = "3004"; errorCode = "3004";
errorString = getResources().getString(R.string.unrecognized_media_format); errorString = getResources().getString(R.string.unrecognized_media_format);
} else if(cause instanceof MediaDrmCallbackException) { } else if(cause instanceof MediaDrmCallbackException || cause instanceof DrmSessionException) {
errorCode = "3005"; errorCode = "3005";
errorString = getResources().getString(R.string.unrecognized_media_format); errorString = getResources().getString(R.string.unrecognized_media_format);
if (!hasDrmFailed) { if (!hasDrmFailed) {
@ -1300,6 +1301,7 @@ class ReactExoplayerView extends FrameLayout implements
playerNeedsSource = true; playerNeedsSource = true;
updateResumePosition(); updateResumePosition();
initializePlayer(); initializePlayer();
setPlayWhenReady(true);
return; return;
} }
} else { } else {
@ -1317,6 +1319,7 @@ class ReactExoplayerView extends FrameLayout implements
playerNeedsSource = true; playerNeedsSource = true;
updateResumePosition(); updateResumePosition();
initializePlayer(); initializePlayer();
setPlayWhenReady(true);
return; return;
} }
} }
@ -1374,6 +1377,7 @@ class ReactExoplayerView extends FrameLayout implements
if (uri != null) { if (uri != null) {
boolean isSourceEqual = uri.equals(srcUri); boolean isSourceEqual = uri.equals(srcUri);
hasDrmFailed = false;
this.srcUri = uri; this.srcUri = uri;
this.extension = extension; this.extension = extension;
this.requestHeaders = headers; this.requestHeaders = headers;