首先我们需要实例化一个子线程,能后实时的更新SeekBar的进度方法如下:
首先在Actvity里面 实例化一个子线程
//视频进度条更新 class VideoThreed extends Thread { public void run() { while (!Thread.currentThread().isInterrupted()) { // 正在播放的时间和 总时长 if (mediaPlayer.getCurrentPosition() == mediaPlayer。getp=Position) { return; } Message message = new Message(); message.what = PROGRESS_CHANGED; myHandler.sendMessage(message); try { Thread.sleep(1000); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } } } }
然后我们需要起一个handler来实时的更新UI:
//更新UI Handler myHandler = new Handler() { public void handleMessage(Message msg) { switch (msg.what) { case PROGRESS_CHANGED: