<img src="https://img.shields.io/badge/%20Android-V3-yellow?logo=android" style="float:left"/><br />

If you have captions or subtitles for your video content, you can use the following sections to add embedded or sidecar captions to your app.

Although there are differences between the intended purposes of captions and subtitles, you use the same processes to add or to customize either type of synchronized text to your app. For simplicity, both captions and subtitles are referred to as captions in our documentation.

<br /> <hr />

## Add captions to your app

### Embedded captions

To add videos or streams with embedded captions to your app, follow the steps to [create a playlist](🔗). Replace step 2 of the process with the two steps below:

  1. Copy the URL of your video. **The video must contain CEA-608, CEA-708, or in-manifest WebVTT captions.**

  2. Define the `file` property of the `PlaylisItem` object with the URL of your video.

<br />

### Sidecar captions

  1. Create a `List<Caption>` object and name it, for example, `captionTracks`.

  2. Use `Caption.Builder()` to create and name a `Caption` object for each caption track.

  3. Add the caption track URL (`file`) and a language label (`label`).

  4. (Optional) If you have multiple tracks, set `isdefault(true)` for the default caption track.

  5. Add each caption track to `captionTracks`.

  6. Add `captionTracks` to a playlist item.



If you define a single track, the `label` value is ignored and not shown.



<br /> <hr />

## Customize your captions

Using the `CaptionsConfig.Builder()`, you can customize the font, font color, window color, background color, and edge style of the captions in your app. If you do not define any styling, your captions are styled based upon the **Accessibility** settings on the viewer's device.



Any caption styling that you define applies only when a viewer disables **Use Caption** in the **Accessibility** section of his or her device settings.

CEA-608 and CEA-708 captions cannot be styled with CSS.

<br />

  1. Use `CaptionsConfig.Builder()` to create and name a `CaptionsConfig` object.

  2. Use the following example and table to define the properties of the `captionsConfig` object.

  3. Add `captionsConfig` to the `captionsConfig` property of the `PlayerConfig` object (`config`)



<br />

### Android settings mapping

The following tables map the specific Android settings to the Android SDK property. Remember that viewers must disable **Use Caption** in the **Accessibility** section of the device settings for your customizations to render when they use your app.

<br />

#### Standard options

Android settingCaptionsConfig.Builder() property
Language-
Text sizefontSize
Caption style-

#### Custom options

Android settingCaptionsConfig.Builder() property
Font familyfontFamily
Text colorcolor
Text opacityfontOpacity
Edge typeedgeStyle
Edge color-
Background colorbackgroundColor
Background opacitybackgroundOpacity
Caption window colorwindowColor
Caption window opacitywindowOpacity

<br /> <hr />

## Captions methods and callbacks

### Methods

MethodDescription
List<Caption> getCaptionsList()Returns a List with captions tracks from the player
int getCurrentCaptions()Returns the index of the currently active captions track. Note the captions are Off if the index is 0
setCurrentCaptions(int index)Change the visible captions track to the provided index. The index must be within the list provided by `getCaptionsList()`.

<br />

### Callbacks

CallbackDescription
onCaptionsList(CaptionsListEvent captionsListEvent)Fired when the list of available captions tracks is updated
onCaptionsChanged(CaptionsChangedEvent)Fired when the active captions track is changed

<br />