I am not sure if the vimeo API allows this:
I have this html code:
<iframe id="vm-player"
src="http://player.vimeo.com/video/27855315?api=1&player_id=vm-player"
frameborder="0"
webkitAllowFullScreen mozallowfullscreen allowFullScreen>
</iframe>
And I have this JavaScript code using the froogaloop.js from Vimeo:
var iframe = $('#vm-player')[0];
var vmPlayer = $f(iframe);
function ready(player_id) {
// Keep a reference to Froogaloop for this player
var vmPlayer = $f(player_id);
}
$(window).bind('ready', function() {
//Attach the ready event to the iframe
$f(document.getElementById('vm-player')).addEvent('ready', ready);
});
When I call the vmPlayer.api('play');
after this, it works. But after I change the src attribute on the iframe through JavaScript, the vmPlayer.api() calls doesn't do anything. It looks like it loses reference to the player somehow.
This is how I change the src attribute through jQuery:
function playVmVideo(id) {
$('#vm-player').attr('src',
'http://player.vimeo.com/video/'
+ id + '?api=1&player_id=vm-player');
vmPlayer.api('play');
}