Android的VideoView无法播放视频的MP4 [英] Android VideoView Cannot play video mp4

查看:3435
本文介绍了Android的VideoView无法播放视频的MP4的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用过Android VideoView通过HTTP来播放视频文件。我的问题是我的手机会提示无法播放视频很抱歉,此视频无法播放。打从HTTP一个MP4文件时。但它玩另一个MP4视频文件的时候就可以了。

I used the Android VideoView to play a video file via HTTP. My problem is my phone prompts "Cannot play video Sorry, this video cannot be played." when playing a mp4 file from HTTP. But it is ok when playing another mp4 video file.

当在一个较新的手机使用,如三星的Galaxy S,我的程序可以从HTTP成功地同时播放MP4视频文件。

When used in a newer phone, like Samsung Galaxy S, my program can play both mp4 video file from HTTP successfully.

我的电话:

Samsung GT-S5830  
Android version: 2.3.4  
Display: 320x480.

Video file 1 (OK):  
Video Codec: H.264  
Resolution: 640x360  
Others: 16:9, 340kbps, 29.92fps  
Audio Codec: AAC, 44kHz 96kbps Stereo.


Video file 2 (Fail):  
Video Codec: H.264  
Resolution: 640x360  
Others: 16:9, 993kbps, 25fps  
Audio Codec: AAC 44kHz 125kbps Stereo.

下面是我的code硬codeD成功地播放视频文件1。

Below is my code that hardcoded to play the video file 1 successfully.

public class VideoPlayActivity extends Activity {
VideoView vv;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    //requestWindowFeature(Window.FEATURE_NO_TITLE);
    //getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

    vv = new VideoView(this);
    RelativeLayout.LayoutParams param1 = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
    param1.addRule(RelativeLayout.CENTER_IN_PARENT);
    vv.setOnErrorListener(new OnErrorListener() {

        public boolean onError(MediaPlayer mp, int what, int extra) {
            Log.d("Dbg", "OnErrorListener: onError: " + what + ", " + extra);
            return false;
        }

    });

    RelativeLayout layout = new RelativeLayout(this);
    layout.addView(vv, param1);

    setContentView(layout);

    playContent();

 }

 private void playContent() {
    String path = "http://rmcdn.2mdn.net/MotifFiles/html/1248596/android_1330378998288.mp4";

    vv.setVideoPath(path);
    vv.requestFocus();
    vv.start();
    }
}

播放视频文件2时,错误日志如下:

The error log when playing video file 2 is as below:

11-19 17:49:30.119: I/VideoView(16860): start()  
11-19 17:49:30.139: E/MediaPlayer(16860): error (1, -2147483648)  
11-19 17:49:30.149: E/MediaPlayer(16860): Error (1,-2147483648)  
11-19 17:49:30.149: D/VideoView(16860): Error: 1,-2147483648  
11-19 17:49:30.149: D/Dbg(16860): OnErrorListener: onError: 1, -2147483648  

值得注意的是,我试图安装MX播放器和下载的两个视频文件到我的手机的SD卡。该MX播放器可以成功地同时播放视频文件。

It is noted that I tried to install the MX player and downloaded the both video file into my phone's SD card. The MX player can play both video files successfully.

那么,谁能帮我回答下列问题:

So, can anyone help me to answer the questions below:

  1. 为什么我的程序不能播放视频文件2在我的手机?
  2. 如何播放视频文件2在我的手机?

感谢您的咨询。

推荐答案

感谢您从答案Android的MediaPlayer的错误(1,-2147483648)

我找到了视频文件2是连接codeD的标准H.264 Main Profile,我的手机不能播放。 的Andr​​oid支持的媒体格式建议H.264的Baseline Profile的。所以转换视频到基线资料后,就可以发挥我的手机。

I found the video file 2 was encoded in H.264 Main Profile, that my mobile phone cannot be played. Android Supported Media Format suggests H.264 in Baseline Profile. So after converting the video to Baseline Profile, it can be played on my phone.

这篇关于Android的VideoView无法播放视频的MP4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆