HTML5视频重定向 [英] HTML5 video redirection
问题描述
基本上我要做的是让视频在完成播放后重定向到不同的网页(非常类似于YouTube用于播放列表的内容)。我在尝试这类问题之前尝试过一些研究,但似乎没有什么可以解决的。
Basically what I'm trying to do is make the video redirect to a different web page after it's finished playing (very similar to what YouTube uses for Playlists). I've tried doing a bit of research before asking this type of question but nothing seems to be working out for me.
这是代码:
<video id="example_video_1" class="video-js vjs-default-skin"
controls preload="auto" width="854" height="480"
poster="images/thumbnailbackgrounds/AE-DageSide.jpg"
data-setup='{"example_option":true}'>
<source src="files/Clip1.mp4" type='video/mp4' />
</video>
推荐答案
因为看起来你正在使用Video.JS为此,您应该查看他们的文档:
Since it looks like you're using Video.JS for this, you should have a look at their docs:
https://github.com/videojs/video.js/blob/master/docs/index.md
具体来说,API部分:
Specifically, the API section:
https://github.com/videojs/video.js/blob/master/docs/api.md
在活动部分,它说:
已结束
在达到媒体资源的末尾时触发。 currentTime ==持续时间
因此您需要获得对您的播放器的引用(也在该页面上):
So you'd need to get a reference to your player (also on that page):
var myPlayer = videojs("example_video_1");
然后收听已结束的事件,并从那里重定向:
and then listen for the ended event, and redirect from there:
function endedFunction(){
window.location = 'http://www.example.com/';
}
myPlayer.on("eventName", endedFunction);
这篇关于HTML5视频重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!