Android VideoView播放视频,提示加载框ProgressBar的问题?

浏览:23日期:2022-11-27

问题描述

我用VideoView播放视频,因为是加载网络视频么,等一会才能加载出来,我想加个加载框ProgressBar来提醒用户等待,我利用Handle每隔半秒就检测视频是否isPlaying中,但是没效果,网上也有用setOnInfoListener这个接口来控制,但是我试过了 没反应。有哪位大神做过类似的程序吗?可否告知一下?谢谢这是我的代码:

public class PlayVideoActivity extends CommonActivity{ @Bind(R.id.playVideo_vv) VideoView playVideoVv; @Bind(R.id.pb) ProgressBar pb; private String videoPath; @Override protected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.playvideoactivity);ButterKnife.bind(this);initView(); } Handler handler=new Handler(); Runnable runnable=new Runnable() {@Overridepublic void run(){ if (playVideoVv.isPlaying()) {pb.setVisibility(View.GONE); }else{pb.setVisibility(View.VISIBLE); } handler.postDelayed(runnable,500);} }; private void initView() {pb.setVisibility(View.VISIBLE);videoPath=getIntent().getStringExtra('videoPath');playVideoVv.setVideoPath(videoPath);MediaController mediaController = new MediaController(this,false);// 设置VideView与MediaController建立关联playVideoVv.setMediaController(mediaController);// 设置MediaController与VideView建立关联mediaController.setMediaPlayer(playVideoVv);// 让VideoView获取焦点playVideoVv.requestFocus();playVideoVv.start(); }}

问题解答

回答1:

你为什么不用 onpreparedlistener

回答2:

没看到你的线程调用代码

相关文章: