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

## Class TimelineQueueNavigator

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

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

      public abstract class TimelineQueueNavigator
      extends Object
      implements MediaSessionConnector.QueueNavigator

  An abstract implementation of the `MediaSessionConnector.QueueNavigator` that maps the windows of a `Player`'s `Timeline` to the media session queue.

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `static int` | `DEFAULT_MAX_QUEUE_SIZE` |

    - ### Fields inherited from interface com.google.android.exoplayer2.ext.mediasession.MediaSessionConnector.QueueNavigator

      `ACTIONS`

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `TimelineQueueNavigator​(android.support.v4.media.session.MediaSessionCompat mediaSession)` | Creates an instance for a given `MediaSessionCompat`.
    `TimelineQueueNavigator​(android.support.v4.media.session.MediaSessionCompat mediaSession, int maxQueueSize)` | Creates an instance for a given `MediaSessionCompat` and maximum queue size.

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `long` | `getActiveQueueItemId​(Player player)` | Gets the id of the currently active queue item, or `MediaSessionCompat.QueueItem.UNKNOWN_ID` if the active item is unknown.
    `abstract android.support.v4.media.MediaDescriptionCompat` | `getMediaDescription​(Player player, int windowIndex)` | Gets the `MediaDescriptionCompat` for a given timeline window index.
    `long` | `getSupportedQueueNavigatorActions​(Player player)` | Returns the actions which are supported by the navigator.
    `boolean` | `onCommand​(Player player, ControlDispatcher controlDispatcher, String command, Bundle extras, ResultReceiver cb)` | See `MediaSessionCompat.Callback.onCommand(String, Bundle, ResultReceiver)`.
    `void` | `onCurrentWindowIndexChanged​(Player player)` | Called when the current window index changed.
    `void` | `onSkipToNext​(Player player, ControlDispatcher controlDispatcher)` | See `MediaSessionCompat.Callback.onSkipToNext()`.
    `void` | `onSkipToPrevious​(Player player, ControlDispatcher controlDispatcher)` | See `MediaSessionCompat.Callback.onSkipToPrevious()`.
    `void` | `onSkipToQueueItem​(Player player, ControlDispatcher controlDispatcher, long id)` | See `MediaSessionCompat.Callback.onSkipToQueueItem(long)`.
    `void` | `onTimelineChanged​(Player player)` | Called when the timeline of the player has changed.

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

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

- - ### Field Detail

    - #### DEFAULT_MAX_QUEUE_SIZE

          public static final int DEFAULT_MAX_QUEUE_SIZE

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### TimelineQueueNavigator

          public TimelineQueueNavigator​(android.support.v4.media.session.MediaSessionCompat mediaSession)

      Creates an instance for a given `MediaSessionCompat`.

      Equivalent to `TimelineQueueNavigator(mediaSession, DEFAULT_MAX_QUEUE_SIZE)`.

      Parameters:
        `mediaSession` - The `MediaSessionCompat`.

    - #### TimelineQueueNavigator

          public TimelineQueueNavigator​(android.support.v4.media.session.MediaSessionCompat mediaSession,
                                        int maxQueueSize)

      Creates an instance for a given `MediaSessionCompat` and maximum queue size.

      If the number of windows in the `Player`'s `Timeline` exceeds `maxQueueSize`, the media session queue will correspond to `maxQueueSize` windows centered on the one currently being played.

      Parameters:
        `mediaSession` - The `MediaSessionCompat`.
        `maxQueueSize` - The maximum queue size.

  - ### Method Detail

    - #### getMediaDescription

          public abstract android.support.v4.media.MediaDescriptionCompat getMediaDescription​(Player player,
                                                                                              int windowIndex)

      Gets the `MediaDescriptionCompat` for a given timeline window index.

      Often artworks and icons need to be loaded asynchronously. In such a case, return a `MediaDescriptionCompat` without the images, load your images asynchronously off the main thread and then call `MediaSessionConnector.invalidateMediaSessionQueue()` to make the connector update the queue by calling this method again.

      Parameters:
        `player` - The current player.
        `windowIndex` - The timeline window index for which to provide a description.
      Returns:
        A `MediaDescriptionCompat`.

    - #### getSupportedQueueNavigatorActions

          public long getSupportedQueueNavigatorActions​(Player player)

      Description copied from interface: `MediaSessionConnector.QueueNavigator`
      Returns the actions which are supported by the navigator. The supported actions must be a bitmask combined out of `PlaybackStateCompat.ACTION_SKIP_TO_QUEUE_ITEM`, `PlaybackStateCompat.ACTION_SKIP_TO_NEXT`, `PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS`.
      Specified by:
        `getSupportedQueueNavigatorActions` in interface `MediaSessionConnector.QueueNavigator`
      Parameters:
        `player` - The player connected to the media session.
      Returns:
        The bitmask of the supported media actions.

    - #### onTimelineChanged

          public final void onTimelineChanged​(Player player)

      Description copied from interface: `MediaSessionConnector.QueueNavigator`
      Called when the timeline of the player has changed.
      Specified by:
        `onTimelineChanged` in interface `MediaSessionConnector.QueueNavigator`
      Parameters:
        `player` - The player connected to the media session.

    - #### onCurrentWindowIndexChanged

          public final void onCurrentWindowIndexChanged​(Player player)

      Description copied from interface: `MediaSessionConnector.QueueNavigator`
      Called when the current window index changed.
      Specified by:
        `onCurrentWindowIndexChanged` in interface `MediaSessionConnector.QueueNavigator`
      Parameters:
        `player` - The player connected to the media session.

    - #### getActiveQueueItemId

          public final long getActiveQueueItemId​(@Nullable
                                                 Player player)

      Description copied from interface: `MediaSessionConnector.QueueNavigator`
      Gets the id of the currently active queue item, or `MediaSessionCompat.QueueItem.UNKNOWN_ID` if the active item is unknown.

      To let the connector publish metadata for the active queue item, the queue item with the returned id must be available in the list of items returned by `MediaControllerCompat.getQueue()`.

      Specified by:
        `getActiveQueueItemId` in interface `MediaSessionConnector.QueueNavigator`
      Parameters:
        `player` - The player connected to the media session.
      Returns:
        The id of the active queue item.

    - #### onSkipToPrevious

          public void onSkipToPrevious​(Player player,
                                       @Deprecated
                                       ControlDispatcher controlDispatcher)

      Description copied from interface: `MediaSessionConnector.QueueNavigator`
      See `MediaSessionCompat.Callback.onSkipToPrevious()`.
      Specified by:
        `onSkipToPrevious` in interface `MediaSessionConnector.QueueNavigator`
      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)`).

    - #### onSkipToQueueItem

          public void onSkipToQueueItem​(Player player,
                                        @Deprecated
                                        ControlDispatcher controlDispatcher,
                                        long id)

      Description copied from interface: `MediaSessionConnector.QueueNavigator`
      See `MediaSessionCompat.Callback.onSkipToQueueItem(long)`.
      Specified by:
        `onSkipToQueueItem` in interface `MediaSessionConnector.QueueNavigator`
      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)`).

    - #### onSkipToNext

          public void onSkipToNext​(Player player,
                                   @Deprecated
                                   ControlDispatcher controlDispatcher)

      Description copied from interface: `MediaSessionConnector.QueueNavigator`
      See `MediaSessionCompat.Callback.onSkipToNext()`.
      Specified by:
        `onSkipToNext` in interface `MediaSessionConnector.QueueNavigator`
      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)`).

    - #### 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.