Package com.google.android.exoplayer2.ext.mediasession

## Class TimelineQueueEditor

- java.lang.Object
- - com.google.android.exoplayer2.ext.mediasession.TimelineQueueEditor

- All Implemented Interfaces:
    `MediaSessionConnector.CommandReceiver`, `MediaSessionConnector.QueueEditor`

      public final class TimelineQueueEditor
      extends Object
      implements MediaSessionConnector.QueueEditor, MediaSessionConnector.CommandReceiver

  A `MediaSessionConnector.QueueEditor` implementation.

  This class implements the `MediaSessionConnector.CommandReceiver` interface and handles the `COMMAND_MOVE_QUEUE_ITEM` to move a queue item instead of removing and inserting it. This allows to move the currently playing window without interrupting playback.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class | Description
    --- | --- | ---
    `static interface` | `TimelineQueueEditor.MediaDescriptionConverter` | Converts a `MediaDescriptionCompat` to a `MediaItem`.
    `static class` | `TimelineQueueEditor.MediaIdEqualityChecker` | Media description comparator comparing the media IDs.
    `static interface` | `TimelineQueueEditor.QueueDataAdapter` | Adapter to get `MediaDescriptionCompat` of items in the queue and to notify the application about changes in the queue to sync the data structure backing the `MediaSessionConnector`.

  - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `static String` | `COMMAND_MOVE_QUEUE_ITEM` |
    `static String` | `EXTRA_FROM_INDEX` |
    `static String` | `EXTRA_TO_INDEX` |

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `TimelineQueueEditor​(android.support.v4.media.session.MediaControllerCompat mediaController, TimelineQueueEditor.QueueDataAdapter queueDataAdapter, TimelineQueueEditor.MediaDescriptionConverter mediaDescriptionConverter)` | Creates a new `TimelineQueueEditor` with a given mediaSourceFactory.
    `TimelineQueueEditor​(android.support.v4.media.session.MediaControllerCompat mediaController, TimelineQueueEditor.QueueDataAdapter queueDataAdapter, TimelineQueueEditor.MediaDescriptionConverter mediaDescriptionConverter, com.google.android.exoplayer2.ext.mediasession.TimelineQueueEditor.MediaDescriptionEqualityChecker equalityChecker)` | Creates a new `TimelineQueueEditor` with a given mediaSourceFactory.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `onAddQueueItem​(Player player, android.support.v4.media.MediaDescriptionCompat description)` | See `MediaSessionCompat.Callback.onAddQueueItem(MediaDescriptionCompat description)`.
    `void` | `onAddQueueItem​(Player player, android.support.v4.media.MediaDescriptionCompat description, int index)` | See `MediaSessionCompat.Callback.onAddQueueItem(MediaDescriptionCompat description, int index)`.
    `boolean` | `onCommand​(Player player, ControlDispatcher controlDispatcher, String command, Bundle extras, ResultReceiver cb)` | See `MediaSessionCompat.Callback.onCommand(String, Bundle, ResultReceiver)`.
    `void` | `onRemoveQueueItem​(Player player, android.support.v4.media.MediaDescriptionCompat description)` | See `MediaSessionCompat.Callback.onRemoveQueueItem(MediaDescriptionCompat description)`.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### COMMAND_MOVE_QUEUE_ITEM

          public static final String COMMAND_MOVE_QUEUE_ITEM

      See Also:
        Constant Field Values

    - #### EXTRA_FROM_INDEX

          public static final String EXTRA_FROM_INDEX

      See Also:
        Constant Field Values

    - #### EXTRA_TO_INDEX

          public static final String EXTRA_TO_INDEX

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### TimelineQueueEditor

          public TimelineQueueEditor​(android.support.v4.media.session.MediaControllerCompat mediaController,
                                     TimelineQueueEditor.QueueDataAdapter queueDataAdapter,
                                     TimelineQueueEditor.MediaDescriptionConverter mediaDescriptionConverter)

      Creates a new `TimelineQueueEditor` with a given mediaSourceFactory.
      Parameters:
        `mediaController` - A `MediaControllerCompat` to read the current queue.
        `queueDataAdapter` - A `TimelineQueueEditor.QueueDataAdapter` to change the backing data.
        `mediaDescriptionConverter` - The `TimelineQueueEditor.MediaDescriptionConverter` for converting media descriptions to `MediaItems`.

    - #### TimelineQueueEditor

          public TimelineQueueEditor​(android.support.v4.media.session.MediaControllerCompat mediaController,
                                     TimelineQueueEditor.QueueDataAdapter queueDataAdapter,
                                     TimelineQueueEditor.MediaDescriptionConverter mediaDescriptionConverter,
                                     com.google.android.exoplayer2.ext.mediasession.TimelineQueueEditor.MediaDescriptionEqualityChecker equalityChecker)

      Creates a new `TimelineQueueEditor` with a given mediaSourceFactory.
      Parameters:
        `mediaController` - A `MediaControllerCompat` to read the current queue.
        `queueDataAdapter` - A `TimelineQueueEditor.QueueDataAdapter` to change the backing data.
        `mediaDescriptionConverter` - The `TimelineQueueEditor.MediaDescriptionConverter` for converting media descriptions to `MediaItems`.
        `equalityChecker` - The `TimelineQueueEditor.MediaDescriptionEqualityChecker` to match queue items.

  - ### Method Detail

    - #### onAddQueueItem

          public void onAddQueueItem​(Player player,
                                     android.support.v4.media.MediaDescriptionCompat description)

      Description copied from interface: `MediaSessionConnector.QueueEditor`
      See `MediaSessionCompat.Callback.onAddQueueItem(MediaDescriptionCompat description)`.
      Specified by:
        `onAddQueueItem` in interface `MediaSessionConnector.QueueEditor`

    - #### onAddQueueItem

          public void onAddQueueItem​(Player player,
                                     android.support.v4.media.MediaDescriptionCompat description,
                                     int index)

      Description copied from interface: `MediaSessionConnector.QueueEditor`
      See `MediaSessionCompat.Callback.onAddQueueItem(MediaDescriptionCompat description, int index)`.
      Specified by:
        `onAddQueueItem` in interface `MediaSessionConnector.QueueEditor`

    - #### onRemoveQueueItem

          public void onRemoveQueueItem​(Player player,
                                        android.support.v4.media.MediaDescriptionCompat description)

      Description copied from interface: `MediaSessionConnector.QueueEditor`
      See `MediaSessionCompat.Callback.onRemoveQueueItem(MediaDescriptionCompat description)`.
      Specified by:
        `onRemoveQueueItem` in interface `MediaSessionConnector.QueueEditor`

    - #### onCommand

          public boolean onCommand​(Player player,
                                   @Deprecated
                                   ControlDispatcher controlDispatcher,
                                   String command,
                                   @Nullable
                                   Bundle extras,
                                   @Nullable
                                   ResultReceiver cb)

      Description copied from interface: `MediaSessionConnector.CommandReceiver`
      See `MediaSessionCompat.Callback.onCommand(String, Bundle, ResultReceiver)`. The receiver may handle the command, but is not required to do so.
      Specified by:
        `onCommand` in interface `MediaSessionConnector.CommandReceiver`
      Parameters:
        `player` - The player connected to the media session.
        `controlDispatcher` - This parameter is deprecated. Use `player` instead. Operations can be customized by passing a `ForwardingPlayer` to `MediaSessionConnector.setPlayer(Player)`, or when configuring the player (for example by using `SimpleExoPlayer.Builder#setSeekBackIncrementMs(long)`).
        `command` - The command name.
        `extras` - Optional parameters for the command, may be null.
        `cb` - A result receiver to which a result may be sent by the command, may be null.
      Returns:
        Whether the receiver handled the command.