PresentationState

@UnstableApi
class PresentationState


State that holds information to correctly deal with UI components related to the rendering of frames to a surface.

Summary

Public constructors

PresentationState(keepContentOnReset: Boolean)

Public functions

suspend Unit
observe(player: Player?)

Subscribes to updates from Player.Events and listens to

Public properties

Boolean

set to false when the Player emits Player.EVENT_RENDERED_FIRST_FRAME and reset back to true on Player.EVENT_TRACKS_CHANGED depending on the number and type of tracks.

Boolean
Player?
@VisibleForTesting(otherwise = 2)
player
Size?

wraps Player.getVideoSize in Compose's Size, becomes null when either height or width of the video is zero.

Public constructors

PresentationState

PresentationState(keepContentOnReset: Boolean = false)
Parameters
keepContentOnReset: Boolean = false

whether the currently displayed video frame or media artwork is kept visible when tracks change or player changes. Defaults to false.

Public functions

observe

suspend fun observe(player: Player?): Unit

Subscribes to updates from Player.Events and listens to

Public properties

coverSurface

val coverSurfaceBoolean

set to false when the Player emits Player.EVENT_RENDERED_FIRST_FRAME and reset back to true on Player.EVENT_TRACKS_CHANGED depending on the number and type of tracks.

keepContentOnReset

var keepContentOnResetBoolean

player

@VisibleForTesting(otherwise = 2)
var playerPlayer?

videoSizeDp

val videoSizeDpSize?

wraps Player.getVideoSize in Compose's Size, becomes null when either height or width of the video is zero. Takes into account VideoSize.pixelWidthHeightRatio to return a Size in Dp, i.e. device-independent pixel. To use this measurement in Compose's Drawing and Layout stages, convert it into pixels using Density.toPx. Note that for cases where pixelWidthHeightRatio is not equal to 1, the rescaling will be down, i.e. reducing the width or the height to achieve the same aspect ratio in square pixels.