有關android中載入MP4,3gp等視頻檔案,無法播放問題的解決

來源:互聯網
上載者:User

     釋懷,總算還是把這個問題給解決掉了。

    在android的模擬器中載入視頻檔案的時候,它會提示:視頻無法播放!於是,我在logcat下面找錯誤的日誌,它有如下幾行錯誤顯示:
    ERROR/PlayerDriver(31): Command PLAYER_PREPARE completed with an error or info
PVMFErrResource

   : ERROR/MediaPlayer(19049): error (1, -17)

   :ERROR/MediaPlayer(19049): Error (1,-17)

   昨天,我反覆尋找,代碼沒有錯,一時半會,陷入了死角。 我選擇了暫時放棄,把它擱置在了一旁。在網上查了一些資料,沒有能夠找到解決問題的辦法。今天,我又開啟看了看,同時找了一些源碼看了看,我試著在layout檔案夾下的main.xml配置資訊裡面添加了如下的代碼:

   <TextView  

android:layout_width="fill_parent" 

    android:layout_height="wrap_content" 

    android:text="@string/hello"

    />

  可以了,解決掉了。由於能力有限,我只能做如下的理解和解釋,大家如果有什麼不同的或更好的見解,希望予以提出,以下是我的main.xml設定檔:

 

<FrameLayout

   xmlns:android="http://schemas.android.com/apk/res/android"

   android:layout_width="fill_parent"

   android:layout_height="fill_parent">

   <TextView  

android:layout_width="fill_parent" 

    android:layout_height="wrap_content" 

    android:text="@string/hello"

    />

   <VideoView

      android:id="@+id/video"

      android:layout_height="wrap_content"

      android:layout_width="wrap_content"

      android:layout_gravity="center" />

</FrameLayout>

  由於我是使用的FrameLayout布局的,所以我們不妨把FrameLayout當作畫布canvas,固定從螢幕的左上方開始填充圖片,文字等。比如說我的程式,是讓視頻檔案顯示出來,我先讓文字檔顯示,然後把我的視訊檔案填充上去,覆蓋前者,去顯示給用戶端。

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.