我正在使用 media3 exo 播放器在 jetpack compsoe 中制作视频播放器。我面临的问题是,在水平选项卡模式下,我为播放器提供 16/9f 的宽高比,并为播放器定义了总屏幕宽度的 60%,因此默认控件应该在定义的 60% 宽度内可见,但是它们在屏幕末端或视频播放器定义区域之外可见。 我提到了我的问题的屏幕截图
AndroidView(
factory = {
PlayerView(context).apply {
useController = true
resizeMode = AspectRatioFrameLayout.RESIZE_MODE_FILL
player = exoPlayer
setShowBuffering(PlayerView.SHOW_BUFFERING_WHEN_PLAYING)
hideController()
setKeepContentOnPlayerReset(true)
setShowNextButton(false)
setShowPreviousButton(false)
setFullscreenButtonClickListener {
isFullscreen = !isFullscreen
setScreenValue()
handleFullscreen(isFullscreen, context)
}
controllerShowTimeoutMs = 2000
setControllerVisibilityListener(PlayerView.ControllerVisibilityListener { visibility ->
isControlVisible = visibility == View.VISIBLE
Log.i("fsdsdsdajsdfsdsdsdsdsdsdsdsdsdsdsdsdsdsd", "TravelxpPlayer: hello sid")
val selectedAudioLanguage = exoPlayer.audioFormat?.language
if (defLanguage != selectedAudioLanguage) {
defLanguage = selectedAudioLanguage
if (selectedAudioLanguage != null) {
coroutineScope.launch {
userStore.setLanguage(selectedAudioLanguage)
}
}
}
})
val progressBar = findViewById<ProgressBar>(R.id.exo_buffering)
progressBar.indeterminateDrawable.setTint(
ContextCompat.getColor(context, R.color.travelxp_red),
)
layoutParams = FrameLayout.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT
)
setShowSubtitleButton(true)
}
}, modifier = Modifier
.aspectRatio(aspectRatio)
.fillMaxHeight()
)```
layoutParams = FrameLayout.LayoutParams(
width = definedWidth, // specify the width that fits within 60% of the screen
height = ViewGroup.LayoutParams.WRAP_CONTENT
)
Modifier.padding(horizontal = paddingValue) // Adjust padding as needed
使用matchparent代替wrapcontent试试这个如果这可以帮助你
这个问题的出现是因为 exo 播放器使用默认视图