Android VideoView的resume和seekTo
我正在我的应用程序中使用 VideoView 播放视频。单击按钮后,它会记录视频的当前位置,然后应用程序会打开浏览器并显示一些网址。按下后退按钮后,应用程序将返回视频应用程序并从中断处恢复视频。
我查看了 Android Activity 生命周期,发现一旦视频 Activity 进入前台,就会调用 onStart() 方法。因此,我在 onStart() 中创建布局并通过查找当前位置来播放视频。
我的问题是,当视频恢复时,它从一开始就缓冲,然后寻找。既然它已经第一次缓冲了,有没有办法在执行seekTo时再次消除缓冲?
谢谢 克里斯
I am playing a Video using a VideoView in my app. On the click of a button, it records the current position of the video, and the app opens up the browser with some url. On pressing the back button, the app comes back to video app and resumes the video from where it left off.
I looked at the Android Activity lifecycle and saw that onStart() method gets called once the video activity comes to the foreground. So I am creating my layout in onStart() and playing the video by seeking to the current position.
My problem is that when the video resumes, it buffers from the start and then seeks to. Since it already buffered the first time, is there a way to eliminate buffering again while doing a seekTo?
Thanks
Chris
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我有类似的问题。我有一个 OnPreparedListener 在开始之前执行seekTo。除了视频开头出现音频故障外,seekTo 可以正常工作,就好像视频开始播放然后进行搜索一样。我不知道我的代码是否有助于解决所描述的缓冲问题,但它可能有助于阐明它。
I am having a similar problem. I have an OnPreparedListener that does the seekTo prior to the start. The seekTo works except that there is an audio glitch that is coming from the very beginning of the video, as if it is starting to play and then seeking. I don't know if my code would help the buffering problem described but it may help illuminate it.
代码
定义您的资源视频视图,然后使用您必须添加的
.setMediaController(new MediaController(this));
希望
在使用PrepareListener之前
它能帮助你
Define your Resource videoview then use this code
you have to add
.setMediaController(new MediaController(this));
and
before using the PrepareListener
hope it will help you