观看一次视频并重定向到另一个网站

View video once and redirect to another website

我的任务是只允许使用 WordPress 网站观看一次视频,并且在观看一次视频结束后,让网站 URL 重定向到另一个页面。视频无法播放,但在 1 分钟后仍会重定向。

这是我的代码

[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>
   

您可以使用 ended 事件检测视频是否播放完毕:

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>