문제

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

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top