开发者

MediaPlayer : How to update progress every second?

I'm programming a videoplayer program and i'm searching to see the way the progress bar and time got updated every second while mediaplayer is playing.

I have been looking at VideoView and MediaPlayer class , but i have no found if it use a hypothetically "OnEverySecondUpdate" Listener or whatever nice (or ugly开发者_StackOverflow) process to do it the good way.

Any idea?

P.D : I don't use a VideoView component , i'm using a SurfaceView .


Use Handler method: postDelayed. In runnable just put postDelayed again with second interval.


I found two relevant methods in MediaPlayer:

/**
     * Gets the current playback position.
     *
     * @return the current position in milliseconds
     */
    public native int getCurrentPosition();

    /**
     * Gets the duration of the file.
     *
     * @return the duration in milliseconds
     */
    public native int getDuration();

This is enough for u.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜