Brightcove .addeventlistener 函数的 jQuery FancyBox 问题

发布于 2024-12-20 05:47:59 字数 1415 浏览 2 评论 0原文

好吧,伙计们,这就是我遇到的问题,我有一个来自 Brightcove 的视频,并且我从他们的 api 添加了一个事件侦听器,以在播放完成后关闭 fancybox 2.0 模式窗口。但偶数侦听器没有发生,因为 fancybox 复制了 div 中的内容而不是 javascript,因此事件侦听器没有被激活。

这是代码

   <!-- Start Brightcove API -->
   <script language="JavaScript" type="text/javascript" src="http://admin.brightcove.com/js/APIModules_all.js"></script>
   <script type="text/javascript">
       var bcExp;
       var modVP;
       function onTemplateLoaded(experienceID) {
           alert("EVENT: TEMPLATE_LOAD");
           bcExp = brightcove.getExperience(experienceID);
           modVP = bcExp.getModule(APIModules.VIDEO_PLAYER);
           modVP.addEventListener(
           BCMediaEvent.COMPLETE, 
           function(event) {
               alert("EVENT: Close Modal Activated");
               jQuery.fancybox.close(true);
           }
       );
       }

       /*   
       function onTemplateLoaded(experienceID) {
           alert("EVENT: TEMPLATE_LOAD");
           bcExp = brightcove.getExperience(experienceID);
           modVP = bcExp.getModule(APIModules.VIDEO_PLAYER);
           modVP.addEventListener(BCMediaEvent.COMPLETE, closeModal);
       }
       function closeModal(event) {
           alert("EVENT: Close Modal Activated");
           jQuery.fancybox.close(true);
       }
        */
   </script>
   <!-- End Brightcove API -->

有什么想法或解决方案吗?

Okay guys here's the problem i'm having, i have a video coming from brightcove and i have an event listener added from their api to close the fancybox 2.0 modal window after playback is completed. but the even listener is not happening because fancybox is duplicating the content from the div but not the javascript so the event listener is not being activated.

here is the code

   <!-- Start Brightcove API -->
   <script language="JavaScript" type="text/javascript" src="http://admin.brightcove.com/js/APIModules_all.js"></script>
   <script type="text/javascript">
       var bcExp;
       var modVP;
       function onTemplateLoaded(experienceID) {
           alert("EVENT: TEMPLATE_LOAD");
           bcExp = brightcove.getExperience(experienceID);
           modVP = bcExp.getModule(APIModules.VIDEO_PLAYER);
           modVP.addEventListener(
           BCMediaEvent.COMPLETE, 
           function(event) {
               alert("EVENT: Close Modal Activated");
               jQuery.fancybox.close(true);
           }
       );
       }

       /*   
       function onTemplateLoaded(experienceID) {
           alert("EVENT: TEMPLATE_LOAD");
           bcExp = brightcove.getExperience(experienceID);
           modVP = bcExp.getModule(APIModules.VIDEO_PLAYER);
           modVP.addEventListener(BCMediaEvent.COMPLETE, closeModal);
       }
       function closeModal(event) {
           alert("EVENT: Close Modal Activated");
           jQuery.fancybox.close(true);
       }
        */
   </script>
   <!-- End Brightcove API -->

Any ideas or solutions?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

口干舌燥 2024-12-27 05:47:59

我已经使用 vimeo 完成了此操作,但通常我会使用脚本创建一个单独的 html 页面来运行视频。然后我使用 iframe 模式 (type:'iframe') 在 Fancybox 中打开该页面。

对于 vimeos 的听众,我有:

function endOfVideo() {
  parent.$.fancybox.close();
}

vimeoAPI.api_addEventListener("onFinish","endOfVideo"); 

这可以解决问题。

看看相似之处,我想在你的情况下这应该可行:

modVP.addEventListener(
 BCMediaEvent.COMPLETE, function(){parent.jQuery.fancybox.close();}
);

无论如何,检查你的 API 文档以获取正确的格式和语法,但 jQuery.fancybox.close();parent.jQuery。 fancybox.close(); 如果使用 iframe,在任何情况下都应该工作

I have done this with vimeo but usually I create a separated html page with the script to run the video. Then I open that page in Fancybox using the iframe mode (type:'iframe').

For the vimeos's listener I have:

function endOfVideo() {
  parent.$.fancybox.close();
}

vimeoAPI.api_addEventListener("onFinish","endOfVideo"); 

which does the trick.

Looking at the similarities, I guess in your case this should work:

modVP.addEventListener(
 BCMediaEvent.COMPLETE, function(){parent.jQuery.fancybox.close();}
);

Anyway, check your API's documentation for the right format and syntax but jQuery.fancybox.close(); or parent.jQuery.fancybox.close(); if using iframe, should work in any case

好多鱼好多余 2024-12-27 05:47:59

感谢您的消息,但我实际上发现这对我来说是一个巨大的错误,我像这样调用 fancybox

jQuery.document().ready(function() { 
if (document.location.hash === '#video') { 
jQuery.fancybox.open([{ 
content: jQuery('.video').html(), 

其余的并不重要,因为这就是破坏它的 .html() 但无论高兴它现在修复了

Thanks for the message but i actually figured it out it was a huge goof on my part I was calling fancybox like this

jQuery.document().ready(function() { 
if (document.location.hash === '#video') { 
jQuery.fancybox.open([{ 
content: jQuery('.video').html(), 

the rest isnt important because thats what is breaking it the .html() but whatever glad its fixed now

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文