Android VideoView,方向变化时无缝播放
我正在使用 VideoView 在我的应用程序中播放 mp4 文件。有没有办法保存所有缓冲的内容,以便当屏幕方向更改时,用户无需再等待 10 秒或更长时间视频即可再次开始播放。
也许“保存缓冲的视频”不是正确的解决方案,我只是在寻找一种在屏幕方向改变时使播放几乎无缝显示的方法。
我已经保存了视频定位并使用“seekTo”方法从视频停止的位置开始播放。但我也希望防止重新缓冲。我搜索了整个 stackoverflow,但找不到任何关于此的讨论。
谢谢!
布拉德利4
I'm using a VideoView to play a mp4 file in my application. Is there a way to save all the content that was buffered so when the orientation of the screen is changed the user doesn't have to wait another 10 seconds or more for the video to start playing again.
Perhaps "saving the buffered video" isn't the right solution, I'm just looking for a way to have the playback almost appear seamless when the orientation of the screen is changed.
I'm already saving the video positioning and using the "seekTo" method to start the video where it left off. But I'm looking to prevent the rebuffering as well. I searched all over stackoverflow and couldn't find any discussions on this.
Thanks!
Bradley4
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以自己处理配置更改,这样应用程序就不会重新启动。
另一种解决方案可能是将 VideoView 放入 Fragment 中。然后,您可以暂停视频,分离片段并在配置更改后重新附加,而不是用 Activity 杀死片段。虽然现在我想了一下,我认为 Fragment 也可能在配置更改时重新创建......
对您如何解决这个问题非常感兴趣,如果没有人回答,请发布您的解决方案。
You could handle the configuration change yourself so that the application isn't restarted.
Another solution might be to put the VideoView into a Fragment. Then rather than killing the Fragment with the Activity, you might just pause the video detach the Fragment and re-attach after the configuration change. Although now that I think about it, I think the Fragment may also be re-created on the configuration change...
Very interested in how you solve this, please post your solution if no one answers.