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

ExoPlayer在Kotlin Compose中视频宽度拉伸问题求助

ExoPlayer在Kotlin Compose中视频拉伸问题

我正在开发一款Android应用,需使用AspectRatioFrameLayout.RESIZE_MODE_ZOOM让视频铺满屏幕,但在Pixel 7a(Android 14)真机和模拟器上,视频宽度出现拉伸。切换至RESIZE_MODE_FIXED_HEIGHT后问题仍存在。

  • 应用退至后台再从最近应用打开时,视频显示恢复正常
  • 使用Android View系统而非Kotlin Compose时无此Bug

相关代码

ExoplayerscalingproblemTheme {
    // A surface container using the 'background' color from the theme
    Surface(modifier = Modifier.fillMaxSize(), color = MaterialTheme.colorScheme.background) {
        BoxWithConstraints(modifier = Modifier.fillMaxSize()) {
            AndroidView(
                modifier = Modifier.fillMaxSize(),
                factory = {
                    PlayerView(it).apply {
                        layoutParams = ViewGroup.LayoutParams(
                            ViewGroup.LayoutParams.MATCH_PARENT,
                            ViewGroup.LayoutParams.MATCH_PARENT,
                        )
                        this.useController = false
                        setKeepContentOnPlayerReset(true)
                        this.resizeMode = AspectRatioFrameLayout.RESIZE_MODE_ZOOM
                    }
                },
                update = {
                    it.player = exoPlayer
                }
            )
        }
    }
}

问题截图

当前异常显示:
当前异常显示

期望正常显示:
期望正常显示

已创建仓库用于复现该问题,另有使用Android View而非Compose的分支。

恳请各位提供技术帮助,感谢!

内容的提问来源于stack exchange,提问作者H.Taras

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.25 11:52:18