2014-10-21 75 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); 
    
        }); 
    
相關問題