Listener (or handler) for video finish

前端 未结 5 2083
梦如初夏
梦如初夏 2020-12-05 22:33

I have implement the following code in order to test playing a video from a remote web server through it´s URL.

videoView = (VideoView)this.findViewById(R.id.         


        
相关标签:
5条回答
  • 2020-12-05 22:59
            vidView=(VideoView)findViewById(R.id.vidView);
        vidView.setMediaController(null);
        vidView.setVideoPath( "/mnt/external_sd/somerandommovie.3gp" );
        vidView.start();
    
        vidView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
    
            @Override
            public void onCompletion(MediaPlayer mp) {
                            vidView.start();
            }
        });
    

    I found that the listener was firing, the issue was mp.start() didn't seem to do anything, so calling start again on the original object seems to be working fine.

    0 讨论(0)
  • 2020-12-05 23:03

    here is my working chunk of code:

    mp.setOnCompletionListener(new MediaPlayer.OnCompletionListener() 
            {           
                public void onCompletion(MediaPlayer mp) 
                {
                    // Do whatever u need to do here
    
                }           
            });   
    
    0 讨论(0)
  • 2020-12-05 23:15

    Seems you are looking for

    setOnCompletionListener(MediaPlayer.OnCompletionListener l)
    

    More in depth explanation can be found here

    EDIT

    This shows a solution where playback is called after completion using VideoView, MediaController and setOnCompletionListener().

    0 讨论(0)
  • 2020-12-05 23:18

    in your onCompletion listener, try using videoView.start(); instead of mp.start();

    0 讨论(0)
  • 2020-12-05 23:19

    Make sure you are using the player on the main thread, it seems the callback only works on the main thread.

    0 讨论(0)
提交回复
热议问题