Use the player API for this, specifically the video player module.
Enable the API in the player settings in the Studio, and add these parameters to your publishing code:
<param name="includeAPI" value="true" />
<param name="templateLoadHandler" value="onTemplateLoad" />
Define the function you specify as the value of templateLoadHandler
.
var videoPlayer;
function onTemplateLoad(id) {
var player = brightcove.api.getExperience(id);
videoPlayer = player.getModule(brightcove.api.modules.APIModules.VIDEO_PLAYER);
}
Then to play a video, use videoPlayer.play()
. Note that some mobile browsers (including mobile Safari) will not allow playback until the player has been interacted with - you can use videoPlayer.canPlayWithoutInteraction
to determine whether play()
will work.
Further API docs/examples here.