MediaPlayer-Extended icon indicating copy to clipboard operation
MediaPlayer-Extended copied to clipboard

MediaPlayer seek

Open erhuocqr opened this issue 6 years ago • 1 comments

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

erhuocqr avatar Mar 28 '18 08:03 erhuocqr

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.

protyposis avatar Mar 29 '18 16:03 protyposis