一、关于 “MediaPlayer error (XXXX,XXXX) 

问题1:

E/MediaPlayer(19765): stop called in state 4
E/MediaPlayer(19765): error (-38, 0)

原因:是在调用prepareAsync()则以异步方式进入Prepared状态过程中即preparing状态中,调用了stop方法。

参考:http://stackoverflow.com/questions/8796956/mediaplayer-stop-called-in-state-4

问题2:

Media Player called in state 0, error (-38,0)

原因是在You're using prepareAsync, which is asynchronous. That is, you should wait for the onPrepared callback before you do anything that relies on the preparation to be complete (like calling start). That's why you get the "start called in state 4" error message (state 4 is MEDIA_PLAYER_PREPARING).

即调用 prepareAsync,在preparing过程中调用了start。

参考:http://stackoverflow.com/questions/16495276/mediaplayer-track-change-issue 

问题3:

Attempt to call getDuration without a valid mediaplayer in media player on android

原因:在preparing过程中调用了getDuration方法。

You might be calling getDuration before the file is fully loaded.

参考:http://stackoverflow.com/questions/6026288/attempt-to-call-getduration-without-a-valid-mediaplayer-in-media-player-on-andr 

问题4:如果你使用VideoView播放过MP4视频,你可能碰到过类似下面的问题:

MediaPlayer error (1, -2147483648)

如果你查阅文档,会发现1其实代表MEDIA_ERROR_UNKNOWN,不过文档对-2147483648(0x80000000)没有做什么说明,实际上它也是代表unknown error的意思。

真正的原因在于,MP4有多种编码格式,例如H.264,H.263等,而android版本较低的机器只支持部分编码。

一旦遭遇不被支持的编码格式,MediaPlayer可能就会抛出上面的错误信息。

如果你也遇到这类问题,你可以使用一些视频软件查看视频的编码格式,然后转换为普遍支持的格式。

stackoverflow上有关于此问题的讨论,下面是一些链接:

http://stackoverflow.com/questions/10849044/cant-play-mp4-video-in-my-android-app

http://superuser.com/questions/371460/command-encoding-h264-baseline-profile-level-1-with-ffmpeg-and-libx264

http://stackoverflow.com/questions/11540076/android-mediaplayer-error-1-2147483648

http://developer.android.com/guide/appendix/media-formats.html

更多相关文章

  1. android全格式多媒体播放器(三:基于ffmpeg架构的具体实现)
  2. Android学习笔记:Activity-Spinner
  3. android 不透明度16进制值
  4. android 获取video列表和缩略图 亲测()
  5. Tiny210 从源代码开始创建Android
  6. android 开发故障记录
  7. 全套Java、Android、HTML5前端视频
  8. android 数据存储值 sharedPreferences
  9. Android(安卓)通过Get方式提交参数给Web应用

随机推荐

  1. Android(安卓)资源(resource)学习小结
  2. android sqlite 数据类型
  3. Android系统上部署usb打印机
  4. busybox应用于android系统
  5. android应用层学习经验
  6. android系统体系结构
  7. Android的webview研究
  8. Android(安卓)Camera 系统框架分析
  9. 深刻解析 Android(安卓)的 AIDL
  10. Android(安卓)开发手记之NDK 编程实例