我想为exoplayer实现自定义加载错误处理策略。在媒体上,我发现this很棒的文章,向我介绍了如何构建自定义错误处理策略。现在我被实现困住了getRetryDelayMsFor(dataType: Int, loadDurationMs: Long, exception: IOException?, errorCount: Int)方法。

我不明白我必须在SomeNetworkExceptionNoConnectivityException上捕获哪个异常

是否有人也实现了自定义的加载错误处理程序,并会与我分享他的知识?

最佳答案

检查HttpDataSource.HttpDataSourceException方法内的getRetryDelayMsFor,例如:

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.
    }
}

10-07 20:04
查看更多