I have been assigned with task of only allowing a video to be viewed once using WordPress website and after being watch once and the video end, have the website URL redirect to another page. The video does not play but still redirect after 1 minutes.
Here is my code
[videojs_video url="http://tecfa.unige.ch/guides/html/html5-video/videos/state-of-wikipedia-480x272.mp4" preload="auto" controls ="false" autoplay = "true" loop="true"]
<script>
setTimeout(function(){
window.location.href = 'https://www.tutorialspoint.com/javascript/';
}, 60000);
</script>
<p>Web page redirects after 1 minute.</p>
You can use the ended event to detect if the video has finished playing:
let myVideo = document.getElementById('my-video');
myVideo.addEventListener('ended', videoCompleted, false);
function videoCompleted(e) {
console.log('video has completed');
window.location.href = 'https://www.tutorialspoint.com/javascript/';
}
<video controls src="https://file-examples-com.github.io/uploads/2017/04/file_example_MP4_640_3MG.mp4" id="my-video"></video>