简体   繁体   English

Android:这个VideoView出了什么问题?

[英]Android: What's wrong with this VideoView?

I'm working on an application for Android using Eclipse. 我正在使用Eclipse开发Android应用程序。 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中使用的代码的副本:

<?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: 这是Java代码:

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? 我使用错误的Uri地址吗? Or can videos from websites like ustream, livestream or justin.tv not be played in the VideoView? 或者可以在VideoView中播放来自ustream,livestream或justin.tv等网站的视频?

Other videos I want to be able to display in my app will be from http://www.livestream.com/canal33sv 我希望能够在我的应用中显示的其他视频来自http://www.livestream.com/canal33sv

But I'm getting the same error! 但是我得到了同样的错误!

This is a web page address, not a video URI. 这是一个网页地址,而不是视频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. 如果视频可以播放与否,则取决于(例如,播放器的播放器),但您需要提供视频的实际路径,而不是网站的路径。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM