gpt4 book ai didi

javascript - 关闭模式后,Vimeo 声音继续在 Bootstrap 模式中播放

转载 作者:行者123 更新时间:2023-12-03 11:36:15 24 4
gpt4 key购买 nike

在此页面上,我们有多个指向 vimeo 视频的链接,这些视频都在同一 Bootstrap 模式中播放,并使用 data-src 填充模式。问题是当模式关闭时音频继续播放。我可以运行什么脚本来停止音频播放?

页面是here您可以通过单击顶部显示“安全文件共享”的图像来观看视频。

最佳答案

我个人发现监听hidden.bs.modal事件没有产生任何结果,相反hide.bs.modal对我有用。

额外奖励 - 无需使用 vimeo API

  • 您需要向 iframe 添加一个 id(在下面的示例中,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);

    });

关于javascript - 关闭模式后,Vimeo 声音继续在 Bootstrap 模式中播放,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26497707/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com