【问题标题】:Stop Youtube video on hide a bootstrap modal在隐藏引导模式时停止 Youtube 视频
【发布时间】:2020-07-21 10:21:42
【问题描述】:

我正在尝试以引导模式停止 YouTube 嵌入视频,但没有任何反应。谁能帮帮我?

页面:https://www.visiteumtegra.com.br/

<div class="modal fade bg-modal show" id="ModalVideofontano1" tabindex="-1" role="dialog" aria-labelledby="ModalVideoTitle" style="display: block;" aria-modal="true">
<div class="modal-dialog modal-dialog-centered modal-xl" role="document">
    <div class="modal-content">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">x</button>
        <div class="modal-body mt-5 mb-5 border-0">
            <div class="embed-responsive embed-responsive-16by9">
                <iframe id="videofontano1" class="embed-responsive-item yvideo" src="https://www.youtube.com/embed/smIdBgbsHYg?rel=0&enablejsapi=1" gesture="media" allow="encrypted-media" allowfullscreen="" frameborder="0"></iframe>
            </div>
        </div>
    </div>
</div>

$('#ModalVideofontano1').on('hide.bs.modal', function (e) {
      $('.yvideo').each(function(){
        $(this).stopVideo();
      });
});

【问题讨论】:

    标签: jquery twitter-bootstrap video iframe modal-dialog


    【解决方案1】:

    你可以这样做:

    $('#ModalVideofontano1').on('hide.bs.modal', function (e) {
        $('.yvideo').each(function(){
            $(this).prop('src', $(this).prop('src'));
        });
    });
    

    它所做的是重新分配视频源,因此默认将其恢复为停止的原始行为。

    【讨论】:

      猜你喜欢
      • 2020-09-14
      • 2019-03-24
      • 1970-01-01
      • 2018-05-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-06-27
      相关资源
      最近更新 更多