@UnstableApi
class CueUtil


Utility methods and constants for Cue layout and styling.

Summary

Constants

const Float

The default bottom padding to apply when line is DIMEN_UNSET, as a fraction of the viewport height.

const Float

The default fractional text size, as a fraction of the viewport height.

Public functions

java-static Float
resolveAnchorOffset(
    fractionalPosition: Float,
    @Cue.AnchorType anchorType: Int,
    cueDimension: Int,
    viewDimension: Int
)

Calculates the pixel offset for placing a cue along a given axis (X or Y) relative to the viewport.

java-static Float
resolveTextSize(
    @Cue.TextSizeType textSizeType: Int,
    textSize: Float,
    rawViewHeight: Int,
    viewHeightMinusPadding: Int
)

Returns the text size in px, derived from textSize and textSizeType.

Constants

DEFAULT_BOTTOM_PADDING_FRACTION

const val DEFAULT_BOTTOM_PADDING_FRACTION = 0.08f: Float

The default bottom padding to apply when line is DIMEN_UNSET, as a fraction of the viewport height.

DEFAULT_TEXT_SIZE_FRACTION

const val DEFAULT_TEXT_SIZE_FRACTION = 0.0533f: Float

The default fractional text size, as a fraction of the viewport height.

Public functions

resolveAnchorOffset

java-static fun resolveAnchorOffset(
    fractionalPosition: Float,
    @Cue.AnchorType anchorType: Int,
    cueDimension: Int,
    viewDimension: Int
): Float

Calculates the pixel offset for placing a cue along a given axis (X or Y) relative to the viewport.

If fractionalPosition is DIMEN_UNSET, the cue is centered within the viewport. Otherwise, the offset is determined by aligning the specified anchorType of the cue with the fractionalPosition of the viewport.

Parameters
fractionalPosition: Float

The position of the cue's anchor, expressed as a fraction (between 0 and 1) of viewDimension, or DIMEN_UNSET.

@Cue.AnchorType anchorType: Int

The anchor type (e.g., ANCHOR_TYPE_START, ANCHOR_TYPE_MIDDLE, ANCHOR_TYPE_END).

cueDimension: Int

The pixel dimension (width or height) of the cue.

viewDimension: Int

The pixel dimension (width or height) of the viewport.

Returns
Float

The pixel offset of the start (top or left) of the cue, relative to the start (top or left) of the viewport.

resolveTextSize

java-static fun resolveTextSize(
    @Cue.TextSizeType textSizeType: Int,
    textSize: Float,
    rawViewHeight: Int,
    viewHeightMinusPadding: Int
): Float

Returns the text size in px, derived from textSize and textSizeType.

Returns DIMEN_UNSET if textSize == Cue.DIMEN_UNSET or textSizeType == Cue.TYPE_UNSET.