Skip to content

Instantly share code, notes, and snippets.

@arriolac
Last active June 26, 2024 20:49
Show Gist options
  • Save arriolac/8c218b37632cf7eeba322a7a73eeea06 to your computer and use it in GitHub Desktop.
Save arriolac/8c218b37632cf7eeba322a7a73eeea06 to your computer and use it in GitHub Desktop.
// 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