MediaPlayer-Extended
MediaPlayer-Extended copied to clipboard
MediaPlayer seek
public void seekTo(long usec) { if(mCurrentState.ordinal() < State.PREPARED.ordinal() && mCurrentState.ordinal() >= State.RELEASING.ordinal()) { mCurrentState = State.ERROR; throw new IllegalStateException(); } ....... }
i have a question about mCurrentState<3 && mCurrentState>5 ?why write like this? it seems never happen
You cannot seek when no media source is loaded, which is when prepare
has not been called and it is not in the PREPARED
state, or after release
has been called and the player is RELEASING
or RELEASED
, or when an error happened and it is in the ERROR
state.
There's two possibilities, either ignore seek calls or throw an exception, which is what is happening here because the Android MediaPlayer
does it as well and MediaPlayer-Extended is API compatible to the MediaPlayer so it needs to work similarly.