gpt4 book ai didi

Android VideoView 控件不显示

转载 作者:行者123 更新时间:2023-11-30 05:03:40 26 4
gpt4 key购买 nike

我有一个视频 View ,我希望能够播放/暂停和全屏显示。我无法让视频显示控件。

private fun showVideo() {
isLottieVisible = false
isImageViewVisible = false
isVideoVisible = true
val mediaController = MediaController(activityManager.currentActivity.window?.context!!)
mediaController.setAnchorView(anchorView)
mediaController.setMediaPlayer(videoView)
//mediaController.show()
videoView.setMediaController(mediaController)
videoView.keepScreenOn = true
videoView.setZOrderOnTop(true)
videoView.setVideoPath("https://i.imgur.com/EaEK5ZB.mp4")
videoView.requestFocus()
videoView.setOnPreparedListener {
it.isLooping = true
videoView.start()
mediaController.show()
}
}

最佳答案

我已经尝试运行您的代码,一切都按预期工作,但暂停/播放控制栏仅在单击视频后出现,这是预期的行为。我对您的代码所做的唯一编辑是注释行 //mediaController.setAnchorView(anchorView)

enter image description here

关于Android VideoView 控件不显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57773496/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com