2016-11-17 49 views
0

下面是该网站后打:http://neillieleadershipgroup.com/阿瓦达索模式Vimeo的视频继续被关闭

在主页上,你会看到一个视频播放按钮。点击它打开一个包含视频的模式窗口。视频未设置为自动播放。当您关闭模式窗口时,视频中的音频会继续播放。

我花了几个小时研究这个问题,并且我已经尝试在页眉和页脚中添加大量“bootstrap”模态视频JavaScript代码,到目前为止没有任何工作。

我对javascript/jquery不是很了解,但是我知道HTML和CSS的相当数量。我搜索了网站的源代码,但我似乎无法找到这种模式背后的技术,即它是使用引导程序还是别的东西 - 换句话说,我找不到控制模式的脚本。

这是一个文章中,我已经阅读并试图无济于事:
Play and stop Vimeo video placed in Bootstrap modal
同样的,这一个:
Audio from vimeo video continues after modal has closed
还有许多其他人也说是对我没有任何帮助。

下面是一个创建模态的HTML:

<div class="fusion-modal modal fade modal-1 homepage-video in" tabindex="-1" role="dialog" aria-labelledby="modal-heading-1" aria-hidden="false" id="homepage-video" style="display: block;"> 
<div class="modal-dialog modal-lg"> 
    <div class="modal-content fusion-modal-content" style="background-color:#f6f6f6"> 
    <div class="modal-header"> 
    <button class="close" type="button" data-dismiss="modal" aria-hidden="true">×</button> 
    <h3 class="modal-title" id="modal-heading-1" data-dismiss="modal" aria-hidden="true" data-fontsize="28" data-lineheight="36"></h3> 
    </div> 
    <div class="modal-body"> 
    <iframe src="https://player.vimeo.com/video/151703999?title=0&amp;byline=0&amp;portrait=0&amp;api=1&amp;player_id=player_1&amp;wmode=opaque" width="710" height="399" frameborder="0" allowfullscreen="allowfullscreen" id="player_1"></iframe> 
    </div> 
    </div> 
    </div> 
</div> 

再次,如果我能找到的JS的模式,我想也请一并提供。

这里是最近的jQuery我试过(停止时模式密切播放视频),没有工作(添加到两个页眉和页脚):

videoSRC = $('iframe#player_1').attr('src'); 
    $('button.close').click(function() { 
    $(' iframe#player_1').attr('src', videoSRC); 
    }); 

    $('.homepage-video').on('hidden.bs.modal', function (e) { 
    $(' iframe#player_1').attr('src', videoSRC); 
    }); 


任何帮助深表感谢。谢谢!

回答

1

您可以使用Vimeo JS API轻松实现。下载并上传从这个链接player.js到你的WordPress主题文件夹:https://github.com/vimeo/player.js/blob/master/dist/player.min.js

一旦上传你可以解雇像这样使用jQuery的事件: - 。

jQuery(document).ready(function($) { 

    var jqueryPlayer = new Vimeo.Player($('iframe#player_1')); 

    $('.homepage-video').on('hidden.bs.modal', function (e) { 
     jqueryPlayer.pause(); 
    }); 

}); 

这将解决您的问题(Y)

+0

我将此添加到我的头文件中: ...然后将您的代码添加到我的页脚。它的工作!非常感谢! – chriscreation