I’m currently developing a video player for android. I’ve created a simple textview that shows the current subtitle.
The problem is: MediaPlayer getCurrentPosition() method only gives me time in seconds. And I need that value in milliseconds to correctly synchronize the subtitle with the movie.
The getCurrentPosition is supposed to give me the time in milliseconds, but it gives the time in seconds*1000 (every number ends with “000”).
- Do you know a better way of doing this?
- How do I get the time in milliseconds?
- Generating an event exactly at the time of second (000ms) would also work.
Any suggestions?
In case anyone needs, I did my solution.
I developed the subtitles module.
To get the accurate milliseconds, I made a synchronizer for system and player timers.
Every 20 seconds of video playback I do this procedure:
Now, if I want the current movie milliseconds:
Easy, and resulted in synchronized subtitles 😉