com.brightcove.player.controller

## Class BrightcoveClosedCaptioningController

- java.lang.Object
- - com.brightcove.player.event.AbstractComponent
  - - com.brightcove.player.controller.BrightcoveClosedCaptioningController

- All Implemented Interfaces:
    Component

      @ListensFor(events={"didSetVideo","stop","enterTvMode","hidePlayerOptions"})
       @Emits(events={"captionsDialogOk","captionsDialogSettings","toggleClosedCaptions","captionsLanguages","selectClosedCaptionTrack"})
      public class BrightcoveClosedCaptioningController
      extends AbstractComponent

  A controller class for managing closed captioning dialogue windows.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected android.content.Context` | `context`

    - ### Fields inherited from class com.brightcove.player.event.AbstractComponent

      `eventEmitter, listenerTokens`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `BrightcoveClosedCaptioningController(BaseVideoView videoView, android.content.Context context)` Constructor

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `checkIfCaptionsExist(Video video)` Check to see if the Video passed in has closed captioning data.
    `LoadCaptionsService` | `getLoadCaptionsService()` Method to return the LoadCaptionsService instance for fetching captions URI's.
    `protected void` | `hideCaptionsMenu()` Hide caption menu for Android TV.
    `protected void` | `initCaptionsMenu()` Init caption menu for Android TV.
    `boolean` | `isCaptioningEnabled()` Checks the closed captioning enabled/disabled state from the applications shared preferences.
    `void` | `saveClosedCaptioningState(boolean state)` Save the closed captioning enabled/disabled state to the applications shared preferences.
    `void` | `selectCaptions(int trackIndex)` Selects the caption option and and emits the one selected.
    `void` | `setLocaleCode(java.lang.String localeCode)` Stores the locale code in the default shared preferences, so it will be persisted.
    `void` | `setShouldImportSystemSettings(boolean shouldImport)` Method to set whether to import the system caption settings before displaying captions on a video.
    `void` | `showCaptionsDialog()` Helper that prepares the captions dialog with the current state and displays the dialog over the video player.
    `protected void` | `showCaptionsMenu()` Show caption menu for Android TV.
    `boolean` | `validateCaptionSourcesField(java.lang.Object obj)` Helper method to validate the types of the CAPTION_SOURCES video field, which should always be a List>.

    - ### Methods inherited from class com.brightcove.player.event.AbstractComponent

      `addListener, addOnceListener, getEventEmitter, removeListener, removeListeners`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### context

          protected android.content.Context context

  - ### Constructor Detail

    - #### BrightcoveClosedCaptioningController

          public BrightcoveClosedCaptioningController(BaseVideoView videoView,
                                                      android.content.Context context)

      Constructor
      Parameters:
        `videoView` - A video view in charge of media playback.
        `context` - The context of the main application's activity.

  - ### Method Detail

    - #### setShouldImportSystemSettings

          public void setShouldImportSystemSettings(boolean shouldImport)

      Method to set whether to import the system caption settings before displaying captions on a video.

    - #### getLoadCaptionsService

          public LoadCaptionsService getLoadCaptionsService()

      Method to return the LoadCaptionsService instance for fetching captions URI's.
      Returns:
        the LoadCaptionsService instance.

    - #### validateCaptionSourcesField

          public boolean validateCaptionSourcesField(java.lang.Object obj)

      Helper method to validate the types of the CAPTION_SOURCES video field, which should always be a List>.
      Parameters:
        `obj` - the object to test for the correct type.
      Returns:
        true if the types are correct, false otherwise.

    - #### checkIfCaptionsExist

          public boolean checkIfCaptionsExist(Video video)

      Check to see if the Video passed in has closed captioning data.
      Parameters:
        `video` - The video to check
      Returns:
        true if captions exist, false otherwise.

    - #### showCaptionsDialog

          public void showCaptionsDialog()

      Helper that prepares the captions dialog with the current state and displays the dialog over the video player.

    - #### isCaptioningEnabled

          public boolean isCaptioningEnabled()

      Checks the closed captioning enabled/disabled state from the applications shared preferences.
      Returns:
        true for CC enabled, false for disabled.

    - #### saveClosedCaptioningState

          public void saveClosedCaptioningState(boolean state)

      Save the closed captioning enabled/disabled state to the applications shared preferences.
      Parameters:
        `state` - The enabled/disabled state to save.

    - #### setLocaleCode

          public void setLocaleCode(java.lang.String localeCode)

      Stores the locale code in the default shared preferences, so it will be persisted.
      Parameters:
        `localeCode` - The two character locale code.

    - #### initCaptionsMenu

          protected void initCaptionsMenu()

      Init caption menu for Android TV. It initializes the Player option menu when necessary.

    - #### showCaptionsMenu

          protected void showCaptionsMenu()

      Show caption menu for Android TV.

    - #### hideCaptionsMenu

          protected void hideCaptionsMenu()

      Hide caption menu for Android TV.

    - #### selectCaptions

          public void selectCaptions(int trackIndex)

      Selects the caption option and and emits the one selected. Making this method public instead of protected allows for its use in custom caption dialogs
      Parameters:
        `trackIndex` - the caption index