androidx.media3.ui.compose.state

Classes

CuesState

State holder that converts Player.Listener.onCues events into a State of List and tracks the availability of text commands.

CurrentMediaItemState

A state holder that observes a Player and provides reactive updates for properties of the currently playing media item.

ErrorState

State holder that tracks the Player.getPlayerError by listening to Player.EVENT_PLAYER_ERROR and Player.EVENT_PLAYBACK_STATE_CHANGED.

MuteButtonState

State that holds all interactions to correctly deal with a UI component representing a Mute button.

NextButtonState

State that holds all interactions to correctly deal with a UI component representing a seek-to-next button.

PlayPauseButtonState

State that converts the necessary information from the Player to correctly deal with a UI component representing a PlayPause button.

PlaybackSpeedState

State that holds all interactions to correctly deal with a UI component representing a playback speed controller.

PlaybackState

A general-purpose, read-only state holder that observes and exposes the core playback states of a Player reactively for Compose UIs.

PlayerStateObserver

Utility to observe Player states by listening to events.

PlaylistState

State that holds information about the current playback playlist.

PresentationState

State that holds information to correctly deal with UI components related to the rendering of frames to a surface.

PreviousButtonState

State that holds all interactions to correctly deal with a UI component representing a seek-to-previous button.

ProgressStateWithTickCount

State that aims to hold accurate progress information (position, bufferedPosition, duration) that is required for a UI component representing a non-textual progress indicator, e.g. circular or linear.

ProgressStateWithTickInterval

State that holds playback progress information of a Player.

RepeatButtonState

State that holds all interactions to correctly deal with a UI component representing a Repeat On/All/Off button.

SeekBackButtonState

State that holds all interactions to correctly deal with a UI component representing a seek back button.

SeekForwardButtonState

State that holds all interactions to correctly deal with a UI component representing a seek forward button.

ShuffleButtonState

State that holds all interactions to correctly deal with a UI component representing a Shuffle On/Off button.

TrackSelectionOption

Represents a unique track configuration available for selection, based on the active TrackFilters.

TrackSelectionParametersState

A state holder that exposes the current Tracks and TrackSelectionParameters of a Player as Compose state.

TrackSelectionState

A state object that manages the track selection for a specific trackType.

Annotations

DisplayMode
OnOffState

Represents the track selection state for a specific track type.

TrackFilter

Supported filters for selecting specific tracks.

Composables

rememberCuesState

Remembers the value of CuesState created based on the passed Player and launches a coroutine to listen to Player's cue changes.

rememberCurrentMediaItemState

Remembers the value of CurrentMediaItemState created based on the passed Player and launch a coroutine to listen to Player's changes.

rememberErrorState

Remembers the value of ErrorState created based on the passed Player and launches a coroutine to listen to Player's error changes.

rememberMuteButtonState

Remembers the value of MuteButtonState created based on the passed Player and launch a coroutine to listen to Player's changes.

rememberNextButtonState

Remembers the value of NextButtonState created based on the passed Player and launch a coroutine to listen to Player's changes.

rememberPlayPauseButtonState

Remembers the value of PlayPauseButtonState created based on the passed Player and launch a coroutine to listen to Player's changes.

rememberPlaybackSpeedState

Remember the value of PlaybackSpeedState created based on the passed Player and launch a coroutine to listen to Player's changes.

rememberPlaybackState

Creates and remembers a PlaybackState for the given Player.

rememberPlaylistState

Remembers the value of PlaylistState created based on the passed Player and launch a coroutine to listen to Player's changes.

rememberPresentationState

Remembers the value of PresentationState created based on the passed Player and launches a coroutine to listen to Player's changes.

rememberPreviousButtonState

Remembers the value of PreviousButtonState created based on the passed Player and launch a coroutine to listen to Player's changes.

rememberProgressStateWithTickCount

Remember the value of ProgressStateWithTickCount created based on the passed Player and launch a coroutine to listen to Player's changes.

rememberProgressStateWithTickInterval

Remember the value of ProgressStateWithTickInterval created based on the passed Player and launch a coroutine to listen to Player's changes.

rememberRepeatButtonState

Remember the value of RepeatButtonState created based on the passed Player and launch a coroutine to listen to Player's changes.

rememberSeekBackButtonState

Remembers the value of SeekBackButtonState created based on the passed Player and launch a coroutine to listen to Player's changes.

rememberSeekForwardButtonState

Remembers the value of SeekForwardButtonState created based on the passed Player and launch a coroutine to listen to Player's changes.

rememberShuffleButtonState

Remember the value of ShuffleButtonState created based on the passed Player and launch a coroutine to listen to Player's changes.

rememberTrackSelectionParametersState

Remembers the value of TrackSelectionParametersState created based on the passed Player and launches a coroutine to listen to Player changes.

rememberTrackSelectionState

Remembers a TrackSelectionState for the given trackType and trackFilters.

Constants summary

const Long
const Long
const Int

The buffering view is always shown when the player is in the buffering state.

const Int

The buffering view is shown when the player is in the buffering state and shouldShowPlayButton is false.

const Int

The replay icon is shown when the player is in the ended state.

const Int

The retry icon is shown when the player has encountered an error.

const Int

Filter for selecting track language (applies to audio or text depending on track type).

const Int

Filter for selecting video MIME type (sampleMimeType).

const Int

Filter for selecting video resolution (width and height).

const Int

No specific preferences or constraints are applied for the active filters (the player chooses automatically).

const Int

The track type is explicitly disabled.

const Int

Specific preferences or constraints are applied for the active filters.

Extension functions summary

PlayerStateObserver
@UnstableApi
Player.observeState(
    firstEvent: @Player.Event Int,
    vararg otherEvents: Int,
    stateUpdater: (Player) -> Unit
)

Utility to observe Player states by listening to events.

PlayerStateObserver
@UnstableApi
Player.observeState(
    firstEvent: @Player.Event Int,
    vararg otherEvents: Int,
    stateUpdater: (Player, Player.Events) -> Unit
)

Utility to observe Player states by listening to events.

PlayerStateObserver
@UnstableApi
Player.observeState(
    firstEvent: @Player.Event Int,
    vararg otherEvents: Int,
    initialStateUpdater: (Player) -> Unit,
    stateUpdater: (Player, Player.Events) -> Unit
)

Utility to observe Player states by listening to events.

Constants

FALLBACK_UPDATE_INTERVAL_MS

@VisibleForTesting(otherwise = 2)
@UnstableApi
const val FALLBACK_UPDATE_INTERVAL_MS = 1000: Long

MIN_UPDATE_INTERVAL_MS

@UnstableApi
const val MIN_UPDATE_INTERVAL_MS = 8: Long

SHOW_BUFFERING_ALWAYS

@UnstableApi
const val SHOW_BUFFERING_ALWAYS: Int

The buffering view is always shown when the player is in the buffering state.

SHOW_BUFFERING_WHEN_PLAYING

@UnstableApi
const val SHOW_BUFFERING_WHEN_PLAYING: Int

The buffering view is shown when the player is in the buffering state and shouldShowPlayButton is false.

SHOW_REPLAY_ON_ENDED

@UnstableApi
const val SHOW_REPLAY_ON_ENDED: Int

The replay icon is shown when the player is in the ended state.

SHOW_RETRY_ON_ERROR

@UnstableApi
const val SHOW_RETRY_ON_ERROR: Int

The retry icon is shown when the player has encountered an error.

TRACK_FILTER_LANGUAGE

@UnstableApi
const val TRACK_FILTER_LANGUAGE: Int

Filter for selecting track language (applies to audio or text depending on track type).

TRACK_FILTER_MIME_TYPE

@UnstableApi
const val TRACK_FILTER_MIME_TYPE: Int

Filter for selecting video MIME type (sampleMimeType).

TRACK_FILTER_RESOLUTION

@UnstableApi
const val TRACK_FILTER_RESOLUTION: Int

Filter for selecting video resolution (width and height).

TRACK_SELECTION_AUTO

@UnstableApi
const val TRACK_SELECTION_AUTO = 1: Int

No specific preferences or constraints are applied for the active filters (the player chooses automatically).

TRACK_SELECTION_OFF

@UnstableApi
const val TRACK_SELECTION_OFF = 0: Int

The track type is explicitly disabled.

TRACK_SELECTION_ON

@UnstableApi
const val TRACK_SELECTION_ON = 2: Int

Specific preferences or constraints are applied for the active filters.

Extension functions

Player.observeState

@UnstableApi
fun Player.observeState(
    firstEvent: @Player.Event Int,
    vararg otherEvents: Int,
    stateUpdater: (Player) -> Unit
): PlayerStateObserver

Utility to observe Player states by listening to events.

Parameters
firstEvent: @Player.Event Int

The first Player.Event to listen to.

vararg otherEvents: Int

Additional Player.Event types to listen to.

stateUpdater: (Player) -> Unit

The operation to trigger initially and whenever one of the configured events happen.

Player.observeState

@UnstableApi
fun Player.observeState(
    firstEvent: @Player.Event Int,
    vararg otherEvents: Int,
    stateUpdater: (Player, Player.Events) -> Unit
): PlayerStateObserver

Utility to observe Player states by listening to events.

Parameters
firstEvent: @Player.Event Int

The first Player.Event to listen to.

vararg otherEvents: Int

Additional Player.Event types to listen to.

stateUpdater: (Player, Player.Events) -> Unit

The operation to trigger initially (with all configured Player.Events) and whenever one of the configured events happen.

Player.observeState

@UnstableApi
fun Player.observeState(
    firstEvent: @Player.Event Int,
    vararg otherEvents: Int,
    initialStateUpdater: (Player) -> Unit,
    stateUpdater: (Player, Player.Events) -> Unit
): PlayerStateObserver

Utility to observe Player states by listening to events.

Parameters
firstEvent: @Player.Event Int

The first Player.Event to listen to.

vararg otherEvents: Int

Additional Player.Event types to listen to.

initialStateUpdater: (Player) -> Unit

The operation to trigger initially on creation and when PlayerStateObserver.observe starts.

stateUpdater: (Player, Player.Events) -> Unit

The operation to trigger whenever one of the configured events happen.