【问题标题】:Can't play any video with any technique : android无法使用任何技术播放任何视频:android
【发布时间】:2014-07-05 21:48:59
【问题描述】:

第一次在 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 放入我的资产文件夹并从那里加载,但我得到了同样的信息。 (编辑:此视频文件与新的 Android 不兼容,但 URI 中的那个肯定是)

我一直在测试的两个视频都来自示例 android 代码,所以我知道这不可能是格式问题。播放视频还需要其他什么东西吗?

【问题讨论】:

  • 好吧,this one of your links 的视频不适用于较新版本的 Android。我已经在那里更新了我的答案以反映这一点。与其从资产进行测试,不如在外部存储上测试文件的播放。如果在那里失败,则视频与您正在测试的任何内容不兼容。
  • 呵呵没看到你的更新。我刚刚从“boisestatefootball”链接传输了视频文件,没有重新格式化它,它使用默认视频播放器在我的设备上运行良好。
  • 您是否在 AndroidManifest.xml 中添加了权限? ` ` 你有没有尝试播放其他在线视频?前任。 wowza.com/html/mobile.html
  • 这表明问题与 HTTP 流有关。您可能会看到现有的支持 Web 的视频播放器是否可以播放它。
  • 我尝试添加权限但没有更改。我尝试将视频 uri 更改为:wowza.com/_h264/BigBuckBunny_115k.mov,但仍然显示“无法播放此视频”

标签: android video


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-08-14
    • 2016-04-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多