Android的VideoView无法播放视频的MP4

编程入门 行业动态 更新时间:2024-10-10 11:30:22
本文介绍了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 = "rmcdn.2mdn/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:

  • 为什么我的程序不能播放视频文件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

    本文发布于:2023-11-27 18:49:48,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1639187.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:无法播放   视频   Android   VideoView

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!