Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit be6e3024 authored by Wei Jia's avatar Wei Jia
Browse files

MediaPlayer2Impl: fix getPlayerState.

Test: MediaPlayer2 plays
Bug: 74204684
Change-Id: Ib27930287485f074be6a8df4a90fb78023153ccd
parent a52ddd98
Loading
Loading
Loading
Loading
+20 −12
Original line number Diff line number Diff line
@@ -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() {