我想为 exoplayer 实现自定义加载错误处理策略。在媒体上我找到了this很棒的文章,介绍了如何构建我的自定义错误处理警察。现在我坚持执行
getRetryDelayMsFor(dataType: Int, loadDurationMs: Long, exception: IOException?, errorCount: Int)
方法。
我不明白我必须在 SomeNetworkException
和 NoConnectivityException
上捕获哪个异常
是否有人也实现了自定义加载错误处理程序并且会与我分享他们的知识?
最佳答案
在 getRetryDelayMsFor
方法中检查 HttpDataSource.HttpDataSourceException
:
public long getRetryDelayMsFor(int dataType, long loadDurationMs, IOException exception, int errorCount) {
// checking if it is a connectivity issue
if (exception instanceof HttpDataSource.HttpDataSourceException) {
return 5000; // Retry every 5 seconds.
} else {
return C.TIME_UNSET; // Anything else is surfaced.
}
}
关于android - 如何为 exoplayer 实现自定义 LoadErrorHandlingPolicy,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54746707/