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

Commit 68c774a1 authored by Jaewan Kim's avatar Jaewan Kim
Browse files

MediaSession2: Implement skipTo APIs

This implements following APIs from both session and controller.
  - skipToPlaylistItem()
  - skipToNextItem()
  - skipToPreviousItem()

Bug: 74175632
Test: Run CTS with MediaComponents/runcts.sh
Change-Id: I47d94346c997314ff39797bac3034aa507058036
parent 2572f6b7
Loading
Loading
Loading
Loading
+14 −4
Original line number Diff line number Diff line
@@ -836,20 +836,30 @@ public class MediaController2 implements AutoCloseable {
    }

    /**
     * Sets the index of current DataSourceDesc in the play list to be played.
     * Skips to the item in the playlist.
     * <p>
     * This calls {@link MediaPlaylistAgent#skipToPlaylistItem(MediaItem2)}.
     *
     * @param item the index of DataSourceDesc in the play list you want to play
     * @throws IllegalArgumentException if the play list is null
     * @throws NullPointerException if index is outside play list range
     * @param item The item in the playlist you want to play
     */
    public void skipToPlaylistItem(@NonNull MediaItem2 item) {
        mProvider.skipToPlaylistItem_impl(item);
    }

    /**
     * Skips to the previous item in the playlist.
     * <p>
     * This calls {@link MediaPlaylistAgent#skipToPreviousItem()}.
     */
    public void skipToPreviousItem() {
        mProvider.skipToPreviousItem_impl();
    }

    /**
     * Skips to the next item in the playlist.
     * <p>
     * This calls {@link MediaPlaylistAgent#skipToNextItem()}.
     */
    public void skipToNextItem() {
        mProvider.skipToNextItem_impl();
    }
+6 −0
Original line number Diff line number Diff line
@@ -266,10 +266,16 @@ public abstract class MediaPlaylistAgent {
        mProvider.skipToPlaylistItem_impl(item);
    }

    /**
     * Skips to the previous item in the playlist.
     */
    public void skipToPreviousItem() {
        mProvider.skipToPreviousItem_impl();
    }

    /**
     * Skips to the next item in the playlist.
     */
    public void skipToNextItem() {
        mProvider.skipToNextItem_impl();
    }
+25 −4
Original line number Diff line number Diff line
@@ -1779,20 +1779,41 @@ public class MediaSession2 implements AutoCloseable {
    }

    /**
     * Skip to the item in the play list.
     * Skips to the item in the playlist.
     * <p>
     * This calls {@link MediaPlaylistAgent#skipToPlaylistItem(MediaItem2)} and the behavior depends
     * on the playlist agent implementation, especially with the shuffle/repeat mode.
     *
     * @param item item in the play list you want to play
     * @throws IllegalArgumentException if the play list is null
     * @throws NullPointerException if index is outside play list range
     * @param item The item in the playlist you want to play
     * @see #getShuffleMode()
     * @see #getRepeatMode()
     */
    public void skipToPlaylistItem(@NonNull MediaItem2 item) {
        mProvider.skipToPlaylistItem_impl(item);
    }

    /**
     * Skips to the previous item.
     * <p>
     * This calls {@link MediaPlaylistAgent#skipToPreviousItem()} and the behavior depends on the
     * playlist agent implementation, especially with the shuffle/repeat mode.
     *
     * @see #getShuffleMode()
     * @see #getRepeatMode()
     **/
    public void skipToPreviousItem() {
        mProvider.skipToPreviousItem_impl();
    }

    /**
     * Skips to the next item.
     * <p>
     * This calls {@link MediaPlaylistAgent#skipToNextItem()} and the behavior depends on the
     * playlist agent implementation, especially with the shuffle/repeat mode.
     *
     * @see #getShuffleMode()
     * @see #getRepeatMode()
     */
    public void skipToNextItem() {
        mProvider.skipToNextItem_impl();
    }