Tom Doe
Tom Doe

Reputation: 329

Android MP4 stream - Video cannot be played

So i am streaming a video from a URL into the androids video view and its MP4.

Here's my code:

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();";

I get the dialog box saying "This Video cannot be played" BUT if i change the link url to "http://www.boisestatefootball.com/sites/default/files/videos/original/01%20-%20coach%20pete%20bio_4.mp4" Then it works! Does anyone know why? and how can i fix it?

Many Thanks

Upvotes: 5

Views: 5531

Answers (1)

blessed
blessed

Reputation: 127

Try this, it played the video for me

 <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();

Upvotes: 4

Related Questions