I am following this tutorial to implement the Exoplayer. But the ExtractorMediaSource class is deprecated. I need to play video from a remote url. What is the alternative to use in this situation?

val mediaSource = ExtractorMediaSource
  .Factory(DefaultDataSourceFactory(context, userAgent))
  .setExtractorsFactory(DefaultExtractorsFactory())
  .createMediaSource(Uri.parse(url))

推荐答案

您使用的是2.10.0版或更高版本的ExoPlayer吗?然后,用ProgressiveMediaSource代替ExtractorMediaSource(Reference Release Note)

Kotlin相关问答推荐

在没有外部 map 的情况下转换列表项

何时使用figureEach

Kotlin:类型不匹配:推断的类型已运行,但应等待

如何将 `when` 与 2 个密封类一起使用并获取内部值?

如何在 Spring Boot 3 中为内部类提供运行时提示

如何使用 Firebase 和 Kotlin 在文本 (Jetpack Compose) 中显示当前用户名?

Kotlin 中私有集的完整语法 struct 是什么?

使用 LazyListScope 嵌套可组合项

基类中的 ViewModelProviders.get(...)

Kotlin 协程中的 Dispatchers.Main 和 Dispatchers.Default 有什么区别?

Kotlin boxed Int 不一样

如何用 kotlin 打包 List

Hilt Activity 必须附加到 @AndroidEntryPoint 应用程序

Kotlin:找不到符号类片段或其他 android 类

将协同路由调用放在存储库或ViewModel中哪个更好?

如何在 Kotlin 中传递有界通配符类型参数?

Android 上的 Kotlin:将map到list

如何限制kotlin协程的最大并发性

uses-sdk:minSdkVersion 16 不能小于库中声明的版本 23

Kotlin:获取文件的扩展名,例如.txt