开发者

Android: What's wrong with this VideoView?

I'm working on an application for Android using Eclipse. I want to stream a video from the internet in my app. I have read a lot of the questions and answers from here and got far but the video is not 开发者_开发知识库playing!

I get this message when I call the video:

Cannot play video.... Sorry, this video cannot be played.

Here is a copy of the code I'm using in XML:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
       android:layout_width="fill_parent"
       android:layout_height="fill_parent" >
<VideoView android:id="@+id/tvvideoView"
         android:layout_width="fill_parent"
         android:layout_alignParentRight="true"
         android:layout_alignParentLeft="true"
         android:layout_alignParentTop="true"
         android:layout_alignParentBottom="true"
         android:layout_height="fill_parent">
</VideoView>
</RelativeLayout>

and here is the Java code:

package appinventor.ai_ignacioleon7.ElSalvadorTVRadioGuide;

import android.app.Activity;
import android.net.Uri;
import android.os.Bundle;
import android.widget.MediaController;
import android.widget.VideoView;


public class Tvdiplay1 extends Activity {
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);

         setContentView(R.layout.tvdisplay);

         VideoView videoView = (VideoView) findViewById(R.id.tvvideoView);
         MediaController mediaController = new MediaController(this);
         mediaController.setAnchorView(videoView);
         Uri video = Uri.parse("http://www.ustream.tv/channel/5474055");
         videoView.setMediaController(mediaController);
         videoView.setVideoURI(video);
         videoView.start();
    }
}

Am I using the wrong Uri address? Or can videos from websites like ustream, livestream or justin.tv not be played in the VideoView?

Other videos I want to be able to display in my app will be from http://www.livestream.com/canal33sv

But I'm getting the same error!


This is a web page address, not a video URI. If the videos can be played or not, it depends (on what player is it for, for example) but you need to give the actual path of the video, not of the site.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜