public final class Cue


Contains information about a specific cue, including textual content and formatting data.

Summary

Nested types

@Documented
@Retention(value = RetentionPolicy.SOURCE)
@Target(value = )
@IntDef(value = )
public annotation Cue.AnchorType

The type of anchor, which may be unset.

@UnstableApi
public final class Cue.Builder

A builder for Cue objects.

@Documented
@Retention(value = RetentionPolicy.SOURCE)
@Target(value = )
@IntDef(value = )
public annotation Cue.LineType

The type of line, which may be unset.

@Documented
@Retention(value = RetentionPolicy.SOURCE)
@Target(value = )
@IntDef(value = )
public annotation Cue.TextSizeType

The type of default text size for this cue, which may be unset.

@Documented
@Retention(value = RetentionPolicy.SOURCE)
@Target(value = )
@IntDef(value = )
public annotation Cue.VerticalType

The type of vertical layout for this cue, which may be unset (i.e. horizontal).

Constants

static final int

Anchors the right (for horizontal positions) or bottom (for vertical positions) edge of the cue box.

static final int

Anchors the middle of the cue box.

static final int

Anchors the left (for horizontal positions) or top (for vertical positions) edge of the cue box.

static final float
DIMEN_UNSET = -3.4028235E38f

An unset position, width or size.

static final Cue

This field is deprecated.

There's no general need for a cue with an empty text string.

static final int

Value for lineType when line is a fractional position.

static final int

Value for lineType when line is a line number.

static final int

Text size is measured in number of pixels.

static final int

Text size is measured as a fraction of the viewport size minus the view padding.

static final int

Text size is measured as a fraction of the viewport size, ignoring the view padding

static final int
TYPE_UNSET = -2147483648

An unset anchor, line, text size or vertical type value.

static final int

Vertical left-to-right (e.g. for Mongolian).

static final int

Vertical right-to-left (e.g. for Japanese).

Public fields

final @Nullable Bitmap

The cue image, or null if this is a text cue.

final float

The bitmap height as a fraction of the of the viewport size, or DIMEN_UNSET if the bitmap should be displayed at its natural height given the bitmap dimensions and the specified size.

final float

The position of the cue box within the viewport in the direction orthogonal to the writing direction (determined by verticalType), or DIMEN_UNSET.

final int

The cue box anchor positioned by line when lineType is LINE_TYPE_FRACTION.

final int

The type of the line value.

final @Nullable Layout.Alignment

The alignment of multiple lines of text relative to the longest line, or null if the alignment is undefined.

final float

The fractional position of the positionAnchor of the cue box within the viewport in the direction orthogonal to line, or DIMEN_UNSET.

final int

The cue box anchor positioned by position.

final float

The shear angle in degrees to be applied to this Cue, expressed in graphics coordinates.

final float

The size of the cue box in the writing direction specified as a fraction of the viewport size in that direction, or DIMEN_UNSET.

final @Nullable CharSequence

The cue text, or null if this is an image cue.

final @Nullable Layout.Alignment

The alignment of the cue text within the cue box, or null if the alignment is undefined.

final float

The default text size for this cue's text, or DIMEN_UNSET if this cue has no default text size.

final int

The default text size type for this cue's text, or TYPE_UNSET if this cue has no default text size.

final int

The vertical formatting of this Cue, or TYPE_UNSET if the cue has no vertical setting (and so should be horizontal).

final int

The fill color of the window.

final boolean

Specifies whether or not the windowColor property is set.

Public methods

Cue.Builder

Returns a new Cue.Builder initialized with the same values as this Cue.

boolean
static Cue

Restores a cue from a Bundle.

int
Bundle

Returns a Bundle that may contain Binder references, meaning it cannot be safely serialized to bytes.

Bundle

This method is deprecated.

Use toSerializableBundle or toBinderBasedBundle instead.

Bundle

Returns a Bundle that can be serialized to bytes.

Constants

ANCHOR_TYPE_END

public static final int ANCHOR_TYPE_END = 2

Anchors the right (for horizontal positions) or bottom (for vertical positions) edge of the cue box.

ANCHOR_TYPE_MIDDLE

public static final int ANCHOR_TYPE_MIDDLE = 1

Anchors the middle of the cue box.

ANCHOR_TYPE_START

public static final int ANCHOR_TYPE_START = 0

Anchors the left (for horizontal positions) or top (for vertical positions) edge of the cue box.

DIMEN_UNSET

public static final float DIMEN_UNSET = -3.4028235E38f

An unset position, width or size.

EMPTY

public static final Cue EMPTY

LINE_TYPE_FRACTION

public static final int LINE_TYPE_FRACTION = 0

Value for lineType when line is a fractional position.

LINE_TYPE_NUMBER

public static final int LINE_TYPE_NUMBER = 1

Value for lineType when line is a line number.

TEXT_SIZE_TYPE_ABSOLUTE

public static final int TEXT_SIZE_TYPE_ABSOLUTE = 2

Text size is measured in number of pixels.

TEXT_SIZE_TYPE_FRACTIONAL

public static final int TEXT_SIZE_TYPE_FRACTIONAL = 0

Text size is measured as a fraction of the viewport size minus the view padding.

TEXT_SIZE_TYPE_FRACTIONAL_IGNORE_PADDING

public static final int TEXT_SIZE_TYPE_FRACTIONAL_IGNORE_PADDING = 1

Text size is measured as a fraction of the viewport size, ignoring the view padding

TYPE_UNSET

public static final int TYPE_UNSET = -2147483648

An unset anchor, line, text size or vertical type value.

VERTICAL_TYPE_LR

public static final int VERTICAL_TYPE_LR = 2

Vertical left-to-right (e.g. for Mongolian).

VERTICAL_TYPE_RL

public static final int VERTICAL_TYPE_RL = 1

Vertical right-to-left (e.g. for Japanese).

Public fields

bitmap

public final @Nullable Bitmap bitmap

The cue image, or null if this is a text cue.

bitmapHeight

public final float bitmapHeight

The bitmap height as a fraction of the of the viewport size, or DIMEN_UNSET if the bitmap should be displayed at its natural height given the bitmap dimensions and the specified size.

line

public final float line

The position of the cue box within the viewport in the direction orthogonal to the writing direction (determined by verticalType), or DIMEN_UNSET. When set, the interpretation of the value depends on the value of lineType.

The measurement direction depends on verticalType:

  • For TYPE_UNSET (i.e. horizontal), this is the vertical position relative to the top of the viewport.
  • For VERTICAL_TYPE_LR this is the horizontal position relative to the left of the viewport.
  • For VERTICAL_TYPE_RL this is the horizontal position relative to the right of the viewport.

lineAnchor

@Cue.AnchorType
public final int lineAnchor

The cue box anchor positioned by line when lineType is LINE_TYPE_FRACTION.

One of:

For the normal case of horizontal text, ANCHOR_TYPE_START, ANCHOR_TYPE_MIDDLE and ANCHOR_TYPE_END correspond to the top, middle and bottom of the cue box respectively.

lineType

@Cue.LineType
public final int lineType

The type of the line value.

  • LINE_TYPE_FRACTION indicates that line is a fractional position within the viewport (measured to the part of the cue box determined by lineAnchor).
  • LINE_TYPE_NUMBER indicates that line is a viewport line number. The viewport is divided into lines (each equal in size to the first line of the cue box). The cue box is positioned to align with the viewport lines as follows:
    • lineAnchor) is ignored.
    • When line is greater than or equal to 0 the first line in the cue box is aligned with a viewport line, with 0 meaning the first line of the viewport.
    • When line is negative the last line in the cue box is aligned with a viewport line, with -1 meaning the last line of the viewport.
    • For horizontal text the start and end of the viewport are the top and bottom respectively.

multiRowAlignment

public final @Nullable Layout.Alignment multiRowAlignment

The alignment of multiple lines of text relative to the longest line, or null if the alignment is undefined.

position

public final float position

The fractional position of the positionAnchor of the cue box within the viewport in the direction orthogonal to line, or DIMEN_UNSET.

The measurement direction depends on verticalType.

  • For TYPE_UNSET (i.e. horizontal), this is the horizontal position relative to the left of the viewport. Note that positioning is relative to the left of the viewport even in the case of right-to-left text.
  • For VERTICAL_TYPE_LR and VERTICAL_TYPE_RL (i.e. vertical), this is the vertical position relative to the top of the viewport.

positionAnchor

@Cue.AnchorType
public final int positionAnchor

The cue box anchor positioned by position. One of ANCHOR_TYPE_START, ANCHOR_TYPE_MIDDLE, ANCHOR_TYPE_END and TYPE_UNSET.

For the normal case of horizontal text, ANCHOR_TYPE_START, ANCHOR_TYPE_MIDDLE and ANCHOR_TYPE_END correspond to the left, middle and right of the cue box respectively.

shearDegrees

public final float shearDegrees

The shear angle in degrees to be applied to this Cue, expressed in graphics coordinates. This results in a skew transform for the block along the inline progression axis.

size

public final float size

The size of the cue box in the writing direction specified as a fraction of the viewport size in that direction, or DIMEN_UNSET.

text

public final @Nullable CharSequence text

The cue text, or null if this is an image cue. Note the CharSequence may be decorated with styling spans.

textAlignment

public final @Nullable Layout.Alignment textAlignment

The alignment of the cue text within the cue box, or null if the alignment is undefined.

textSize

public final float textSize

The default text size for this cue's text, or DIMEN_UNSET if this cue has no default text size.

textSizeType

@Cue.TextSizeType
public final int textSizeType

The default text size type for this cue's text, or TYPE_UNSET if this cue has no default text size.

verticalType

@Cue.VerticalType
public final int verticalType

The vertical formatting of this Cue, or TYPE_UNSET if the cue has no vertical setting (and so should be horizontal).

windowColor

public final int windowColor

The fill color of the window.

windowColorSet

public final boolean windowColorSet

Specifies whether or not the windowColor property is set.

Public methods

buildUpon

@UnstableApi
public Cue.Builder buildUpon()

Returns a new Cue.Builder initialized with the same values as this Cue.

equals

public boolean equals(@Nullable Object obj)

fromBundle

@UnstableApi
public static Cue fromBundle(Bundle bundle)

Restores a cue from a Bundle.

hashCode

public int hashCode()

toBinderBasedBundle

@UnstableApi
public Bundle toBinderBasedBundle()

Returns a Bundle that may contain Binder references, meaning it cannot be safely serialized to bytes.

The Bundle returned from this method can be safely sent between processes and parsed by older versions of the media3 library.

Use toSerializableBundle to get a Bundle that can be safely serialized.

toBundle

@UnstableApi
public Bundle toBundle()

toSerializableBundle

@UnstableApi
public Bundle toSerializableBundle()

Returns a Bundle that can be serialized to bytes.

Prefer the more efficient toBinderBasedBundle if the result doesn't need to be serialized.

The Bundle returned from this method must not be passed to other processes that might be using a different version of the media3 library.