0
public void playvideo()
{
    setContentView(R.layout.testvideo);  

    VideoView video = (VideoView)findViewById(R.id.videoView1);    
    String videoName = "testvideo" ;
    // You build the URI to your video here 
    StringBuilder uriPathBuilder = new StringBuilder (); 
    uriPathBuilder.append ("android.resource://"); 
    uriPathBuilder.append (this.getPackageName ()); 
    uriPathBuilder.append (File.separator); 
    uriPathBuilder.append ("raw"); 
    uriPathBuilder.append (File.separator); 
    uriPathBuilder.append (videoName); 
    Uri uri = Uri.parse (uriPathBuilder.toString ()); 

    video.setVideoURI (uri); 
    video.start ();    
}

这是播放测试视频的功能。单击按钮时调用此函数。视频播放完毕后,我想调用另一个函数。

4

2 回答 2

1

您可能正在寻找setOnCompletionListener.

video.setOnCompletionListener( new MediaPlayer.OnCompletionListener()
{
   public void onCompletion(MediaPlayer mp) 
        {
            // call some function
        }  
});
于 2012-05-02T14:04:46.760 回答
0

如果你想调用另一个函数,那么你可以覆盖

video.setOnCompletionListener(new MediaPlayer.OnCompletionListener(){});

每当您的视频完成时,它都会调用上述回调函数,您可以执行任何您想要的函数。

于 2012-05-02T14:06:36.547 回答