Look at this code
I tried to play the video from a specific time to another specific time.
<html>
<head>
<script>
function playVideo(str) {
var video = document.getElementById("myVideo");
video.src = str;
video.currentTime=16;
video.play();
var maxTime = 20;
video.addEventListener("progress", function(){
if(video.currentTime >= maxTime){
video.pause();
}
}, false);
}
</script>
</head>
<body>
<video id="myVideo" width="1000" height="800" controls autoplay loop>
Your browser does not support the video tag.
</video>
<a onclick="playVideo('video/journey27.mp4')" > Play2 </a>
</body>
</html>
Why doesn't the video stop when the currentTime>=maxTime?
i think there is something wrong with the eventListener.