android:视频观看历史记录/书签
我有一个视频播放器应用程序。假设用户已经播放了一个视频,并且在播放了一半视频后,用户按下了后退按钮或退出了应用程序。我希望记住该位置,以便用户下次播放相同的视频时,视频会从与左侧完全相同的位置开始。
这方面有什么想法吗? 非常感谢
I have a videoplayer application. Suppose the user has played a video and after playing half of the video, the user pressed the back button or exists the application. I want that position to be remembered so that the next time, the user plays the same video, the video starts from exactly the same position from where it was left.
Any ideas in this regard?
Thanks much
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,您需要将这些数据存储在某个数据库中,但这非常简单。
现在,您应该在 Activity 的
onPause()
或onDestroy()
方法中添加一个检查,该方法从 videoview 获取位置:当您播放视频时,设置之前存储的当前位置:
First, you will need to store this data in some database, but it's quite simple.
Now, you should add a check in the
onPause()
oronDestroy()
method of your activity, which gets the position from the videoview:When you play a video, set the current position as stored before: