android - 如何为 exoplayer 实现自定义 LoadErrorHandlingPolicy

标签 android error-handling exoplayer

我想为 exoplayer 实现自定义加载错误处理策略。在媒体上我找到了this很棒的文章,介绍了如何构建我的自定义错误处理警察。现在我坚持执行 getRetryDelayMsFor(dataType: Int, loadDurationMs: Long, exception: IOException?, errorCount: Int) 方法。

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

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

最佳答案

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/

相关文章:

android - 无法编译 ThreeTenABP

ios - 无法将类型 'String!' 的值转换为预期的参数类型错误

android - 使用 ExoPlayer 播放本地 aes128 cbc 加密的 mp3

java - 在android项目中导入和使用jar文件

android - (FrameLayout)findViewById(...) 给出 null

android - 如何以编程方式取消设置默认主屏幕?

error-handling - 如何使用 $util.error 在 AppSync 中发送自定义错误

node.js - 如何使用域来处理 Node js 应用程序中的异常

android - 在 ExoPlayer 上快速搜索

android - Phonegap/Cordova - 构建 Apk