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

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

MediaController2: Add fastForward() / rewind()

Following CLs are included
  - Add MediaController2#fastForward() / rewind()
  - Add MediaSession2.SessionCallback#onFastForward() / rewind()

Bug: 74724709
Test: Build
Change-Id: I0dd2b6c21931df937006ae26011ea9538720afee
parent cdc9d900
Loading
Loading
Loading
Loading
+2 −4
Original line number Original line Diff line number Diff line
@@ -423,16 +423,14 @@ public class MediaController2 implements AutoCloseable {
    }
    }


    /**
    /**
     * Start fast forwarding. If playback is already fast forwarding this
     * Fast forwards playback. If playback is already fast forwarding this may increase the rate.
     * may increase the rate.
     */
     */
    public void fastForward() {
    public void fastForward() {
        mProvider.fastForward_impl();
        mProvider.fastForward_impl();
    }
    }


    /**
    /**
     * Start rewinding. If playback is already rewinding this may increase
     * Rewinds playback. If playback is already rewinding this may increase the rate.
     * the rate.
     */
     */
    public void rewind() {
    public void rewind() {
        mProvider.rewind_impl();
        mProvider.rewind_impl();
+0 −27
Original line number Original line Diff line number Diff line
@@ -130,33 +130,6 @@ public abstract class MediaPlayerBase implements AutoCloseable {
     */
     */
    public abstract void seekTo(long pos);
    public abstract void seekTo(long pos);


    /**
     * Fast forwards playback. If playback is already fast forwarding this may increase the rate.
     * <p>
     * Default implementation sets the playback speed to the 2.0f
     * @see #setPlaybackSpeed(float)
     * @hide
     */
    // TODO(jaewan): Unhide (b/74724709)
    public void fastForward() {
        setPlaybackSpeed(2.0f);
    }

    /**
     * Rewinds playback. If playback is already rewinding this may increase the rate.
     * <p>
     * Default implementation sets the playback speed to the -1.0f if
     * {@link #isReversePlaybackSupported()} returns {@code true}.
     * @see #setPlaybackSpeed(float)
     * @hide
     */
    // TODO(jaewan): Unhide (b/74724709)
    public void rewind() {
        if (isReversePlaybackSupported()) {
            setPlaybackSpeed(-1.0f);
        }
    }

    public static final long UNKNOWN_TIME = -1;
    public static final long UNKNOWN_TIME = -1;


    /**
    /**
+18 −25
Original line number Original line Diff line number Diff line
@@ -142,20 +142,13 @@ public class MediaSession2 implements AutoCloseable {


    /**
    /**
     * Command code for {@link MediaController2#fastForward()}.
     * Command code for {@link MediaController2#fastForward()}.
     * <p>
     * This is transport control command. Command would be sent directly to the player if the
     * session doesn't reject the request through the
     * {@link SessionCallback#onCommandRequest(MediaSession2, ControllerInfo, Command)}.
     */
     */
    public static final int COMMAND_CODE_PLAYBACK_FAST_FORWARD = 7;
    public static final int COMMAND_CODE_SESSION_FAST_FORWARD = 7;


    /**
    /**
     * Command code for {@link MediaController2#rewind()}.
     * Command code for {@link MediaController2#rewind()}.
     * <p>
     * Command would be sent directly to the player if the session doesn't reject the request
     * through the {@link SessionCallback#onCommandRequest(MediaSession2, ControllerInfo, Command)}.
     */
     */
    public static final int COMMAND_CODE_PLAYBACK_REWIND = 8;
    public static final int COMMAND_CODE_SESSION_REWIND = 8;


    /**
    /**
     * Command code for {@link MediaController2#seekTo(long)}.
     * Command code for {@link MediaController2#seekTo(long)}.
@@ -634,8 +627,8 @@ public class MediaSession2 implements AutoCloseable {
         * @see #COMMAND_CODE_PLAYLIST_SKIP_NEXT_ITEM
         * @see #COMMAND_CODE_PLAYLIST_SKIP_NEXT_ITEM
         * @see #COMMAND_CODE_PLAYLIST_SKIP_PREV_ITEM
         * @see #COMMAND_CODE_PLAYLIST_SKIP_PREV_ITEM
         * @see #COMMAND_CODE_PLAYBACK_PREPARE
         * @see #COMMAND_CODE_PLAYBACK_PREPARE
         * @see #COMMAND_CODE_PLAYBACK_FAST_FORWARD
         * @see #COMMAND_CODE_SESSION_FAST_FORWARD
         * @see #COMMAND_CODE_PLAYBACK_REWIND
         * @see #COMMAND_CODE_SESSION_REWIND
         * @see #COMMAND_CODE_PLAYBACK_SEEK_TO
         * @see #COMMAND_CODE_PLAYBACK_SEEK_TO
         * @see #COMMAND_CODE_PLAYLIST_SKIP_TO_PLAYLIST_ITEM
         * @see #COMMAND_CODE_PLAYLIST_SKIP_TO_PLAYLIST_ITEM
         * @see #COMMAND_CODE_PLAYLIST_ADD_ITEM
         * @see #COMMAND_CODE_PLAYLIST_ADD_ITEM
@@ -795,6 +788,20 @@ public class MediaSession2 implements AutoCloseable {
        public void onPrepareFromUri(@NonNull MediaSession2 session,
        public void onPrepareFromUri(@NonNull MediaSession2 session,
                @NonNull ControllerInfo controller, @NonNull Uri uri, @Nullable Bundle extras) { }
                @NonNull ControllerInfo controller, @NonNull Uri uri, @Nullable Bundle extras) { }


        /**
         * Called when a controller called {@link MediaController2#fastForward()}
         *
         * @param session the session for this event
         */
        public void onFastForward(@NonNull MediaSession2 session) { }

        /**
         * Called when a controller called {@link MediaController2#rewind()}
         *
         * @param session the session for this event
         */
        public void onRewind(@NonNull MediaSession2 session) { }

        /**
        /**
         * Called when the player's current playing item is changed
         * Called when the player's current playing item is changed
         * <p>
         * <p>
@@ -1435,20 +1442,6 @@ public class MediaSession2 implements AutoCloseable {
        mProvider.prepare_impl();
        mProvider.prepare_impl();
    }
    }


    /**
     * Fast forwards playback. If playback is already fast forwarding this may increase the rate.
     */
    public void fastForward() {
        mProvider.fastForward_impl();
    }

    /**
     * Rewinds playback. If playback is already rewinding this may increase the rate.
     */
    public void rewind() {
        mProvider.rewind_impl();
    }

    /**
    /**
     * Move to a new location in the media stream.
     * Move to a new location in the media stream.
     *
     *
+2 −0
Original line number Original line Diff line number Diff line
@@ -52,6 +52,8 @@ public interface MediaController2Provider extends TransportControlProvider {
    void playFromSearch_impl(String query, Bundle extras);
    void playFromSearch_impl(String query, Bundle extras);
    void playFromUri_impl(Uri uri, Bundle extras);
    void playFromUri_impl(Uri uri, Bundle extras);
    void playFromMediaId_impl(String mediaId, Bundle extras);
    void playFromMediaId_impl(String mediaId, Bundle extras);
    void fastForward_impl();
    void rewind_impl();


    void setRating_impl(String mediaId, Rating2 rating);
    void setRating_impl(String mediaId, Rating2 rating);
    void sendCustomCommand_impl(Command command, Bundle args, ResultReceiver cb);
    void sendCustomCommand_impl(Command command, Bundle args, ResultReceiver cb);
+0 −2
Original line number Original line Diff line number Diff line
@@ -29,8 +29,6 @@ public interface TransportControlProvider {
    void skipToNextItem_impl();
    void skipToNextItem_impl();


    void prepare_impl();
    void prepare_impl();
    void fastForward_impl();
    void rewind_impl();
    void seekTo_impl(long pos);
    void seekTo_impl(long pos);
    void skipToPlaylistItem_impl(MediaItem2 item);
    void skipToPlaylistItem_impl(MediaItem2 item);