javascript - 单击十字按钮后视频停止,但几秒钟后自动以模态方式重新开始
问题描述
我想以模态显示视频。视频显示完美,当我单击十字按钮时,模态隐藏并且视频停止。但几秒钟后,视频会自动从后端启动。
这是我的脚本模式
{{-- start modal --}}
<div class="modal fade" id="videoModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-body">
<h1>Technology video</h1>
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<iframe width="100%" height="350" src="https://www.youtube.com/embed/HBdcL7YsdBY?modestbranding=1&rel=0&controls=0&showinfo=0&html5=1&autoplay=1" frameborder="0" allowfullscreen></iframe>
</div>
</div>
</div>
</div>
{{-- end model --}}
{{-- start script --}}
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery('#videoModal').modal('show');
jQuery("#videoModal").on('hidden.bs.modal', function (e)
{
jQuery("#videoModal iframe").attr("src", jQuery("#videoModal iframe").attr("src"));
});
});
</script>
{{-- end script --}}
为什么视频会自动开始?如何阻止这个?
有人帮忙吗?
解决方案
jQuery("#videoModal").on('hidden.bs.modal', function (e)
{
jQuery("#videoModal iframe").attr("src", "https://www.youtube.com/embed/HBdcL7YsdBY?modestbranding=1&rel=0&controls=0&showinfo=0&html5=1&autoplay=0");
});
jQuery("#videoModal").on('show.bs.modal', function (e)
{
jQuery("#videoModal iframe").attr("src", "https://www.youtube.com/embed/HBdcL7YsdBY?modestbranding=1&rel=0&controls=0&showinfo=0&html5=1&autoplay=1");
});
推荐阅读
- javascript - socket.io 管理员/用户的唯一颜色
- javascript - HLS.js 获取视频片段信息
- javascript - Price.map 不是函数
- concurrency - V-lang:如何每秒发送 +2500 个 HTTP 请求?
- reactjs - 如何在 React js 中使用数组将数组推送到对象中?
- javascript - 嵌入对象以显示 PDF 显示为不可见
- python - 无法导入类,即使快速修复找到它
- javascript - 修复 JavaScript LoadMore 按钮以每页加载 5 个项目 - Django
- python - 使用自生成键将嵌套列表转换为字典
- reactjs - React Docusign Clickwrap 凭证