我有我的活动视频视图用于显示储存在我的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