1
votes

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

1

1 Answers

1
votes

The event is brightcove.api.events.MediaEvent.PLAY, not brightcove.api.MediaEvent.PLAY.

Also this code will only work on a page served over HTTPS. The secureConnections and secureHTMLConnections params should not be included if the page is served over HTTP - the browser will prevent communication between the page and the flash object breaking the API. I don't know if you're using HTTP or HTTPS, but noticed you use a protocol relative URL for the player script.

You may also want to consider using the current version of Brightcove's player rather than this version.