私はなんとか問題を解決しました...これがjsfiddleソリューションです。
var vimeoPlayers = [];
function VimeoPlayer (playerId) {
var iframe = $('#' + playerId),
contentWindow = iframe[0].contentWindow,
targetOriginUrl = iframe.attr('src').split('?')[0];
console.log(iframe);
console.log(contentWindow);
console.log(targetOriginUrl);
contentWindow.postMessage({ 'method': 'addEventListener', 'value': 'pause' }, "http:"+targetOriginUrl);
contentWindow.postMessage({ 'method': 'addEventListener', 'value': 'play' }, "http:"+targetOriginUrl);
return {
play: function () {
contentWindow.postMessage({ 'method': 'play' }, "http:"+targetOriginUrl);
},
pause: function() {
contentWindow.postMessage({ 'method': 'pause' }, "http:"+targetOriginUrl);
},
unload: function() {
contentWindow.postMessage({ 'method': 'unload' }, "http:"+targetOriginUrl);
}
}
}
// Listen for postMessage events
$(window).on('message', function(e) {
var data = $.parseJSON(e.originalEvent.data);
if (data.event === 'ready') {
var vimeoPlayer = new VimeoPlayer(data.player_id);
vimeoPlayers.push(vimeoPlayer);
}
if(data.event==='play'){
console.log('play');
}
if(data.event==='pause'){
console.log('pause');
}
console.log(data);
});
$('.vimeo-controls .pause-all').on('click', function () {
for (var i = 0; i < vimeoPlayers.length; i++) {
vimeoPlayers[i].pause();
}
});
$('.vimeo-controls .play-all').on('click', function () {
for (var i = 0; i < vimeoPlayers.length; i++) {
vimeoPlayers[i].play();
}
});
$('.vimeo-controls .unload-all').on('click', function () {
for (var i = 0; i < vimeoPlayers.length; i++) {
vimeoPlayers[i].unload();
}
});