我不确定 vimeo API 是否允许这样做:
我有这个 html 代码:
  <iframe id="vm-player"
      src="http://player.vimeo.com/video/27855315?api=1&player_id=vm-player" 
      frameborder="0" 
      webkitAllowFullScreen mozallowfullscreen allowFullScreen>
  </iframe>
我使用来自 Vimeo 的 froogaloop.js 有这个 JavaScript 代码:
  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);
    });
当我vmPlayer.api('play');在此之后调用时,它可以工作。但是在我通过 JavaScript 更改 iframe 上的 src 属性后,vmPlayer.api() 调用没有做任何事情。看起来它以某种方式失去了对玩家的参考。这就是我通过 jQuery 更改 src 属性的方式:
  function playVmVideo(id) {
    $('#vm-player').attr('src',
                         'http://player.vimeo.com/video/'
                         + id + '?api=1&player_id=vm-player');
    vmPlayer.api('play');
  }