Android的VideoView - 检测视频中的时间点 [英] Android VideoView - Detect point of time in video
问题描述
我使用的是VideoView显示视频。我使用西顿preparedListener和setOnCompletionListener前后的视频开始和结束后做的东西。
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.
我想知道我怎么能去检测一些时间点的视频。对于例如,说我想要写日志到文件时的视频已经打了10秒。我怎样才能检测出10秒大关?
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?
谢谢 克里斯
推荐答案
第1步:使用 postDelayed()
或有所收获控制每一秒左右
Step #1: Use postDelayed()
or something to get control every second or so.
步骤#2:检查 getCurrentPosition()
键,看看是不是靠近你想要的标记点。如果是这样,你的处理。
Step #2: Check getCurrentPosition()
and see if it is near your desired marker point. If so, do your processing.
第三步:车床,漂洗,重复
Step #3: Lather, rinse, repeat.
没有任何机制为Android调入您特别是当一个特定的时间点出现在视频中,所以你必须凑合着用轮询机制。
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的VideoView - 检测视频中的时间点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!