Android SDK媒体录制器。州4

时间:2012-02-11 16:17:59

标签: android sdk media-player state android-2.2-froyo

我刚刚开发一款快速Android应用程序。

小问题。什么是州4?

我正在使用MediaPlayer,每次运行应用程序时都会收到错误消息,指出Media Player“start()”首先在状态0中调用,然后调用状态4.

有谁知道状态4是什么?

如果我知道状态1和2 ......

等状态,我可以找出问题

谢谢,

1 个答案:

答案 0 :(得分:7)

这是来自Android来源的MediaPlayer.h:

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_DECODED            = 1 << 4,
  MEDIA_PLAYER_STARTED            = 1 << 5,
  MEDIA_PLAYER_PAUSED             = 1 << 6,
  MEDIA_PLAYER_STOPPED            = 1 << 7,
  MEDIA_PLAYER_PLAYBACK_COMPLETE  = 1 << 8
};

因此0将是MEDIA_PLAYER_STATE_ERROR,4将是MEDIA_PLAYER_PREPARING。 你在调用start()之前调用了prepare()还是prepareAsync()?

这些是MediaRecorder声明:

enum media_recorder_states {
  MEDIA_RECORDER_ERROR                 =      0,
  MEDIA_RECORDER_IDLE                  = 1 << 0,
  MEDIA_RECORDER_INITIALIZED           = 1 << 1,
  MEDIA_RECORDER_DATASOURCE_CONFIGURED = 1 << 2,
  MEDIA_RECORDER_PREPARED              = 1 << 3,
  MEDIA_RECORDER_RECORDING             = 1 << 4,
};

因此,对于录制,状态4为MEDIA_RECORDER_DATASOURCE_CONFIGURED。