问题
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