我正在使用JS播放页面中的视频,但我无法使用JS跳转到视频的特定部分,甚至无法手动执行。
这是我在blade.php中的代码
blade.php
<video width="100%" src="{{ 'videos/stream.mp4#?t=150'}}" autoplay id="streamvideo" controls></video>
//providing t=150 is not working too.
<div class="play-button-overlay" id="playButton">
<i class="fas fa-play"></i>
</div>
JS
使用此选项可播放并禁止用户暂停视频。
document.addEventListener("DOMContentLoaded", function() {
var video = document.getElementById("streamvideo");
var playButton = document.getElementById("playButton");
playButton.addEventListener("click", function(e) {
e.preventDefault();
video.play();
clssplayButton.remove();
});
video.addEventListener("click", function(e) {
e.preventDefault();
if(video.paused){
video.play();
clssplayButton.remove();
}
});
};
CSS
#streamvideo::-webkit-media-controls-panel {
display: none !important;
}
#streamvideo::-webkit-media-controls-fullscreen-button {
display: inline-block !important;
}
使用JS,我也尝试设置当前时间,但仍然没有成功!
video.currentTime = 120;
有什么办法我能做到吗?