2012-07-16 71 views
0

我試圖一個接一個地播放多個視頻(.mp4格式),使用VideoView.It可以在ICS上的Android平板電腦上正常播放,但會出現錯誤「對不起該視頻無法播放」錯誤我使用Android ICS在BeagleBoard硬件上運行它。logcat錯誤如下:BeagleBoard ICS上的VideoView錯誤

MediaPlayer(3151):error(1,-110). 
MediaPlayer(3151):error(1,-110). 
VideoView(3151):error(1,-110). 

> public class PlayVideoActivity extends Activity implements 
> OnCompletionListener { 
> 
> @Override protected void onCreate(Bundle savedInstanceState) { 
>  super.onCreate(savedInstanceState);   PowerManager pm = 
> (PowerManager) getSystemService(Context.POWER_SERVICE);  mWakeLock = 
> pm.newWakeLock(PowerManager.FULL_WAKE_LOCK | 
> PowerManager.ACQUIRE_CAUSES_WAKEUP, TAG);   mWakeLock.acquire(); 
>    setContentView(R.layout.playvideo);   videoView = (VideoView) findViewById(R.id.videoView); 
>  videoView.setOnCompletionListener(this); 
>  
>  mVideoLocalPathArrayList.add("/mnt/sdcard/downloads/mediabox/film.mp4"); 
>  mVideoLocalPathArrayList.add("/mnt/sdcard/downloads/mediabox/et.mp4"); 
>  mVideoLocalPathArrayList.add("/mnt/sdcard/downloads/mediabox/interview.mp4"); 
>    playListVideo(); } 
> 
> private void playListVideo() {  try { 
>    if (Util.CURRENT_VIDEO > 2) { 
>     Util.CURRENT_VIDEO = 0; 
>    } 
>    playVideo(mVideoLocalPathArrayList.get(Util.CURRENT_VIDEO));  } catch (Exception e) {  }  private void playVideo(String string) { 
>  mediaController = new MediaController(this); 
>  mediaController.setMediaPlayer(videoView); 
>  videoView.setMediaController(mediaController); 
>  //videoView.stopPlayback(); 
>  videoView.setVideoURI(Uri.parse(string)); 
>  videoView.requestFocus(); 
>  videoView.setMediaController(mediaController);  videoView.start(); 
> } 
> 
> @Override public void onCompletion(MediaPlayer arg0) {  finish(); 
>  Util.CURRENT_VIDEO++;  Intent intent = new Intent(this, 
> PlayVideoActivity.class);   startActivity(intent); } } 

任何建議都會有幫助。

+0

u能發佈完整的代碼,使其瞭解清楚? – AkashG 2012-07-16 07:39:28

+0

write videoView.reset();而不是videoView.stopPlayback();在我們的代碼 – AkashG 2012-07-16 07:44:36

+0

我已經添加了一些代碼。請檢查。 onCompletion上的 – 2012-07-16 07:44:47

回答

0

試試這個:

 videoView.setVideoURI(uri); 
     videoView.start(); 
     videoView.setOnCompletionListener(completionListener); 

OnCompletionListener這樣寫:

OnCompletionListener completionListener=new OnCompletionListener() { 

     public void onCompletion(MediaPlayer mp) { 
      mp.stop(); 
      Intent intent = new Intent(YourActivity.this, NewActivity.class); 
      startActivity(intent); 
     } 
    }; 
+0

這段代碼工作得很好。 – AkashG 2012-07-16 09:53:24

+0

我試過你的上述代碼,它可以在ICS平板電腦上正常工作,但不在BeagleBoard上。我仍然得到相同的錯誤。 – 2012-07-16 10:35:36