所以我正在将来自网址的视频流式传输到androids视频及其MP4。
这是我的代码:
String LINK = "String LINK = "http://www.fieldandrurallife.tv/videos/Benltey%20Mulsanne.mp4";
setContentView(R.layout.video);
VideoView videoView =(VideoView)findViewById(R.id.video);
MediaController mc = new MediaController(this);
mc.setAnchorView(videoView);
mc.setMediaPlayer(videoView);
Uri video = Uri.parse(LINK);
videoView.setMediaController(mc);
videoView.setVideoURI(video);
videoView.requestFocus();
videoView.start();";
我收到对话框,说“此视频无法播放”但是如果我将链接网址更改为“http://www.boisestatefootball.com/sites/default/files/videos/original/01%20-%20coach%20pete%20bio_4.mp4”那么它可以正常工作!有谁知道为什么?我该如何解决?
非常感谢
答案 0 :(得分:4)
试试这个,它为我播放视频
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<VideoView
android:id="@+id/videoViewa"
android:layout_width="match_parent"
android:layout_gravity="center"
android:layout_height="match_parent" />
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();