2014-10-21 79 views
0

在此页面上,我们有多个链接到vimeo视频,这些视频都使用相同的引导模式,并使用data-src填充模式。问题是,当模式关闭时,音频继续播放。我可以运行哪些脚本来停止音频播放?Vimeo声音在关闭模式后继续以引导模式播放

页面为here,您可以通过点击顶部显示“安全文件共享”图片来查看视频。

+1

你应该监听['hidden.bs.modal'或'hide.bs.modal'事件](http://getbootstrap.com/javascript/#modals -usage),然后在你的事件处理程序中调用任何API Vimeo公开的停止/暂停/静音/销毁视频播放器。 – cvrebert 2014-10-22 05:42:32

回答

0

就我个人而言,我发现听hidden.bs.modal事件,没有产生任何东西,而是hide.bs.modal为我工作。

奖金 - 无需打VIMEO API

  • 你需要一个id添加到您的iframe(在下面的例子中,id="iframe"
  • 监听hide.bs.modal事件
  • 捕捉iframe src到变量
  • 将src设置为空字符串
  • 通过变量重新添加原始src ...

    $('#orientation_video').on('hide.bs.modal', function() { 
    
        // get the source of the iframe and save it 
        var src = $(this).find('iframe').attr('src'); 
    
        // remove the src from the iframe 
        $("iframe#iframe").attr('src',''); 
    
        // re-add the 
        $("iframe#iframe").attr('src', src); 
    
        }); 
    
相关问题