1

i've got this simple video stream player:

    if (play) {

                    myVideoView.stopPlayback();
                    myVideoView.clearFocus();
                    myVideoView = null;


                    button5.setText("Start");
                    play = false;
                } else {
//                  dialog = ProgressDialog.show(Main.this, "Feldolgozás",
//                          "A videó töltődik");
                    progressBar = new ProgressDialog(v.getContext());
                    progressBar.setCancelable(true);
                    progressBar.setMessage("A video töltődik ...");
                    progressBar.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
                    progressBar.setProgress(0);
                    progressBar.setMax(100);
                    progressBar.show();     

                    myVideoView = (VideoView) findViewById(R.id.myvideoview);
                    myVideoView.setVideoURI(Uri.parse(SrcPath));
                    RelativeLayout.LayoutParams videoviewlp = new RelativeLayout.LayoutParams(
                            500, 480);
                    videoviewlp.addRule(RelativeLayout.CENTER_HORIZONTAL,
                            RelativeLayout.TRUE);
                    videoviewlp.addRule(RelativeLayout.CENTER_VERTICAL,
                            RelativeLayout.TRUE);
                    myVideoView.setLayoutParams(videoviewlp);
                    myVideoView.invalidate();
                    myVideoView.requestFocus();

                    myVideoView.setOnPreparedListener(new OnPreparedListener() {

                        public void onPrepared(MediaPlayer mp) {
                            // mp.setOnCompletionListener(this);
                            mp.setOnBufferingUpdateListener(new OnBufferingUpdateListener() {
                                public void onBufferingUpdate(
                                        MediaPlayer mPlayer, int percent) {

                                    progressBar.setProgress(percent);

                                    if (percent == 100) {
                                        //dialog.dismiss();
                                        progressBar.dismiss();
                                        // Toast.makeText(getApplicationContext(),
                                        // "100%", Toast.LENGTH_LONG).show();
                                    }

                                }
                            });

                            mp.start();

                            // myVideoView.start();

                        }

                    }); 


                    play = true;
                    button5.setText("Stop");



                }
        }

How can i check if the video stream has ended or lost? If lost the button should change to start and stop the videoview... tanks for your aswers!

update: i think the problem is with the vlc rtsp stream because it says when the youtube rtsp is ended...

4

1 回答 1

1

您可以尝试使用以下侦听器VideoView

public void setOnCompletionListener (MediaPlayer.OnCompletionListener l)

注册在播放期间到达媒体文件末尾时调用的回调。

public void setOnErrorListener (MediaPlayer.OnErrorListener l)

注册在播放或设置期间发生错误时要调用的回调。如果没有指定监听器,或者监听器返回 false,VideoView 将通知用户任何错误。

更多信息

于 2013-05-16T15:25:18.287 回答