gpt4 book ai didi

javascript - BrightCove 智能播放器 API HTML 回退失败

转载 作者:行者123 更新时间:2023-11-28 02:10:33 25 4
gpt4 key购买 nike

我正在为一个项目实现一个自定义播放器。我首先认为这可能是我所做的一些更改(这些更改很小),但所有播放器在渲染 HTML 版本时似乎都失败了。有没有人有任何启动和运行这个的经验,这是我第一次与 BrightCove 合作。这是我的代码。播放器处于页面底部的模式中,一旦打开模式,就会动态获取引用 ID 以加载视频。

HTML

<script language="JavaScript" type="text/javascript" src="http://admin.brightcove.com/js/BrightcoveExperiences.js"></script>
<object id="myExperience" class="BrightcoveExperience">
<param name="bgcolor" value="0x01000000" />
<param name="width" value="602" />
<param name="height" value="451" />
<param name="playerID" value="2346987014001" />
<param name="playerKey" value="AQ~~,AAAACNNhjOE~,7GG4lXihTUWE4HZdWRznisBnhfUh1o33" />
<param name="isVid" value="true" />
<param name="isUI" value="true" />
<param name="dynamicStreaming" value="true" />
<param name="includeAPI" value="true" />
<param name="forceHTML" value="true" />
<param name="templateLoadHandler" value="onTemplateLoad" />
</object>
<script type="text/javascript">brightcove.createExperiences();
</script>
<script language="JavaScript" type="text/javascript">
var player, modVP, expMod;
function onTemplateLoad(experienceID) {
player = brightcove.api.getExperience(experienceID);
modVP = player.getModule(brightcove.api.modules.APIModules.VIDEO_PLAYER);
}
</script>

JS

var waitForModVp = function () {
if( typeof modVP == 'object' ) {
modVP.loadVideoByReferenceID(newSrc);
$(window).on('resize.size-video', function(){
expMod = player.getModule(brightcove.api.modules.APIModules.EXPERIENCE);
var width = window.innerWidth*0.8,
height = (window.innerWidth*0.8)*0.7491694352;
if (width < 610) {
expMod.setSize(width, height);
$('.fullscreen-interior-video').css({
'width' : width+'px',
'height' : height+'px'
});
}
})
} else {
window.setTimeout( waitForModVp, 250 );
}
}
if ( thisData.templateReference == "brightcovePlayer") {
waitForModVp();
}

任何帮助将不胜感激,谢谢。

最佳答案

我认为您还应该指定一个 templateReady 处理程序并将 APIModules.VIDEO_PLAYER 模块的初始化移至该处理程序。这是一个非常常见的错误,大多数时候仅使用 templateLoadHandler 就可以工作,尤其是在桌面上,因此它吸引了很多使用移动设备的人。

请参阅 http://support.brightcove.com/en/video-cloud/docs/getting-started-smart-player-api 中的以下注释

Important: understand the difference between the template loaded and template ready events:

  • templateLoad: all the data for player and API have been received by the browser, and you can now get references to the overall player (the BrightcoveExperience) — the player has not been fully set up, though, and if you try to invoke any methods on it at this point, you are setting up a racing condition

  • templateReady: the player has now been fully instantiated and is ready to interact with via the API — you should only call methods of the API modules after the template ready event has fired

To avoid calling methods too early, you can skip the templateLoad event and just handle the templateReady event. The disadvantage of this is that the player ID is not passed to templateReady handler, so you will need to get it from the publishing code in order to get a reference to the player.

关于javascript - BrightCove 智能播放器 API HTML 回退失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17157762/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com