【发布时间】:2014-01-03 18:40:44
【问题描述】:
我正在尝试在我简单的 android VideoView 中播放 mp4 视频。这是我的代码
VideoView videoView;
videoView = (VideoView) findViewById(R.id.videoViewa);
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(videoView);
//URI either from net
Uri video = Uri.parse("http://www.fieldandrurallife.tv/videos/Benltey%20Mulsanne.mp4");
videoView.setMediaController(mediaController);
videoView.setVideoURI(video);
videoView.start();
我的布局看起来像
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
<VideoView
android:id="@+id/videoViewa"
android:layout_width="match_parent"
android:layout_gravity="center"
android:layout_height="match_parent" />
</RelativeLayout>
清单看起来像
android:targetSdkVersion="18" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
我在尝试启动应用程序时收到以下错误
Couldn't open file on client side, trying server side
error (1, -1004)
有没有人遇到过同样的情况?
请帮忙 提前致谢
【问题讨论】:
-
已修复!!!对于有同样问题的人,请注意 Android 将仅播放 H.264 压缩视频。一旦我尝试使用上述视频,问题就解决了
标签: android video-streaming android-videoview android-video-player