Brightcove视频templateLoadHandler没有开火

时间:2012-05-30 11:09:37

标签: javascript events brightcove

好吧,整个下午我都在使用BrightCove API,我真的不会出错。

我跟随所有Brightcove给出,并为智能播放器启用了javascript api。但是templateLoadHandler并没有触发。这真的让我发疯了!

这是我的代码

<!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>

如果事件被触发,则会显示警告。但是永远...... 谁知道它为什么不起作用?感谢。

5 个答案:

答案 0 :(得分:1)

我运行你的代码没有jquery和jBrightcove.js包括(因为我没有它们)。它工作正常。如果它不适合你,我猜猜jBrightcove.js脚本中的某些内容与你的代码之间存在冲突。

答案 1 :(得分:1)

您是否尝试过将处理程序移到HTML代码之上?它对我有用。另外,我必须将“crossdomain.xml”文件添加到我的Web服务器根目录才能使用。您可能不需要它,但包括它以防万一。

<?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>

答案 2 :(得分:0)

在这种情况下,Alex似乎有错误的帐户类型。对我来说情况并非如此。我在brightcove论坛上发现代码需要从网络服务器运行。在我将代码从站点添加到我的本地XAMPP安装后,它就像宣传的那样工作。这是我找到信息的URL:

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

答案 3 :(得分:0)

对于遇到同样顽固麻烦的后来者:this是一个有效的演示,修剪它,看看哪些对你有用。

PS,演示中缺少的脚本的src应该是:http://docs.brightcove.com/en/scripts/secondsToTime.js

答案 4 :(得分:0)

确保在Brightcove中为每种播放器类型启用了SmartPLayer API。如果未在Brightcove面板中更改此设置,则不会触发templateLoadHandler和templateReadyHandler。