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

Commit abf686e0 authored by Jaewan Kim's avatar Jaewan Kim
Browse files

MediaController2: Match APIs with MediaPlayerBase

Bug: 74370608
Test: Build
Change-Id: I6a67b56f0d7a4afe723ea86e70c116fb730b3e69
parent d4115f50
Loading
Loading
Loading
Loading
+31 −11
Original line number Original line Diff line number Diff line
@@ -16,6 +16,8 @@


package android.media;
package android.media;


import static android.media.MediaPlayerBase.BUFFERING_STATE_UNKNOWN;

import android.annotation.CallbackExecutor;
import android.annotation.CallbackExecutor;
import android.annotation.NonNull;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.Nullable;
@@ -166,13 +168,16 @@ public class MediaController2 implements AutoCloseable {
                float speed) { }
                float speed) { }


        /**
        /**
         * Called when the player's buffering position
         * Called to report buffering events for a data source.
         * <p>
         * Use {@link #getBufferedPosition()} for current buffering position.
         *
         *
         * @param controller the controller for this event
         * @param controller the controller for this event
         * @param positionMs buffering position in millis
         * @param item the media item for which buffering is happening.
         * @param state the new buffering state.
         */
         */
        public void onBufferedPositionChanged(@NonNull MediaController2 controller,
        public void onBufferingStateChanged(@NonNull MediaController2 controller,
                long positionMs) { }
                @NonNull MediaItem2 item, @MediaPlayerBase.BuffState int state) { }


        /**
        /**
         * Called when a error from
         * Called when a error from
@@ -193,7 +198,7 @@ public class MediaController2 implements AutoCloseable {
         * @param controller the controller for this event
         * @param controller the controller for this event
         * @param item new item
         * @param item new item
         * @see #onPositionChanged(MediaController2, long, long)
         * @see #onPositionChanged(MediaController2, long, long)
         * @see #onBufferedPositionChanged(MediaController2, long)
         * @see #onBufferingStateChanged(MediaController2, MediaItem2, int)
         */
         */
        // TODO(jaewan): Use this (b/74316764)
        // TODO(jaewan): Use this (b/74316764)
        public void onCurrentMediaItemChanged(@NonNull MediaController2 controller,
        public void onCurrentMediaItemChanged(@NonNull MediaController2 controller,
@@ -450,9 +455,11 @@ public class MediaController2 implements AutoCloseable {
    }
    }


    /**
    /**
     * Revisit this API later.
     * @hide
     * @hide
     */
     */
    public void skipForward() {
    public void skipForward() {
        // TODO(jaewan): (Post-P) Discuss this API later.
        // To match with KEYCODE_MEDIA_SKIP_FORWARD
        // To match with KEYCODE_MEDIA_SKIP_FORWARD
    }
    }


@@ -460,6 +467,7 @@ public class MediaController2 implements AutoCloseable {
     * @hide
     * @hide
     */
     */
    public void skipBackward() {
    public void skipBackward() {
        // TODO(jaewan): (Post-P) Discuss this API later.
        // To match with KEYCODE_MEDIA_SKIP_BACKWARD
        // To match with KEYCODE_MEDIA_SKIP_BACKWARD
    }
    }


@@ -605,16 +613,15 @@ public class MediaController2 implements AutoCloseable {
    }
    }


    /**
    /**
     * Get the lastly cached position from
     * Gets the current playback position.
     * {@link ControllerCallback#onPositionChanged(MediaController2, long, long)}.
     * <p>
     * <p>
     * This returns the calculated value of the position, based on the difference between the
     * This returns the calculated value of the position, based on the difference between the
     * update time and current time.
     * update time and current time.
     *
     *
     * @return position
     * @return position
     */
     */
    public long getPosition() {
    public long getCurrentPosition() {
        return mProvider.getPosition_impl();
        return mProvider.getCurrentPosition_impl();
    }
    }


    /**
    /**
@@ -634,9 +641,22 @@ public class MediaController2 implements AutoCloseable {
        // TODO(jaewan): implement this (b/74093080)
        // TODO(jaewan): implement this (b/74093080)
    }
    }



    /**
     * Gets the current buffering state of the player.
     * During buffering, see {@link #getBufferedPosition()} for the quantifying the amount already
     * buffered.
     * @return the buffering state.
     */
    public @MediaPlayerBase.BuffState int getBufferingState() {
        // TODO(jaewan): Implement.
        return BUFFERING_STATE_UNKNOWN;
    }

    /**
    /**
     * Get the lastly cached buffered position from
     * Gets the lastly cached buffered position from the session when
     * {@link ControllerCallback#onBufferedPositionChanged(MediaController2, long)}.
     * {@link ControllerCallback#onBufferingStateChanged(MediaController2, MediaItem2, int)} is
     * called.
     *
     *
     * @return buffering position in millis
     * @return buffering position in millis
     */
     */
+1 −1
Original line number Original line Diff line number Diff line
@@ -65,7 +65,7 @@ public interface MediaController2Provider extends TransportControlProvider {
    void removePlaylistItem_impl(MediaItem2 item);
    void removePlaylistItem_impl(MediaItem2 item);


    int getPlayerState_impl();
    int getPlayerState_impl();
    long getPosition_impl();
    long getCurrentPosition_impl();
    float getPlaybackSpeed_impl();
    float getPlaybackSpeed_impl();
    long getBufferedPosition_impl();
    long getBufferedPosition_impl();
    MediaItem2 getCurrentMediaItem_impl();
    MediaItem2 getCurrentMediaItem_impl();