Last active
June 26, 2024 20:49
-
-
Save arriolac/8c218b37632cf7eeba322a7a73eeea06 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright 2023 Google LLC. | |
// SPDX-License-Identifier: Apache-2.0 | |
@Composable | |
fun EpisodePlayerWithBackground(/* ... */) { | |
// Initialize a FocusRequester object | |
val focusRequester = remember { FocusRequester() } | |
LaunchedEffect(Unit) { | |
// Request d-pad focus so the associated component is focused | |
focusRequester.requestFocus() | |
} | |
// The layout of the player screen and its components are defined here. | |
// | |
// The FocusRequester object is passed down to PlayPauseButton | |
// that is associated with the FocusRequester object. | |
PlayPauseButton( | |
isPlaying = isPlaying, | |
onClick = { | |
if (isPlaying) { | |
pause() | |
} else { | |
play() | |
} | |
}, | |
// The FocusReqester object is associated with the button via Modifier | |
modifier = Modifier.focusRequester(focusRequester) | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment