2013-08-06 58 views
2

我将视频网址存储在一个数组中。我只想播放该阵列中的所有视频。如何播放所有在线视频

我的Java代码:

public void video_play(){ 

    VideoView vview= (VideoView)findViewById(R.id.vview); 
    vview.setVideoURI(Uri.parse(prepare.txtLectureFileName[index_value])); 
    vview.setMediaController(new MediaController(this)); 
    vview.requestFocus(); 
    vview.start(); 

    if(index_val>=no_of_videos){ 
     Toast.makeText(getApplicationContext(), "Videos are finished", Toast.LENGTH_SHORT).show(); 
    } 
    else{ 
     video_play(); 
    } 
} 

我也尝试实施onCompleteListener并创建了一个方法onCompletion()。 但是毫无效果,请帮我家伙...

回答

4

嘿尝试这是为我工作:

public void video_play(){ 

      VideoView vview= (VideoView)findViewById(R.id.vview); 
      vview.setVideoURI(Uri.parse(prepare.txtLectureFileName[index_value])); 
      vview.setMediaController(new MediaController(this)); 
      vview.requestFocus(); 
      vview.start(); 
      if(index_val>=no_of_videos){ 
       Toast.makeText(getApplicationContext(), "Videos are finished", Toast.LENGTH_SHORT).show(); 
      } 
      else{ 
       video_play(); 
      } 
      vview.setOnCompletionListener(new MediaPlayer.OnCompletionListener() { 
      @Override 
      public void onCompletion (MediaPlayer mp) { 
       index_value++; 
       video_play(); 
      } 
     }); 
} 
+0

感谢ü哥们它的工作... – user2656591