ContentFrame

Functions summary

Unit
@UnstableApi
@Composable
ContentFrame(
    player: Player?,
    modifier: Modifier,
    surfaceType: @SurfaceType Int,
    contentScale: ContentScale,
    alignment: Alignment,
    keepContentOnReset: Boolean,
    artwork: (@Composable () -> Unit)?,
    subtitles: @Composable () -> Unit,
    shutter: @Composable () -> Unit
)

A container for displaying media content from a Player.

Functions

@UnstableApi
@Composable
fun ContentFrame(
    player: Player?,
    modifier: Modifier = Modifier,
    surfaceType: @SurfaceType Int = SURFACE_TYPE_SURFACE_VIEW,
    contentScale: ContentScale = ContentScale.Fit,
    alignment: Alignment = Alignment.Center,
    keepContentOnReset: Boolean = false,
    artwork: (@Composable () -> Unit)? = { Artwork( player, modifier = Modifier.fillMaxSize(), alignment = alignment, contentScale = contentScale, ) },
    subtitles: @Composable () -> Unit = {},
    shutter: @Composable () -> Unit = { Box(Modifier.fillMaxSize().background(Color.Black)) }
): Unit

A container for displaying media content from a Player.

This composable handles the underlying PlayerSurface for video playback, resizing the video based on the provided ContentScale, and displaying a shutter and artwork according to the PresentationState based off the Player. Content that overflows the bounds of this container, for example video scaled with ContentScale.Crop, is clipped.

The layers are drawn in the following order, from bottom to top: the PlayerSurface, the shutter, the artwork and the subtitles.

Parameters
player: Player?

The attached Player that provides media to this content frame.

modifier: Modifier = Modifier

The Modifier to be applied to the layout.

surfaceType: @SurfaceType Int = SURFACE_TYPE_SURFACE_VIEW

The type of surface to use for video playback. Can be either SURFACE_TYPE_SURFACE_VIEW or SURFACE_TYPE_TEXTURE_VIEW.

contentScale: ContentScale = ContentScale.Fit

The ContentScale strategy for the container.

alignment: Alignment = Alignment.Center

The Alignment used to position the scaled content within the container. If the scaled content overflows the container, for example with ContentScale.Crop, the alignment determines which part of the content is visible.

keepContentOnReset: Boolean = false

If true, the last rendered frame will remain visible when the player is reset. If false, the surface will be cleared.

artwork: (@Composable () -> Unit)? = { Artwork( player, modifier = Modifier.fillMaxSize(), alignment = alignment, contentScale = contentScale, ) }

Optional composable slot to render artwork for the current media item.

subtitles: @Composable () -> Unit = {}

A composable that displays subtitles. It is drawn on top of the shutter and the artwork, so that subtitles remain visible when there is no video, and it is laid out within the same bounds as the scaled video surface.

shutter: @Composable () -> Unit = { Box(Modifier.fillMaxSize().background(Color.Black)) }

A composable that is displayed when the video surface needs to be covered. By default, this is a black background.