2 つの Vimeo ビデオが埋め込まれたサイトで作業しています。2 番目のビデオを再生すると、最初のビデオが再生中の場合、最初のビデオは一時停止されます。これは美しく機能します。ただし、最初のビデオが一時停止されると、再び再生されることはありません。どんな考えでも大歓迎です!
var vimeo = {
videos: [],
currentVideo: null,
init: function (element, i) {
var videoData = {
'title': $(element).html(),
'id': 'video-' + i,
'url': $(element).attr('href'),
'width': $(element).data('width'),
'height': $(element).data('height')
};
$.getJSON('http://www.vimeo.com/api/oembed.json?url=' + encodeURIComponent(videoData.url) + '&api=1&player_id='+ videoData.id +'&width='+ videoData.width +'&height='+ videoData.height +'&callback=?', function(data){
$(element).html(data.html);
$(element).find('iframe').load(function(){
player = this;
$(player).attr('id', videoData.id);
$f(player)
.addEvent('ready', function(player_id){
vimeo.videos.push($f(player_id));
})
.addEvent('play', function(player_id){
if (vimeo.currentVideo != null) vimeo.currentVideo.api('pause');
vimeo.currentVideo = $f(player_id);
});
});
});
}
}
$(document).ready(function () {
$('a.vimeo').each(function(i) {
vimeo.init(this, i);
});
});