【问题标题】:Stop audio when closing modal window关闭模态窗口时停止音频
【发布时间】:2020-11-16 02:30:16
【问题描述】:

我有一个在页面加载时弹出并流式传输 youtube 文件的模式。但是,当模式关闭时,音轨仍会继续。 有没有办法在模态关闭时停止音频?

有问题的页面可以在这里看到:Modal audio issue webExample

我的代码如下:

<div class="clear"></div> 
<div style="margin:50 auto; width:800px;">
    <script>
        $(window).load( function(){
            rplm({
                title: "",
                html: true,
                showConfirmButton: false,
                animation: 'fadeIn',
                allowOutsideClick: true,
                modalNOverlay: 'black',
                youtubeID: "FJDkIKPtHUg?autoplay=1&mute=1",
                videoWidth: "780px",
            });
        });
    </script>
</div>

非常感谢任何帮助。 谢谢,汉尼尔。

【问题讨论】:

标签: javascript html css youtube video-streaming


【解决方案1】:

问题看起来像 .close() 调用隐藏了模式并且不会终止视频或删除 iframe 源,类似于Video's audio continues to play after replete modal is closed 他们的问题是 Vimeo。

你可以调用视频

function openModal() {
  rplm({
    title: "",
    html: true,
    text:'<iframe id="rplm-player" type="text/html" width="640" height="390" src="http://www.youtube.com/embed/M7lc1UVf-VE?enablejsapi=1&origin=http://example.com" frameborder="0"></iframe>'
  });  
}

使用rplm-player作为id,可以调用下面的函数来关闭modal并杀死iframe。

function closeModal() {
  document.getElementById("rplm-player").src = "";
  rplm.close()
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-08-22
    • 1970-01-01
    • 1970-01-01
    • 2016-10-03
    • 2015-08-06
    • 1970-01-01
    • 1970-01-01
    • 2021-01-13
    相关资源
    最近更新 更多