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

标签 javascript html video html5-video brightcove

我正在为一个项目实现一个自定义播放器。我首先认为这可能是我所做的一些更改(这些更改很小),但所有播放器在渲染 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/

相关文章:

javascript - 限制文本区域中单行的行数和字母数

javascript - 在 mozilla canvas 中拖放

android - Android上的youtube视频

javascript - Jquery 弹跳效果不适用于应用于 anchor 标记的类

video - 如何查找视频 (.AVI .MP4) 的实际录制日期?

php - 如何获取上传到 Amazon S3 的视频文件长度?

php - 谷歌可视化 AreaChart 在 IE7 中给出 "Invalid Argument"

javascript - 我的页面上有两个模态框,但如果在模态框之外单击,则只有第二个模态框会关闭

javascript 拼写检查器建议

html - 流体 DIV 前后具有固定宽度的 Div