Vimeo的球员没有得到"完成"事件 [英] Vimeo player doesn't get "finish" event
问题描述
我有当IFRAME VIMEO完成视频的作品一个很基本的JS。看看小提琴: http://jsfiddle.net/vy9kf0w5/1/
我怎样可以针对与JS视频的结束?它看起来像它应该工作:P
的document.getElementById('视频')。api_addEventListener('完成',函数(事件){
警报('视频已经结束');
的console.log('视频已经结束');
$('#视频')addClass('完成');
});
下面你是一个工作的例子的http:/ /jsfiddle.net/vy9kf0w5/3/
您需要在为了您的Vimeo的网页的 Froogaloop 脚本摆脱Vimeo的视频事件。然后,它是非常简单的,在他们的支持的事件只是做你想做的:)你需要做的唯一的另一件事是添加API = 1&安培; player_id =视频的网址:?)
IFRAME
< IFRAME src=\"//player.vimeo.com/video/55874553?api=1&player_id=video&title=0&byline=0&portrait=0&color=c9ff23;autoplay=1\" WIDTH =720HEIGHT =405ID =视频FRAMEBORDER =0webkitallowfullscreen mozallowfullscreen的allowFullScreen>< / IFRAME>
在code
VAR IFRAME = $('#视频')[0]
球员= $ F(IFRAME);player.addEvent('准备好',函数(){
player.addEvent(完成,onFinish);
});功能onFinish(ID){
警报('视频已经结束');
的console.log('视频已经结束');
$('#vimeoembed')addClass('完成');
}
了解更多关于Vimeos JavaScript API第这里
I have a very basic JS that works when the vimeo iframe finishes the video. Take a look at the fiddle: http://jsfiddle.net/vy9kf0w5/1/
How can I target the finish of the video with JS? It looks like it should work :p
document.getElementById('video').api_addEventListener('finish', function(event) {
alert('video has ended');
console.log('video has ended');
$('#video').addClass('finished');
});
Here you are a working example http://jsfiddle.net/vy9kf0w5/3/
You need to include Vimeo's Froogaloop script in your page in order to get events from Vimeo videos. Then it is very simple, on their supported events just do what you want :) The only other thing you need to do is to add ?api=1&player_id=video to the url :)
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>
The CODE
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');
}
Read more about Vimeos javaScript API here
这篇关于Vimeo的球员没有得到&QUOT;完成&QUOT;事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!