Android Native Video player with subtitles

后端 未结 2 769
旧时难觅i
旧时难觅i 2021-02-06 12:36

I\'m currently developing a video player for android. I\'ve created a simple textview that shows the current subtitle.

The problem is: MediaPlayer getCu

2条回答
  •  心在旅途
    2021-02-06 13:34

    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:

    1. Ask the mediaplayer for current seconds (got s seconds)
    2. Ask the mediaplayer for current seconds until result is s+1 (s0)
    3. Get the system time (milliseconds) for that time (m0)

    Now, if I want the current movie milliseconds:

    1. Get the current system time (millisecons) (m1)
    2. Movie real time is: s0+(m1-m0)

    Easy, and resulted in synchronized subtitles ;)

提交回复
热议问题