Fundamental CC Methods on Android

A simple programming example shows the basic methods on Android to get and set the closed caption (CC) language.

Note:Be sure you have setup the required DFXP (now TTML) files for all your videos, as detailed Required Closed Caption Setup in Backlot. This simple example shows some of the basic method calls for programming with closed captions on Android:
  • Shown first here is a check for the CURRENT_ITEM_CHANGED_NOTIFICATION event, which in this context indicates that the video and its associated DFXP (now TTML) file have been loaded. (Event programming is not required for working with closed captions, but is shown here only as a useful feature. If you are interested in more details about event programming, see Working with Events.)
  • To find out what languages are available for the video, use the getAvailableClosedCaptionsLanguages() method, which returns the information in a string named languages in this example..
  • Then, with the setClosedCaptionsLanguage() method, you can actually set the desired language. This example checks if English ("en") is available and sets the captions to that language.
if (notification == OoyalaPlayer.CURRENT_ITEM_CHANGED_NOTIFICATION) {

    Set<String> languages = player.getAvailableClosedCaptionsLanguages();

    if (languages.contains("en")) {