android - Android exoplayer v2.11.5 & v2.13.2 UI 延迟时调用准备
问题描述
在我的应用程序中,我正在构建一个视频播放工具,用户可以在其中从 recyclerview 中选择和播放不同的视频。我注意到,在 ExoPlayer 的 v2.11.5 和 v2.13.2 版本中,一旦我调用方法准备,UI 就会滞后。我尝试将其注释掉,并且日志猫显示没有 GC 提要(AllocSpace 对象)。我还尝试在 ExoPlayer 上设置 setLoadControl() 方法,但效果不佳。调用准备好的方法后,有什么方法可以消除滞后。您可以在下面找到启动视频的代码。
fun prepareSource(source: String) {
if (source.isBlank() || this.mSource == source) return
mSource = source
onLoading.value = true
val hlsMediaSource: HlsMediaSource = HlsMediaSource.Factory(dataSourceFactory)
.setAllowChunklessPreparation(true)
. createMediaSource(MediaItem.fromUri(source))
player.setMediaSource(hlsMediaSource)
// player.prepare() -> This method causes the UI to freeze, commenting it out the UI works as excepted
// emit default values
onPlaybackSpeed.value = Global.PLAYER_DEFAULT_PLAYBACK_SPEED
onVolume.value = Global.PLAYER_DEFAULT_VOLUME
}
解决方案
推荐阅读
- php - Laravel 电子邮件刀片模板路由不起作用
- angular - 使用 Angular 构建的 Outlook 插件在 1903 版之前的 Windows Outlook App 上显示空白屏幕
- amazon-web-services - AWS Eventbridge 事件未触发 Lambda 函数
- c# - 来自调用者 Xamarin 的 BindingContext
- javascript - Puppeteer pdf 分页错误
- python - Mosek 不可行性报告支持的问题类型
- javascript - 打字稿省略getter setter readOnly for Partial数据?
- c++ - 这个文件创建代码不起作用请帮助我
- flutter - 如何在 Flutter 中对齐步进器和文本?
- .htaccess - htaccess rewritecondition 具有多种语言的多个 TLD