Android VideoView - 检测视频中的时间点
我正在使用 VideoView 来显示视频。我使用 setOnPreparedListener 和 setOnCompletionListener 在视频开始和结束之前和之后执行操作。
我想知道如何检测视频中的某个时间点。例如,假设我想在视频播放 10 秒时将日志写入文件。如何检测 10s 标记?
谢谢 克里斯
I am using a VideoView to display a video. I am using setOnPreparedListener and setOnCompletionListener to do stuff before and after the video starts and ends.
I was wondering how I could go about detecting some point of time in the video. For eg, say I want to write log to a file when the video has played for 10s. How can I detect the 10s mark?
Thanks
Chris
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
步骤#1:使用
postDelayed()
或其他东西来每秒左右获得控制权。步骤#2:检查
getCurrentPosition()
并查看它是否靠近您想要的标记点。如果是这样,请进行处理。步骤#3:起泡沫,冲洗,重复。
Android 没有任何机制可以在视频中发生某个时间点时专门调用您,因此您必须使用轮询机制。
Step #1: Use
postDelayed()
or something to get control every second or so.Step #2: Check
getCurrentPosition()
and see if it is near your desired marker point. If so, do your processing.Step #3: Lather, rinse, repeat.
There is no mechanism for Android to call into you specifically when a certain point in time has occurred in the video, so you have to make do with a polling mechanism.