无法使用任何技术播放任何视频:android

时间:2014-07-05 21:49:00

标签: android video

首次在Android上使用视频..我尝试使用的所有代码示例都会呈现“无法播放此视频”消息。

以下是我一直在尝试的一个实现:

public class MainActivity extends Activity {

 protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);

  Uri.parse("http://www.boisestatefootball.com/sites/default/files/videos/original/01%20-%20coach%20pete%20bio_4.mp4");

  VideoView mVideoView  = (VideoView)findViewById(R.id.VideoView);
  mVideoView.setMediaController(new MediaController(this));       
  mVideoView.setVideoURI(uri);
  mVideoView.requestFocus();
  mVideoView.start();
}

activity_main.xml中

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    tools:context="com.example.moviedemo.MainActivity" >

    <VideoView 
         android:layout_height="fill_parent"
         android:layout_width="fill_parent" 
         android:id="@+id/VideoView" />
</RelativeLayout>

我也试过这个:Streaming video with videoview

以及其他一些解决方案,例如:How to play a video file in android?

但每次结果都是一样的。我也尝试将这篇文章中的视频:Playing a video in VideoView in Android放入我的资源文件夹并从那里加载,但我得到了相同的消息。 (编辑:此视频文件与新的Androids不兼容,但URI中的那个肯定是)

我一直在测试的两个视频都来自示例Android代码,所以我知道它不能成为格式化问题。是否有其他东西需要播放视频?

1 个答案:

答案 0 :(得分:0)

我重新安装了ADT并且相同的代码工作了......我猜这是安装中的配置错误