5

我有以下工作代码:

@Override
        protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        this.setContentView(R.layout.player);

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

        // video finish listener
        videoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {

                @Override
                public void onCompletion(MediaPlayer mp) {
                        mp.start();
                }
        });
    }

    public void playVideo() {
                MediaController mc = new MediaController(this);
                videoView.setMediaController(mc);
                videoView.setVideoURI(Uri.parse("http://sayedhashimi.com/downloads/android/movie.mp4"));
                videoView.requestFocus(); 
        }

我只想在视频结束时更改 MediaPlayer 数据源(setOnCompletionListener)。

4

1 回答 1

9

我正在处理同样的问题。这是我想出的:

   public void onCompletion(MediaPlayer mp) {
       mp.reset();
       mp.setDataSource(this, newUri);
       mp.start();
   }
于 2011-08-30T13:47:06.967 回答