视频播放完毕后重定向

时间:2012-07-18 08:24:02

标签: javascript html5 video

  

可能重复:
  redirecting the page after a video plays using an html5 video player

有没有办法重定向此视频

<video class="video-js vjs-default-skin" id="player1" controls="controls" poster="video/image.jpg"    preload="auto" data-setup="{}" autoplay="autoplay">
        The browser you are using does not support viewing HTML5 Video,please open it in Chrome or Firefox .
</video>

停止播放后?

我尝试了这个但是没有用。

<script>
var video = document.getElementsById('player1');
    video.onended = function(e) {
      window.location.replace("http://stackoverflow.com");
    }
</script>

1 个答案:

答案 0 :(得分:0)

你能做的是:

创建一个播放视频的按钮,并设置一个具有视频长度的计时器。

类似的东西(我没有检查过,只是一件简单的事情)

<script>
$("#button").click(function() {
$('#videoId').get(0).play();
setInterval(function(){window.location.replace("http://stackoverflow.com")}, $('#videoId').duration();
});
</script>
相关问题