我有一个非常基本的JS,可以在vimeo iframe完成视频时运行。看看小提琴:http://jsfiddle.net/vy9kf0w5/1/
如何使用JS定位视频的完成?它看起来应该有效:p
document.getElementById('video').api_addEventListener('finish', function(event) {
alert('video has ended');
console.log('video has ended');
$('#video').addClass('finished');
});
答案 0 :(得分:3)
这是一个有效的例子http://jsfiddle.net/vy9kf0w5/3/
您需要在页面中加入Vimeo的Froogaloop脚本才能从Vimeo视频中获取活动。然后它非常简单,在他们支持的事件上只做你想要的:)你需要做的唯一的另一件事是将?api = 1& player_id = video添加到网址:)
IFRAME
<iframe src="//player.vimeo.com/video/55874553?api=1&player_id=video&title=0&byline=0&portrait=0&color=c9ff23;autoplay=1" width="720" height="405" id="video" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen ></iframe>
代码
var iframe = $('#video')[0],
player = $f(iframe);
player.addEvent('ready', function() {
player.addEvent('finish', onFinish);
});
function onFinish(id) {
alert('video has ended');
console.log('video has ended');
$('#vimeoembed').addClass('finished');
}
阅读有关Vimeos javaScript API here
的更多信息