MediaPlayer常见错误码

来源:互联网 发布:数控编程用的语言 编辑:程序博客网 时间:2024/06/05 22:50

先看下mediaplayer.h对error类型的定义:

// Generic error codes for the media player framework.  Errors are fatal, the// playback must abort.//// Errors are communicated back to the client using the// MediaPlayerListener::notify method defined below.// In this situation, 'notify' is invoked with the following://   'msg' is set to MEDIA_ERROR.//   'ext1' should be a value from the enum media_error_type.//   'ext2' contains an implementation dependant error code to provide//          more details. Should default to 0 when not used.//// The codes are distributed as follow://   0xx: Reserved//   1xx: Android Player errors. Something went wrong inside the MediaPlayer.//   2xx: Media errors (e.g Codec not supported). There is a problem with the//        media itself.//   3xx: Runtime errors. Some extraordinary condition arose making the playback//        impossible.//enum media_error_type {    // 0xx    MEDIA_ERROR_UNKNOWN = 1,    // 1xx    MEDIA_ERROR_SERVER_DIED = 100,    // 2xx    MEDIA_ERROR_NOT_VALID_FOR_PROGRESSIVE_PLAYBACK = 200,    // 3xx};


常见错误类型

1. -2147483648 未知错误

例如log输出:

MediaPlayer: error (1, -2147483648)

error的第一个参数1表示未知错误。

错误码-2147483648是十进制表示的,对应16进制的0x80000000。

它定义在文件:/frameworks/native/include/utils/Errors.h

UNKNOWN_ERROR       = 0x80000000,

此错误一般是在framework的libmediaplayerservice,libstagefright目录中抛出的。

在执行某个动作时被取消或者中断,就会抛出此错误。

也是一个通用错误,在不知道错误原因时,也可以抛出此错误。


2. -107 网络链接错误

例如log输出:

MediaPlayer: error (1, -107)