4

因此,我将视频从 URL 流式传输到 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 " 然后就可以了!有谁知道为什么?我该如何解决?

非常感谢

4

1 回答 1

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();
于 2013-08-13T14:03:14.133 回答