简体   繁体   English

Android VideoView-检测视频中的时间点

[英]Android VideoView - Detect point of time in video

I am using a VideoView to display a video. 我正在使用VideoView来显示视频。 I am using setOnPreparedListener and setOnCompletionListener to do stuff before and after the video starts and ends. 我正在使用setOnPreparedListener和setOnCompletionListener在视频开始和结束之前和之后进行操作。

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. 例如,假设我想在视频播放10秒后将日志写入文件。 How can I detect the 10s mark? 如何检测10s标记?

Thanks Chris 谢谢克里斯

Step #1: Use postDelayed() or something to get control every second or so. 步骤#1: postDelayed()使用postDelayed()或其他方式获得控制权。

Step #2: Check getCurrentPosition() and see if it is near your desired marker point. 步骤#2:检查getCurrentPosition() ,看看它是否在所需的标记点附近。 If so, do your processing. 如果是这样,请进行处理。

Step #3: Lather, rinse, repeat. 步骤#3:起泡,冲洗,重复。

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. 当视频中发生某个特定时间点时,没有专门的机制可让Android来调用您,因此您必须采用轮询机制。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM