我必须将Brightcove播放器集成到角度模态窗口中。
这是我通常会放入的对象代码,例如,用于显示视频的jQuery模式:
<object id="" class="BrightcoveExperience">
<param name="playerID" value="2132538346001" />
<param name="playerKey" value="key_here" />
<param name="dynamicStreaming" value="true" />
<param name="@videoPlayer" value="screencast.brightcove_id" />
<param name="bgcolor" value="#ffffff" />
<param name="width" value="480" />
<param name="height" value="360" />
<param name="isVid" value="true" />
<param name="isUI" value="true" />
<param name="wmode" value="transparent" />
<param name="seamlessTabbing" value="false" />
</object>
<script type="text/javascript">brightcove.createExperiences();</script>
请注意在最后一行调用Brightcove函数,并在对象内调用{{screen>编辑:now screencast.brightcove_id,不带花括号)引用。我尝试将此代码放在Angular中,并在Angular之前引用Brightcove.js(或之后,它没有什么区别),但它不起作用。它抛出一个错误:
Cannot read property 'nodeName' of undefined
at hb (https://ajax.googleapis.com/ajax/libs/angularjs/1.1.5/angular.min.js:124:197)
这显然不是Angular的做事方式,但我无法找到有关在Angular中集成其他Javascript工具的信息。你是怎么做到的?
编辑:使用screencast.brightcove_id代替{{screencast.brightcove_id}}摆脱了错误消息。然而,角度绑定的替换不会发生,并且发送brightcove以寻找具有id“screencast.brightcove_id”的视频。手动插入正确的ID插件可以正常工作,但我需要使用angular来填充该字段。
答案 0 :(得分:5)
您可以使用此指令
yourApp.directive("brightcove", function($timeout) {
return {
restrict: "CA",
replace: true,
transclude: false,
scope: {
videoId: "@"
},
template: '<object id="myExperience{{ videoId }}" class="BrightcoveExperience"">\
<param name="bgcolor" value="#000000">\
<param name="width" value="1024">\
<param name="height" value="575">\
<param name="playerID" value="[ YOUR PLAYER ]">\
<param name="playerKey" value="[ YOUR KEY ]">\
<param name="isVid" value="true">\
<param name="isUI" value="true">\
<param name="dynamicStreaming" value="true">\
<param name="autoStart" value="true">\
<param name="wmode" value="transparent">\
<param name="@videoPlayer" value="{{ videoId }}">\
</object>',
link: function(scope, element, attrs) {
return $timeout(function() {
return brightcove.createExperiences();
});
}
};
});
这在模板上:
<div class="brightcove" video-id="{{ video.id }}"></div>
并在index.html中包含:
<script language="JavaScript" type="text/javascript" src="http://admin.brightcove.com/js/BrightcoveExperiences.js"></script>