diff --git a/library/core/src/main/java/com/google/android/exoplayer2/upstream/LoadErrorHandlingPolicy.java b/library/core/src/main/java/com/google/android/exoplayer2/upstream/LoadErrorHandlingPolicy.java index ecf6e5744b..8d6c0b9cf1 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/upstream/LoadErrorHandlingPolicy.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/upstream/LoadErrorHandlingPolicy.java @@ -19,6 +19,7 @@ import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.ParserException; import com.google.android.exoplayer2.source.chunk.ChunkedTrackBlacklistUtil; import com.google.android.exoplayer2.upstream.HttpDataSource.InvalidResponseCodeException; +import com.google.android.exoplayer2.upstream.Loader.Callback; import com.google.android.exoplayer2.upstream.Loader.Loadable; import java.io.IOException; @@ -32,13 +33,17 @@ import java.io.IOException; * blacklisted. Blacklisting will succeed if any of the alternatives is not in the black list. * *

When blacklisting does not take place, {@link #getRetryDelayMsFor(T, long, IOException, int)} - * defines whether the load is retried. Loader clients define when to propagate retry attempt - * errors. Errors that are not retried are propagated. + * defines whether the load is retried. Errors whose load is not retried are propagated. Load errors + * whose load is retried are propagated according to {@link + * #getMinimumLoadableRetryCount(Loadable)}. * * @param The type of the object being loaded. */ public interface LoadErrorHandlingPolicy { + /** The default minimum number of times to retry loading data prior to propagating the error. */ + int DEFAULT_MIN_LOADABLE_RETRY_COUNT = 3; + /** Default implementation of {@link LoadErrorHandlingPolicy}. */ LoadErrorHandlingPolicy DEFAULT = new LoadErrorHandlingPolicy() { @@ -72,6 +77,12 @@ public interface LoadErrorHandlingPolicy { ? C.TIME_UNSET : Math.min((errorCount - 1) * 1000, 5000); } + + /** Returns {@link #DEFAULT_MIN_LOADABLE_RETRY_COUNT}. */ + @Override + public int getMinimumLoadableRetryCount(Loadable loadable) { + return DEFAULT_MIN_LOADABLE_RETRY_COUNT; + } }; /** Returns {@link #DEFAULT}. */ @@ -113,4 +124,15 @@ public interface LoadErrorHandlingPolicy { * C#TIME_UNSET} if the error is fatal and should not be retried. */ long getRetryDelayMsFor(T loadable, long loadDurationMs, IOException exception, int errorCount); + + /** + * Returns the minimum number of times to retry a load in the case of a load error, before + * propagating the error. + * + * @param loadable The loadable to load. + * @return The minimum number of times to retry a load in the case of a load error, before + * propagating the error. + * @see Loader#startLoading(Loadable, Callback, int) + */ + int getMinimumLoadableRetryCount(T loadable); }