Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android VideoView - Detect point of time in video

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

like image 526
Chris Avatar asked May 10 '10 04:05

Chris


1 Answers

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.

like image 185
CommonsWare Avatar answered Nov 01 '22 21:11

CommonsWare