Player

Functions summary

Unit
@UnstableApi
@Composable
Player(player: Player?, modifier: Modifier)

A composable that provides a basic player UI layout with default controls and a shutter.

Unit
@ExperimentalApi
@Composable
Player(
    player: Player?,
    modifier: Modifier,
    surfaceType: @SurfaceType Int,
    contentScale: ContentScale,
    keepContentOnReset: Boolean,
    shutter: @Composable () -> Unit,
    showControls: Boolean,
    topControls: (@Composable BoxScope.(Player?, Boolean) -> Unit)?,
    centerControls: (@Composable BoxScope.(Player?, Boolean) -> Unit)?,
    bottomControls: (@Composable BoxScope.(Player?, Boolean) -> Unit)?,
    errorOverlay: (@Composable BoxScope.(Player?) -> Unit)?
)

A composable that provides a basic player UI layout, combining a ContentFrame for displaying player content with customizable controls and a shutter.

Functions

@UnstableApi
@Composable
fun Player(player: Player?, modifier: Modifier = Modifier): Unit

A composable that provides a basic player UI layout with default controls and a shutter.

This composable consists of a ContentFrame that handles the rendering of the player's video, overlaid with default button controls, progress slider, and a shutter.

This component uses the standard Material3 layouts provided by PlayerDefaults. This includes PlayerDefaults.TopControls, PlayerDefaults.CenterControls, and PlayerDefaults.BottomControls.

To customize the UI components, use the overload that accepts these as parameters.

Parameters
player: Player?

The Player instance to be controlled and whose content is displayed.

modifier: Modifier = Modifier

The Modifier to be applied to the outer Box.

@ExperimentalApi
@Composable
fun Player(
    player: Player?,
    modifier: Modifier = Modifier,
    surfaceType: @SurfaceType Int = SURFACE_TYPE_SURFACE_VIEW,
    contentScale: ContentScale = ContentScale.Fit,
    keepContentOnReset: Boolean = false,
    shutter: @Composable () -> Unit = PlayerDefaults::Shutter,
    showControls: Boolean = false,
    topControls: (@Composable BoxScope.(Player?, Boolean) -> Unit)? = { player, showControls -> PlayerDefaults.TopControls(player, showControls, Modifier.fillMaxWidth()) },
    centerControls: (@Composable BoxScope.(Player?, Boolean) -> Unit)? = { player, showControls -> PlayerDefaults.CenterControls(player, showControls, Modifier.fillMaxWidth()) },
    bottomControls: (@Composable BoxScope.(Player?, Boolean) -> Unit)? = { player, showControls -> PlayerDefaults.BottomControls(player, showControls) },
    errorOverlay: (@Composable BoxScope.(Player?) -> Unit)? = { PlayerDefaults.ErrorOverlay(it) }
): Unit

A composable that provides a basic player UI layout, combining a ContentFrame for displaying player content with customizable controls and a shutter.

This composable is designed to be a flexible container for building player interfaces. It consists of a ContentFrame that handles the rendering of the player's video, overlaid with optional controls and a shutter.

By default, this component uses the standard Material3 layouts provided by PlayerDefaults. This includes PlayerDefaults.TopControls, PlayerDefaults.CenterControls, and PlayerDefaults.BottomControls. You can deeply customize the player UI by providing your own composables to the slots of this composable, or by utilizing the PlayerDefaults layouts and overriding only specific slots within them.

The Player natively manages keyboard focus traversal between its control slots. Each provided control slot (topControls, centerControls, and bottomControls) is wrapped in a focus group. 1-dimensional focus traversal (e.g., using the Tab key) is configured to move sequentially from the top controls, to the center controls, and down to the bottom controls. Backward traversal moves in the reverse order.

Parameters
player: Player?

The Player instance to be controlled and whose content is displayed.

modifier: Modifier = Modifier

The Modifier to be applied to the outer Box.

surfaceType: @SurfaceType Int = SURFACE_TYPE_SURFACE_VIEW

The type of surface to use for video rendering. See SurfaceType.

contentScale: ContentScale = ContentScale.Fit

The scaling mode to apply to the content within the ContentFrame.

keepContentOnReset: Boolean = false

Whether to keep the content visible when the player is reset.

shutter: @Composable () -> Unit = PlayerDefaults::Shutter

A composable to be displayed as a shutter over the content. The default shutter is a black Box.

showControls: Boolean = false

Whether the controls should be visible. False by default.

topControls: (@Composable BoxScope.(Player?, Boolean) -> Unit)? = { player, showControls -> PlayerDefaults.TopControls(player, showControls, Modifier.fillMaxWidth()) }

A composable aligned with Alignment.TopCenter, receiving the player and showControls.

centerControls: (@Composable BoxScope.(Player?, Boolean) -> Unit)? = { player, showControls -> PlayerDefaults.CenterControls(player, showControls, Modifier.fillMaxWidth()) }

A composable aligned with Alignment.Center, receiving the player and showControls.

bottomControls: (@Composable BoxScope.(Player?, Boolean) -> Unit)? = { player, showControls -> PlayerDefaults.BottomControls(player, showControls) }

A composable aligned with Alignment.BottomCenter, receiving the player and showControls.

errorOverlay: (@Composable BoxScope.(Player?) -> Unit)? = { PlayerDefaults.ErrorOverlay(it) }

Slot for the error message overlay. Defaults to PlayerDefaults.ErrorOverlay.