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...

David
  • 2,331
  • 4
  • 29
  • 42

1 Answers1

1

You could try using the following listeners of VideoView:

public void setOnCompletionListener (MediaPlayer.OnCompletionListener l)

Register a callback to be invoked when the end of a media file has been reached during playback.

public void setOnErrorListener (MediaPlayer.OnErrorListener l)

Register a callback to be invoked when an error occurs during playback or setup. If no listener is specified, or if the listener returned false, VideoView will inform the user of any errors.

More Information

Filipe Batista
  • 1,862
  • 2
  • 24
  • 39