使用JavaScript动态更改视频,并使用Bootstrap在浮动窗口上播放的方法如下:
<video id="myVideo" controls>
<source src="path/to/video.mp4" type="video/mp4">
</video>
var video = document.getElementById("myVideo");
video.play();
video.pause();
video.currentTime = 10;
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#videoModal">
打开视频
</button>
<div class="modal fade" id="videoModal" tabindex="-1" role="dialog" aria-labelledby="videoModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="videoModalLabel">视频播放</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<video id="myVideoModal" controls>
<source src="path/to/video.mp4" type="video/mp4">
</video>
</div>
</div>
</div>
</div>
var modal = document.getElementById("videoModal");
// 显示Modal
modal.style.display = "block";
// 隐藏Modal
modal.style.display = "none";
var videoModal = document.getElementById("myVideoModal");
videoModal.play();
这样,你就可以使用JavaScript动态更改视频,并使用Bootstrap在浮动窗口上播放了。请注意,这只是一个基本的示例,你可以根据自己的需求进行修改和扩展。
领取专属 10元无门槛券
手把手带您无忧上云