Merge "MediaPlayer2Impl: fix getPlayerState." into pi-dev

am: af6cb35749

Change-Id: Ica02002122fe7b5eb579482091336ed87a5dad20
This commit is contained in:
Wei Jia
2018-03-09 06:25:34 +00:00
committed by android-build-merger

View File

@@ -311,26 +311,34 @@ public final class MediaPlayer2Impl extends MediaPlayer2 {
return 0;
}
/**
* Gets the current player state.
*
* @return the current player state, one of the following:
* @throws IllegalStateException if the internal player engine has not been
* initialized or has been released.
*/
@Override
public @PlayerState int getPlayerState() {
// TODO: use cached state or call native function.
return PLAYER_STATE_IDLE;
int mediaplayer2State = getMediaPlayer2State();
int playerState;
switch (mediaplayer2State) {
case MEDIAPLAYER2_STATE_IDLE:
playerState = PLAYER_STATE_IDLE;
break;
case MEDIAPLAYER2_STATE_PREPARED:
case MEDIAPLAYER2_STATE_PAUSED:
playerState = PLAYER_STATE_PAUSED;
break;
case MEDIAPLAYER2_STATE_PLAYING:
playerState = PLAYER_STATE_PLAYING;
break;
case MEDIAPLAYER2_STATE_ERROR:
default:
playerState = PLAYER_STATE_ERROR;
break;
}
return playerState;
}
/**
* Gets the current buffering state of the player.
* During buffering, see {@link #getBufferedPosition()} for the quantifying the amount already
* buffered.
* @return the buffering state, one of the following:
* @throws IllegalStateException if the internal player engine has not been
* initialized or has been released.
*/
@Override
public @BuffState int getBufferingState() {