2010-07-01 75 views
1

我正在嘗試將視頻流式傳輸到VideoView上的Android(使用Eclipse和SDK)。有時候視頻會起作用,但有時我會看到視頻無法顯示的錯誤。這裏是代碼:視頻無法正常顯示

//video 

    private Uri mPath; 

private VideoView mVid; 

    mPath = Uri.parse("android.resource://com.accuweather.wordweather/" + R.raw.b2); 

    mVid.setVideoURI(mPath); 

    mVid.requestFocus(); 

    mVid.start(); 

另一個類,當用戶滾動屏幕時加載不同的視頻。

public void onScrollViewSnap(int page) { 
    //change video 
    Log.d(DEB_TAG, "In 'onPageCountChange: '." + page); 
    //video 

    if(page != mOnPage){ 
     if(page == 0){ 
      mPath = Uri.parse("http://www.ted.com/talks/download/video/8584/talk/761"); 
      //mPath = Uri.parse("android.resource://com.accuweather.wordweather/" + R.raw.w2); 
     }else if(page == 1){ 
      mPath = Uri.parse("android.resource://com.accuweather.wordweather/" + R.raw.b1); 
     }else if(page == 2){ 
      mPath = Uri.parse("http://commonsware.com/misc/test2.3gp"); 
      //mPath = Uri.parse("android.resource://com.accuweather.wordweather/" + R.raw.test2); 
     } 
     if(mVid.isPlaying() == true){ 
      mVid.stopPlayback(); 
     } 
     mVid.setVideoURI(mPath); 
     mVid.requestFocus(); 
     mVid.start(); 
     Log.d(DEB_TAG, "THIS IS THE HEIGHT: " + mVid.getMeasuredHeight()); 
     Log.d(DEB_TAG, "THIS IS THE WIDTH: " + mVid.getMeasuredWidth()); 
    } 

    ImageView temp = null; 

    switch(page){ 
    case 0: 
     temp = (ImageView) findViewById(R.id.scroll_page_1); 
     mOnPage = 0; 
     break; 
    case 1: 
     temp = (ImageView) findViewById(R.id.scroll_page_2); 
     mOnPage = 1; 
     break; 
    case 2: 
     temp = (ImageView) findViewById(R.id.scroll_page_3); 
     mOnPage = 2; 
     break; 
    } 

    // Change pagination image 
    mPageSelected.setImageResource(R.drawable.scrollview_page_off); 
    temp.setImageResource(R.drawable.scrollview_page_on); 
    mPageSelected = temp; 

} 

首先,它裝載我的視頻這種方式確保將每個不同的設備上都顯示?
二,任何想法爲什麼一個視頻將開始播放,然後踢視頻不能播放的錯誤? 以下是我在視頻啓動時看到的LogCat中鎖定的內容。

07-01 13:27:05.594: WARN/PlayerDriver(30): Using generic video MIO 
07-01 13:27:22.324: WARN/PlayerDriver(30): Video track fell behind 
07-01 13:27:22.324: ERROR/MediaPlayer(409): error (1, 48) 
07-01 13:27:22.324: ERROR/MediaPlayer(409): Error (1,48) 
07-01 13:27:22.324: DEBUG/VideoView(409): Error: 1,48 

回答

0

模擬器上的視頻播放不是很穩定。如果您正在處理視頻,您應該至少在一臺真實設備上進行測試和開發。這是一個常見問題。

+0

謝謝!它適用於實際的設備。 – taraloca 2010-07-06 15:31:20