釋懷,總算還是把這個問題給解決掉了。
在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,固定從螢幕的左上方開始填充圖片,文字等。比如說我的程式,是讓視頻檔案顯示出來,我先讓文字檔顯示,然後把我的視訊檔案填充上去,覆蓋前者,去顯示給用戶端。