我该如何融入由Brightcove主持的视频结尾引发的事件

How do I hook into an event triggered by the end of a Brightcove hosted video?

本文关键字:结尾 的视频 事件 何融入 Brightcove      更新时间:2024-02-25

当用户点击带有播放按钮的图像时,我有以下代码来显示Brightcove播放器:

$(document).ready(function() {
    $('#performanceVideo').hide();
    $('#banner_text_wrap').click(function(e) {
        e.preventDefault();
        $('banner-image').hide().fadeOut(slow);
        $('#performanceVideo').show().fadeIn(slow).css({'float':'left','margin-top':'-251px'});
    });
});

我想在视频结束时将图像淡入淡出。如何使用jQuery连接到视频结束事件?阅读文档时,我认为我需要在代码中包含addEventListener,但我是JavaScript新手,因此非常感谢您的帮助。

将这两个参数添加到您的播放器片段中:

<param name="includeAPI" value="true" />
<param name="templateLoadHandler" value="myTemplateLoaded" />

然后添加一个javascript函数,该函数与您在snippet params中为templateLoadHandler提供的值相匹配,以设置videoPlayers结束事件的事件侦听器。

function myTemplateLoaded(experienceID){
  player = brightcove.api.getExperience(experienceID);
  modVP = player.getModule(brightcove.api.modules.APIModules.VIDEO_PLAYER);
  modVP.addEventListener(brightcove.api.events.MediaEvent.COMPLETE,onMediaComplete);
}

然后在整个事件触发时隐藏玩家:

function onMediaComplete(evt){
  $('#performanceVideo').hide();
  $('banner-image').show().fadeIn(slow);
}