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

发布于 2024-09-01 02:14:28 字数 179 浏览 2 评论 0原文

我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

笑着哭最痛 2024-09-08 02:14:28

步骤#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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文