Android SDK Media Recorder. State 4

两盒软妹~` 提交于 2020-02-23 05:37:50

问题


I'm just at the end of developing a quick Android App.

Minor problem. What's state 4?

I'm using MediaPlayer and every time I run the app I get an error stating that Media Player "start()" is first called in state 0, then state 4.

Does anyone know what state 4 is?

I can figure out the problem if I know the states such as state 1 and 2...

Thanks,


回答1:


This is from MediaPlayer.h in the Android source:

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
};

Therefore 0 would be MEDIA_PLAYER_STATE_ERROR and 4 would be MEDIA_PLAYER_PREPARING. Did you call prepare() or prepareAsync() before calling start()?

These are the MediaRecorder states:

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,
};

So for recording, state 4 is MEDIA_RECORDER_DATASOURCE_CONFIGURED.



来源:https://stackoverflow.com/questions/9241753/android-sdk-media-recorder-state-4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!