@UnstableApi
class PlaylistState


State that holds information about the current playback playlist.

This state does not have a one-on-one relationship with a UI component like a button, icon, or slider. Instead, it logically groups various playlist-related concepts and values that can be displayed on the screen dynamically.

Summary

Public constructors

Public functions

MediaItem

Returns the MediaItem at the given index in the playlist.

suspend Unit

Subscribes to updates from Player.Events and listens to

Unit

Seeks to the default position of the media item at the given index in the playlist.

Public properties

Int

The index of the current MediaItem.

Int

The total number of media items in the playlist.

MediaMetadata

The MediaMetadata of the entire playlist.

Timeline

The current Timeline of the player.

Public constructors

PlaylistState

PlaylistState(player: Player?)
Parameters
player: Player?

The Player instance to observe.

Public functions

getMediaItemAt

fun getMediaItemAt(index: Int): MediaItem

Returns the MediaItem at the given index in the playlist.

Throws
IndexOutOfBoundsException

if the index is out of bounds.

seekToMediaItem

fun seekToMediaItem(index: Int): Unit

Seeks to the default position of the media item at the given index in the playlist.

This method does nothing if the player is null or Player.COMMAND_SEEK_TO_MEDIA_ITEM is not available.

Parameters
index: Int

The index of the media item to seek to.

Public properties

currentMediaItemIndex

val currentMediaItemIndexInt

The index of the current MediaItem. C.INDEX_UNSET if playlist is empty or command is not available.

mediaItemCount

val mediaItemCountInt

The total number of media items in the playlist. 0 if playlist is empty or command is not available.

playlistMetadata

val playlistMetadataMediaMetadata

The MediaMetadata of the entire playlist. MediaMetadata.EMPTY if not set or command is not available.

timeline

val timelineTimeline

The current Timeline of the player. Timeline.EMPTY if playlist is empty or command is not available.