我有一个javascript代码,可以在视频src之前加载另一个视频后播放视频。我想要的是当第二个视频结束时自动将我重定向到其他页面,这是我的代码:
<script type="text/javascript">
var videoplayer = document.getElementById("videoplayer");
var video = $('video')[0];
videoplayer.addEventListener('click',function(){
videoplayer.play();
},false);
videoplayer.addEventListener('ended',function(){
var nextVideo = "C:/Users/Video Turismo/Desktop/Spots y videos/Vidios/Lamb.mp4";
videoplayer.src = nextVideo;
videoplayer.pause();
$('video').unbind('ended');
window.location("www.google.com");
},false);
</script>
<video width="100%" height="50%" controls id="videoplayer" >
<source src="C:/Users/Video Turismo/Desktop/Spots y videos/Vidios/NEGAS.mp4">
</video>
答案 0 :(得分:0)
我认为您应该询问video.src是否已经是nextVideo,然后更改位置或其他内容。这样你知道第二个视频结束了。
var videoplayer = document.getElementById("videoplayer");
var video = $('video')[0];
videoplayer.addEventListener('click', function(){
videoplayer.play();
},false);
videoplayer.addEventListener('ended', function(){
var nextVideo = "C:/Users/Video Turismo/Desktop/Spots y videos/Vidios/Lamb.mp4";
if (videoplayer.src == nextVideo) {
window.location("www.google.com");
}
videoplayer.src = nextVideo;
videoplayer.pause();
}, false);
<video width="100%" height="50%" controls id="videoplayer" >
<source src="C:/Users/Video Turismo/Desktop/Spots y videos/Vidios/NEGAS.mp4">
</video>