VEX-6834: Android: Sometimes the player fails with RNV-3005 (#34)

Fix RNV-3005 errors when exiting the player and loading a new video immediately. In most cases this error was just happening internally and the user would not experience it, but it skewed the error rate reporting.
This commit is contained in:
Armands Malejev 2022-05-25 11:18:02 +03:00 committed by Armands Malejevs
parent d1c9490ce3
commit 33b7bf1ee1

View File

@ -1316,7 +1316,8 @@ class ReactExoplayerView extends FrameLayout implements
} else if(cause instanceof MediaDrmCallbackException || cause instanceof DrmSessionException) { } 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) { // DrmSessionExceptions can be caused by a lot internal reasons for failure, in most cases they can be safely retried and playback will recover
if (!hasDrmFailed || cause instanceof DrmSessionException) {
// When DRM fails to reach the app level certificate server it will fail with a source error so we assume that it is DRM related and try one more time // When DRM fails to reach the app level certificate server it will fail with a source error so we assume that it is DRM related and try one more time
hasDrmFailed = true; hasDrmFailed = true;
playerNeedsSource = true; playerNeedsSource = true;
@ -1403,7 +1404,6 @@ class ReactExoplayerView extends FrameLayout implements
public void setSrc(final Uri uri, final String extension, Map<String, String> headers) { public void setSrc(final Uri uri, final String extension, Map<String, String> headers) {
if (uri != null) { if (uri != null) {
boolean isSourceEqual = uri.equals(srcUri); boolean isSourceEqual = uri.equals(srcUri);
hasDrmFailed = false; hasDrmFailed = false;
this.srcUri = uri; this.srcUri = uri;
this.extension = extension; this.extension = extension;
@ -1440,7 +1440,6 @@ class ReactExoplayerView extends FrameLayout implements
public void setRawSrc(final Uri uri, final String extension) { public void setRawSrc(final Uri uri, final String extension) {
if (uri != null) { if (uri != null) {
boolean isSourceEqual = uri.equals(srcUri); boolean isSourceEqual = uri.equals(srcUri);
this.srcUri = uri; this.srcUri = uri;
this.extension = extension; this.extension = extension;
this.mediaDataSourceFactory = buildDataSourceFactory(true); this.mediaDataSourceFactory = buildDataSourceFactory(true);