Autoplaying Brightcove Captions and Subtitles

We recently had a customer ask us how to have captions autoplay in their Brightcove player without any changes to their pages.  It turns out this is not currently possible. Since this is such an important and simple use-case, we decided to not only solve it for our client, but also to release the code on github for anyone to use.

If you are familiar with Brightcove you’ll know that there are two parts to any plugin. Flash and Javascript versions of a plugin need to be created.

First lets look at the Flash component. Brightcove provides the ‘CustomModule’ interface as a starting point for your plugin. All we have to do is override initialize() and set captions enabled to ‘true’.

package {

import com.brightcove.api.APIModules;
import com.brightcove.api.CustomModule;
import com.brightcove.api.modules.CaptionsModule;

/**
 * A Brightcove plugin that auto loads captions.
 */
public class CaptionConfigurationModule extends CustomModule {

    override protected function initialize():void {
        var captionModule:CaptionsModule = player.getModule(APIModules.CAPTIONS) as CaptionsModule;
        captionModule.setCaptionsEnabled(true);
    }
}
}

The Javascript plugin is just as simple. Once the player is ready we set captions enabled to ‘true’.

(function() {
    function onPlayerReady() {
        var captionsModule = player.getModule(brightcove.api.modules.APIModules.CAPTIONS);
        captionsModule.setCaptionsEnabled(true);
    }

    var experience = player.getModule(brightcove.api.modules.APIModules.EXPERIENCE);
    if (experience.getReady()) {
        onPlayerReady();
    } else {
        experience.addEventListener(brightcove.player.events.ExperienceEvent.TEMPLATE_READY, onPlayerReady);
    }
}());

There you have it; two simple plugins to enable caption autoplay on your Brightcove player. You can also see these plugins in our GitHub account: https://github.com/dotsub/api-samples/tree/master/brightcove-autoplay-captionsраскрутка сайта в киевевзлом пароля в одноклассниках по логину