我有我的活動視頻視圖用於顯示儲存在我的res.raw文件夾這樣的視頻:僅限VideoView音頻,無視頻?
MediaController controller=new MediaController(this);
video.setMediaController(controller);
String filePath="android.resource://" + getPackageName() + "/" + R.raw.video3;
video.setVideoURI(Uri.parse(filePath));
video.requestFocus();
video.start();
的問題是,我只能聽到聲音,但視頻沒有顯示。
這可能是什麼原因?
編輯:這是我的佈局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent"
android:orientation="vertical"
>
<Button
android:id="@+id/btnPlayAudio"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Play Audio"
>
</Button>
<Button
android:id="@+id/btnPlayVideo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Play Video"
>
</Button>
<VideoView android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:id="@+id/videoView"
/>
</LinearLayout>
並且你指定的MediaPlayer到VideoView?您是否看過:http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/media/VideoViewDemo.html – Blundell 2011-04-18 12:40:57
您是否嘗試使用standart android player播放此視頻?第二個問題:你在模擬器或設備上運行你的代碼?模擬器可能在播放視頻時遇到問題。 – 2011-04-18 12:44:05
@Blundell:我只是使用上面的代碼。 @Anton:我嘗試了一個真實的設備 – 2011-04-18 12:46:06