I am trying to attached event to brightcove video but not able to fire it. Have followed all the steps in Brightcove documentation. here is my code:
<script language="JavaScript" type="text/javascript"
src="//sadmin.brightcove.com/js/BrightcoveExperiences.js">
</script>
<object id="myExperience" class="BrightcoveExperience" style="">
<param name="bgcolor" value="#FFFFFF" />
<param name="width" value="100%" />
<param name="height" value="100%" />
<param name="wmode" value="transparent" />
<param name="playerID" value="3971645786001" />
<param name="playerKey" value="AQ~~%2CAAADnJnNnnk~%2CltuihYvDjRIrUSABF-AQVf9CGuEE1y7k" />
<param name="isVid" value="true" />
<param name="isUI" value="true" />
<param name="dynamicStreaming" value="true" />
<param name="secureConnections" value="true" />
<param name="secureHTMLConnections" value="true" />
<param name="@videoPlayer" value="${item.videoId}" />
<param name="includeAPI" value="true" />
<param name="templateLoadHandler" value="BCL.myTemplateLoaded" />
<param name="templateReadyHandler" value="BCL.onTemplateReady" />
</object>
<script type="text/javascript">
//if (typeof brightcove != 'undefined') {
brightcove.createExperiences();
//}
</script>
<script type="text/javascript">
var BCL = {};
BCL.myTemplateLoaded = function (experienceID) {
console.log("loaded")
BCL.player = brightcove.api.getExperience(experienceID);
BCL.videoPlayer = BCL.player.getModule( brightcove.api.modules.APIModules.VIDEO_PLAYER);
BCL.APIModules = brightcove.api.modules.APIModules;
}
BCL.onTemplateReady = function (evt) {
console.log("ready");
BCL.videoPlayer = BCL.player.getModule( brightcove.api.modules.APIModules.VIDEO_PLAYER);
BCL.videoPlayer.addEventListener(brightcove.api.MediaEvent.PLAY, BCL.onMediaEventFired);
}
BCL.onMediaEventFired = function(evt) {
console.log('evt');
}
</script>
The above code gives console output as "Loaded" and "ready" but when I click on the play button, the Play event does not give a output as 'evt'. I need to make some functionality to stop the carousel when the video starts playing.
Not sure if I am missing anything. Any idea?
P.S. There are multiple videos in the carousel (bootstrap), the video ID changes for each along with a unique id.
Please suggest. Thanks Ayush