Skip to content

Commit

Permalink
VEX-6891: Android: Infinite loading when closing & reopening the play…
Browse files Browse the repository at this point in the history
…er 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.
  • Loading branch information
armands-malejevs authored Apr 25, 2022
1 parent 6815044 commit f6e9cc8
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
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;
Expand Down Expand Up @@ -1291,7 +1292,7 @@ else if (e.type == ExoPlaybackException.TYPE_SOURCE) {
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) {
Expand All @@ -1300,6 +1301,7 @@ else if (e.type == ExoPlaybackException.TYPE_SOURCE) {
playerNeedsSource = true;
updateResumePosition();
initializePlayer();
setPlayWhenReady(true);
return;
}
} else {
Expand All @@ -1317,6 +1319,7 @@ else if (e.type == ExoPlaybackException.TYPE_SOURCE) {
playerNeedsSource = true;
updateResumePosition();
initializePlayer();
setPlayWhenReady(true);
return;
}
}
Expand Down Expand Up @@ -1373,7 +1376,8 @@ public void onMetadata(Metadata metadata) {
public void setSrc(final Uri uri, final String extension, Map<String, String> headers) {
if (uri != null) {
boolean isSourceEqual = uri.equals(srcUri);


hasDrmFailed = false;
this.srcUri = uri;
this.extension = extension;
this.requestHeaders = headers;
Expand Down

0 comments on commit f6e9cc8

Please sign in to comment.