gpt4 book ai didi

javascript - Twitter Bootstrap : modal window not playing video after reopning the modal window

转载 作者:行者123 更新时间:2023-12-03 07:01:19 25 4
gpt4 key购买 nike

我有 5 个链接,可在模式窗口中打开 5 个不同的视频, 以下代码在模态窗口中播放视频并在模态窗口关闭时停止视频。

但是,当我尝试再次打开同一视频时,该视频在模式窗口中被禁用并且无法再播放。有解决办法吗?

这里是模态窗口代码以及下面的 javascript 和 fiddle 链接

MY FIDDLE

莫代尔

<div class="modal fade video2 advSearchModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="exampleModalLabel">Video 2</h4>
</div>
<div class="modal-body">

<div class="row">
<div class="bs-example" data-example-id="responsive-embed-16by9-iframe-youtube">
<div class="embed-responsive embed-responsive-16by9">

<video class="embed-responsive-item" controls src="https://www.youtube.com/embed/zpOULjyy-n8?rel=0" type="video/mp4"> </video>

</div>
</div>

</div>

</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<!-- <button type="button" class="btn btn-primary">Send message</button> -->
</div>
</div>
</div>
</div>

JS

$(document).ready(function() {
$(document).ready(function() {
$(".advSearchModal").on('hide.bs.modal', function(evt) {
var player = $(evt.target).find('video'),
vidSrc = player.prop('src');
player.prop('src', ''); // to force it to pause
player.prop('src', vidSrc);
});
});
});

最佳答案

我正在使用以下技巧来停止 HTML5 视频。暂停()模式关闭视频并设置 currentTime = 0;

$(".advSearchModal").on('hide.bs.modal', function(evt) {
$(evt.target).find('video').get(0).pause();
$(evt.target).find('video').get(0).currentTime = 0;
});

设置currentTime = 0,以便当您打开模态时开始视频播放。

关于javascript - Twitter Bootstrap : modal window not playing video after reopning the modal window,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37053422/

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