隐藏视频但继续播放
我有一个图像和一个视频播放器。在肖像中,它显示了两者。左边做横向,只是视频显示。正确处理风景,如图所示。
我现在正在使用 setVisibility() 方法来实现这一点。这样做的问题:
myVideoView.setVisibility(View.INVISIBLE);
导致视频停止播放。有没有办法让它继续播放但又对用户不可见?也许将 VideoView 的不透明度设置为 0?
I have an image and a video player. In portrait, it shows both. Doing landscape left, just the video shows. Doing landscape right just the image shows.
I am using the setVisibility()
method right now to achieve that. The problem with doing:
myVideoView.setVisibility(View.INVISIBLE);
causes the video to stop playing. Is there a way to keep it playing but also not visible to the user? Maybe like set the opacity of the VideoView to 0?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我想我在这里找到了解决方案。为了使 videoview 不可见并保持其播放声音,您只需通过设置 alpha 值将其隐藏即可。
希望它对你有用!
I think I found a solution here. In order to make videoview invisible and keep it playing sound you simply hide it by setting alpha value.
Hope it works for you!
您可以尝试使用
bringToFront()
方法更改视图的 z 顺序。如果您希望显示视频,请调用
mVideoView.bringToFront()
,当您希望显示图像时,可以使用mImageView.bringToFront()
这应该可以工作,只要视频和图像在屏幕上占据相同的空间。祝你好运
You could try changing the z-order of the views with the
bringToFront()
method.If you want the video to show then call
mVideoView.bringToFront()
and when you want the image to show you could usemImageView.bringToFront()
this should work as long as the video and the image both occupy the same space on the screen.Good luck