谁知道 android 媒体播放器在 LogCat 中的 int 值?

Who knows the android mediaplayer states by their int value in LogCat?

我有一个使用 Android MediaPlayer class 的实现。我不断遇到各种错误,更改代码,遇到另一个错误。根据错误,我收到 LogCat 从 MediaPlayer 返回的错误消息报告:

"xyz 在状态 x" 中调用。

我不想 post 为我遇到的每个错误都发帖,我宁愿掌握所有的窍门并自己修复错误。但是我找不到任何文档可以告诉我 哪个州编号映射到哪个州,正如 MediaPlayer 在线文档中所描述的那样。

有人可以 post 向这样的列表添加 link,或者在此 post 中提供列表吗?我想我不会是唯一会对此表示赞赏的人。

http://developer.android.com/reference/android/media/MediaPlayer.html

例如

public static final int MEDIA_ERROR_IO

Added in API level 17 File or network related operation errors.

Constant Value: -1004 (0xfffffc14)

这些是当前在 mediaplayer.h 中 AOSP 主分支上声明的状态:

enum media_player_states {
    MEDIA_PLAYER_STATE_ERROR        = 0,
    MEDIA_PLAYER_IDLE               = 1 << 0,
    MEDIA_PLAYER_INITIALIZED        = 1 << 1,
    MEDIA_PLAYER_PREPARING          = 1 << 2,
    MEDIA_PLAYER_PREPARED           = 1 << 3,
    MEDIA_PLAYER_STARTED            = 1 << 4,
    MEDIA_PLAYER_PAUSED             = 1 << 5,
    MEDIA_PLAYER_STOPPED            = 1 << 6,
    MEDIA_PLAYER_PLAYBACK_COMPLETE  = 1 << 7
};

基于 Michael 的回答,这里是声明的状态,其中为每个移位的位添加了十进制值。是的,它们计算起来很简单,但这在解析 LogCat 消息时节省了额外的步骤。

enum media_player_states {
    MEDIA_PLAYER_STATE_ERROR        = 0,        //   0
    MEDIA_PLAYER_IDLE               = 1 << 0,   //   1
    MEDIA_PLAYER_INITIALIZED        = 1 << 1,   //   2
    MEDIA_PLAYER_PREPARING          = 1 << 2,   //   4
    MEDIA_PLAYER_PREPARED           = 1 << 3,   //   8
    MEDIA_PLAYER_STARTED            = 1 << 4,   //  16
    MEDIA_PLAYER_PAUSED             = 1 << 5,   //  32
    MEDIA_PLAYER_STOPPED            = 1 << 6,   //  64
    MEDIA_PLAYER_PLAYBACK_COMPLETE  = 1 << 7    // 128
};