BlazeCaptionsStyle
BlazeCaptionsStyle controls how closed captions look inside the Experiences player: caption font and the position of the captions box.
The same type is shared by Moments, Stories, and Videos through the captions property on:
Use this type for how captions look on screen. To show or hide the CC button, set the buttons style on the player instead.
Properties
font
var font: UIFont?Font used for captions text.
- Pass a custom
UIFontto set the caption typeface. The SDK embeds that font in the captions web view with@font-face, and uses the font's point size as the base caption size (then scales it for the viewer's accessibility text-size setting). - Pass
nilto keep the caption renderer's default font family and apply only the default size.
positioning
var positioning: BlazeCaptionsPositioningPosition of the captions box in the player. See BlazeCaptionsPositioning below.
Use BlazeCaptionsPositioning.base() for the renderer's default look (leading / top). When positioning stays at .base(), the SDK leaves the native caption layout unchanged.
Default values
BlazeCaptionsStyle has no public initializer. Each player preset already includes a captions style. Start from a preset player style and override only what you need.
The captions style starts from these defaults:
| Property | Default value |
|---|---|
font | .systemFont(ofSize: 15) |
positioning | .base() (horizontal: .start, vertical: .top) |
Usage
Moments player
var momentsPlayerStyle = BlazeMomentsPlayerStyle.base()
momentsPlayerStyle.captions.font = UIFont(name: "Helvetica Neue", size: 16)
momentsPlayerStyle.captions.positioning.xPosition = .center
momentsPlayerStyle.captions.positioning.yPosition = .bottomStories player
var storyPlayerStyle = BlazeStoryPlayerStyle.base()
storyPlayerStyle.captions.positioning.yPosition = .bottomVideos player
var videosPlayerStyle = BlazeVideosPlayerStyle.base()
videosPlayerStyle.captions.font = UIFont.systemFont(ofSize: 18, weight: .medium)
videosPlayerStyle.captions.positioning.xPosition = .custom(offsetPercent: 10)
videosPlayerStyle.captions.positioning.yPosition = .custom(offsetPercent: 80)BlazeCaptionsPositioning
Horizontal and vertical position of the captions box in the player. Configure each axis independently (for example, horizontal center with a custom vertical offset).
Properties
| Property | Type | Description |
|---|---|---|
xPosition | BlazeCaptionsXPosition | Horizontal position of the captions box. |
yPosition | BlazeCaptionsYPosition | Vertical position of the captions box. |
base()
static func base() -> BlazeCaptionsPositioningDefault captions positioning (xPosition = .start, yPosition = .top), matching the renderer's native look.
BlazeCaptionsXPosition
Horizontal position of the captions box.
| Value | Description |
|---|---|
start | Align to the leading edge of the player. Default look. |
center | Center the captions box and its text horizontally. |
custom(offsetPercent: Int) | Offset from the leading edge as a percent of player width. Values are coerced into 0...100. |
BlazeCaptionsYPosition
Vertical position of the captions box.
| Value | Description |
|---|---|
top | Align to the top edge of the player. Default look. |
center | Center the captions box vertically. |
bottom | Align to the bottom edge of the player. |
custom(offsetPercent: Int) | Offset from the top edge as a percent of player height. Values are coerced into 0...100. |
Updated about 2 months ago
