开发者

How can I perform an action at a certain point in time during a video in Android?

I am creating a program which requires me to change a setting in the program when the video reaches specific points (at 1/3 of the video's completion, 2/3's and on completion). Android has a built in callback method for com开发者_Python百科pletion so performing an action at that point in time is not difficult. However, I don't know how to go about checking when the video has reached 1/3 and 2/3's of completion.


Using a MediaPlayer control you will get the total duration of your media file in milliseconds:

 myMediaPlayer.getDuration()

you will implement a thread that check every second for the current position at 1/3, 2/3 and 3/3 of the videos completion, with

myMediaPlayer.getCurrentPosition(); //***current Position in milliseconds.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜