[ui-compose] Add KDoc to observe() methods for button states

#cherrypick

PiperOrigin-RevId: 731686021
(cherry picked from commit b465cbc22c61acc07875550d1c1f24aa5d080f13)
This commit is contained in:
jbibik 2025-02-27 05:19:55 -08:00 committed by oceanjules
parent c66c221b28
commit c7fa2c3de6
5 changed files with 29 additions and 0 deletions

View File

@ -56,6 +56,11 @@ class NextButtonState(private val player: Player) {
player.seekToNext()
}
/**
* Subscribes to updates from [Player.Events] and listens to
* [Player.EVENT_AVAILABLE_COMMANDS_CHANGED] in order to determine whether the button should be
* enabled, i.e. respond to user input.
*/
suspend fun observe(): Nothing =
player.listen { events ->
if (events.contains(Player.EVENT_AVAILABLE_COMMANDS_CHANGED)) {

View File

@ -79,6 +79,12 @@ class PresentationState(private val player: Player) {
private var lastPeriodUidWithTracks: Any? = null
/**
* Subscribes to updates from [Player.Events] and listens to
* * [Player.EVENT_VIDEO_SIZE_CHANGED] to determine pixelWidthHeightRatio-adjusted video size
* * [Player.EVENT_RENDERED_FIRST_FRAME] and [Player.EVENT_TRACKS_CHANGED]to determine whether the
* surface is ready to be shown
*/
suspend fun observe(): Nothing =
player.listen { events ->
if (events.contains(Player.EVENT_VIDEO_SIZE_CHANGED)) {

View File

@ -56,6 +56,11 @@ class PreviousButtonState(private val player: Player) {
player.seekToPrevious()
}
/**
* Subscribes to updates from [Player.Events] and listens to
* [Player.EVENT_AVAILABLE_COMMANDS_CHANGED] in order to determine whether the button should be
* enabled, i.e. respond to user input.
*/
suspend fun observe(): Nothing =
player.listen { events ->
if (events.contains(Player.EVENT_AVAILABLE_COMMANDS_CHANGED)) {

View File

@ -80,6 +80,12 @@ class RepeatButtonState(
player.repeatMode = getNextRepeatModeInSequence()
}
/**
* Subscribes to updates from [Player.Events] and listens to
* * [Player.EVENT_REPEAT_MODE_CHANGED] in order to determine the latest [Player.getRepeatMode].
* * [Player.EVENT_AVAILABLE_COMMANDS_CHANGED] in order to determine whether the button should be
* enabled, i.e. respond to user input.
*/
suspend fun observe(): Nothing =
player.listen { events ->
if (

View File

@ -58,6 +58,13 @@ class ShuffleButtonState(private val player: Player) {
player.shuffleModeEnabled = !player.shuffleModeEnabled
}
/**
* Subscribes to updates from [Player.Events] and listens to
* * [Player.EVENT_SHUFFLE_MODE_ENABLED_CHANGED] in order to determine the latest
* [Player.getShuffleModeEnabled].
* * [Player.EVENT_AVAILABLE_COMMANDS_CHANGED] in order to determine whether the button should be
* enabled, i.e. respond to user input.
*/
suspend fun observe(): Nothing =
player.listen { events ->
if (