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 |
Subscribes to updates from |
Public properties |
|
|---|---|
Boolean |
set to false when the Player emits |
Boolean |
|
Player? |
@VisibleForTesting(otherwise = 2) |
Size? |
wraps |
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
-
Player.EVENT_VIDEO_SIZE_CHANGEDto determine pixelWidthHeightRatio-adjusted video size -
Player.EVENT_RENDERED_FIRST_FRAMEandPlayer.EVENT_TRACKS_CHANGEDto determine whether the surface is ready to be shown
Public properties
coverSurface
val coverSurface: 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.
videoSizeDp
val videoSizeDp: Size?
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.