android videoView 加载等待

final Handler handler = new Handler();
Runnable runnable = new Runnable() {
    public void run() {
        int duration = mVideoView.getCurrentPosition();
        if(mVideoView.isPlaying()){
            if (old_duration == duration) {
                mProgressBar.setVisibility(View.VISIBLE);
            } else {
                mProgressBar.setVisibility(View.GONE);
            }
        }
        old_duration = duration;
        handler.postDelayed(runnable, 500);
    }
};
handler.postDelayed(runnable, 0);

 

//关闭activity时销毁检测线程
@Override
protected void onDestroy() { handler.removeCallbacks(runnable); super.onDestroy(); }

 

posted @ 2017-09-06 11:44  荣超  阅读(1490)  评论(0编辑  收藏  举报