Question

well, I was struggling with the BrightCove API for the whole afternoon, and I really don't what went wrong.

I followed all Brightcove gives, and enabled the javascript api for smart player. But the templateLoadHandler is just not firing. It is really makes me crazy!

This is my code

<!doctype html>
<html>
<head>
<title>Brightcove video API demo</title>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="jBrightCove.js"></script>
</head>

<body>

    <h2>Brightcove Video Cloud Demo</h2>


    <!-- Start of Brightcove Player -->

    <div style="display:none">

    </div>

    <!--
    By use of this code snippet, I agree to the Brightcove Publisher T and C 
    found at https://accounts.brightcove.com/en/terms-and-conditions/. 
    -->

    <script language="JavaScript" type="text/javascript" src="http://admin.brightcove.com/js/BrightcoveExperiences.js"></script>

    <object id="myExperience1655503405001" class="BrightcoveExperience">
      <param name="bgcolor" value="#FFFFFF" />
      <param name="width" value="480" />
      <param name="height" value="270" />
      <param name="playerID" value="1655260200001" />
      <param name="playerKey" value="AQ~~,AAABgXJq-HE~,N7Kwgwyc9ubOnOKgNwEM8Jm-tJbp_nzt" />
      <param name="isVid" value="true" />
      <param name="isUI" value="true" />
      <param name="dynamicStreaming" value="true" />



      <param name="@videoPlayer" value="ref:spring" />
      <param name="includeAPI" value="true" />
      <param name="templateLoadHandler" value="myTemplateLoaded" />
    </object>

    <script type="text/javascript">
    // this piece of code is from BrightCove template

    var player;

    var modVP;
    var modExp;
    var modCon;
    ////




     //
    function myTemplateLoaded(experienceID) {
        alert("123");
        player = brightcove.api.getExperience(experienceID);
        modVP = player.getModule(brightcove.api.modules.APIModules.VIDEO_PLAYER);
        modExp = player.getModule(brightcove.api.modules.APIModules.EXPERIENCE);
        modCon = player.getModule(brightcove.api.modules.APIModules.CONTENT);

    }
</script>

</body>
</html>

If the event is fired, then an alert would show. But never... Anyone knows why it is not working? Thanks.

Was it helpful?

Solution

I ran your code without the jquery and jBrightcove.js includes (since I don't have them). It worked fine. If it's not working for you, I would guess there's a collision between something in the jBrightcove.js script and your code here.

OTHER TIPS

Have you tried moving your handler above the HTML code? It worked for me. Plus I had to add "crossdomain.xml" file to my web server root for it to work. You might not need it but including it just in case.

<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>


<!-- Read this: www.adobe.com/devnet/articles/crossdomain_policy_file_spec.html -->

<!-- Most restrictive policy: -->
    <allow-access-from domain="admin.brightcove.com"/>


<!-- Least restrictive policy: -->
<!--
    <site-control permitted-cross-domain-policies="all"/>
    <allow-access-from domain="*" to-ports="*" secure="false"/>
    <allow-http-request-headers-from domain="*" headers="*" secure="false"/>
-->
<!--
  If you host a crossdomain.xml file with allow-access-from domain="*"
  and don’t understand all of the points described here, you probably
  have a nasty security vulnerability. ~ simon willison
-->

</cross-domain-policy>

In this case, it seems Alex had the wrong account type. This was not the case for me. I found on a brightcove forum that the code needs to be run from a webserver. After I added the code from the site to my local XAMPP installation it worked as advertised. Here is the URL where I found the info:

http://forum.brightcove.com/t5/Media-APIs/templateLoadHandler-not-fired/td-p/19585

For late comers who have this same stubborn trouble: this is a working demo, trim it down and see what works for you.

PS, the src of the missing script within the demo should be: http://docs.brightcove.com/en/scripts/secondsToTime.js

Make sure in Brightcove you have the SmartPLayer API's enabled for each of your player types. templateLoadHandler and templateReadyHandler will not fire without this setting being changed in the Brightcove panel.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top