Class CaptionPosition
This is the Android analogue of the iOS SDK's JWCaptionPosition, and is attached to
CaptionsConfig.getPosition().
Coordinates are relative to the rendered video, not to the player. In a letterboxed or
pillarboxed layout the black bars are excluded, so linePercentage(100) is the bottom edge
of the video image rather than the bottom edge of the player view. This matches iOS, which
positions captions within the video rendering surface's videoRect. When the video fills
the player there is no difference between the two.
This is a default, not an override. It applies only to caption cues that carry no positioning of their own, so the precedence is:
- positioning parsed from the caption track itself (WebVTT cue settings, TTML region attributes, CEA-608/708 row and column codes);
- this object;
- the player default — horizontally centered, near the bottom of the rendered video.
SRT carries no positional data at all, so SRT cues always take this position. Most WebVTT cues also carry no settings and so take it too, while CEA-608/708 cues are positioned by the broadcast data and are left alone.
A position set here is honored as given. Unpositioned captions are nudged up to clear the control bar while it is visible; a caption placed through this object is not, matching iOS. A caption placed low in the video can therefore sit behind the control bar while it is on screen.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic @interfacestatic class -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe caption text is centered within the caption box.static final StringThe caption text is flush with the leading edge of the caption box.static final StringThe caption text is flush with the trailing edge of the caption box.final Stringfinal Integerfinal Integerfinal Integerfinal Integer -
Method Summary
-
Field Details
-
ALIGNMENT_LEFT
The caption text is flush with the leading edge of the caption box.- See Also:
-
ALIGNMENT_CENTER
The caption text is centered within the caption box. This is the default.- See Also:
-
ALIGNMENT_RIGHT
The caption text is flush with the trailing edge of the caption box.- See Also:
-
mWidth
-
mAlignment
-
mHorizontalPosition
-
mLinePercentage
-
mLineIndex
-
-
Method Details
-
getWidth
- Returns:
- The width of the caption box as a percentage of the rendered video width, in the
range [0, 100], or
nullto size the box to fit the caption text.
-
getAlignment
- Returns:
- The alignment of the caption text within the caption box, one of the
ALIGNMENT_constants, ornullfor the default (ALIGNMENT_CENTER).ALIGNMENT_LEFTandALIGNMENT_RIGHTare resolved against the layout direction, so they read as leading and trailing in a right-to-left locale. This matches iOS.
-
getHorizontalPosition
- Returns:
- The leading edge of the caption box as a percentage of the rendered video width, in
the range [0, 100], or
nullto center the box.
-
getLinePercentage
- Returns:
- The top edge of the caption box as a percentage of the rendered video height measured
from the top, in the range [0, 100], or
nullto position bygetLineIndex()instead.
-
getLineIndex
- Returns:
- The vertical position of the caption box as a line count, or
nullto position bygetLinePercentage()instead. A non-negative value counts lines down from the top of the rendered video; a negative value counts lines up from the bottom, so-1is the bottom line.At most one of this and
getLinePercentage()is ever set.
-