You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Android API 30+版本中ExoPlayer在Compose重组时抖动严重问题求助

Android API 30+版本中ExoPlayer在Compose重组时抖动严重问题求助

各位好,我最近在项目里用ExoPlayer配合Jetpack Compose做视频播放时碰到了个棘手问题:我在不同API等级的设备上都做了测试,只有API 30及以上版本会出现视频播放抖动严重的情况,API 30以下的版本完全正常。而且不管是模拟器还是物理真机,这个问题都存在。

下面是我项目里关于ExoPlayer的相关代码,麻烦帮忙看看有没有哪里疏漏:

首先是依赖配置(使用Media3版本):

[versions]
exoplayer = "1.3.1"

[libraries]
androidx-media3-ui = { module = "androidx.media3:media3-ui", version.ref = "exoplayer" }
androidx-media3-exoplayer = { module = "androidx.media3:media3-exoplayer", version.ref = "exoplayer" }

然后是ViewModel里的Player初始化逻辑:

@HiltViewModel
class NotesViewModel @Inject constructor(
    @ApplicationContext val context: Context,
) : ViewModel() {
    val player: Player = buildPlayer(context).apply {
        repeatMode = Player.REPEAT_MODE_ONE
        prepare()
    }

}

Compose UI部分的调用代码:

val viewModel: NotesViewModel = hiltViewModel()
val player = remember { viewModel.player }
VideoPlayer(
    player = player,
    isPlaying = uiState.isVideoPlaying,
    onPlayClicked = viewModel::playVideo,
)

@OptIn(UnstableApi::class)
// 这里是VideoPlayer自定义组件的实现代码

有没有大佬遇到过类似的问题?或者能从我的代码里看出什么潜在问题吗?感谢各位的帮助!

备注:内容来源于stack exchange,提问作者ObeyMeee

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.16 11:58:09