2

我正在编写一个视频播放器程序,我正在寻找在媒体播放器播放时进度条和时间每秒更新一次的方式。

我一直在研究 VideoView 和 MediaPlayer 类,但我没有发现它是否使用假设的“OnEverySecondUpdate”监听器或任何好的(或丑陋的)过程来做到这一点。

任何的想法?

PD:我不使用 VideoView 组件,我使用的是 SurfaceView。

4

2 回答 2

5

使用 Handler 方法:postDelayed。在 runnable 中,只需使用第二个间隔再次放置 postDelayed。

于 2011-09-27T13:22:10.583 回答
-1

我在 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();

这对你来说已经足够了。

于 2013-03-30T05:03:39.173 回答