0

我在这里有一个 vimeo JavaScript,有人可以告诉我是否有可能让 vimeo 视频在完成后开始播放;

这是我到目前为止使用 JavaScript 的代码

// JavaScript Document

var animSpeed = 400;

function onPlay(id) {
jQuery('.blankOverlay').fadeIn(animSpeed);
jQuery('h2').text('You clicked play!');
}

function onPause(id) {

jQuery('.blankOverlay').fadeOut(animSpeed);
jQuery('h2').text('The video is paused.');
}

function onFinish(id) {
jQuery('.blankOverlay').fadeOut(animSpeed);
jQuery('h2').text('The video has now finished.');
}


jQuery(function($) {
// ---------------------------------------------------------------------------------------------

// --------------------------------------------- PHYSICIAN INDIVIDUAL PAGES --
/* ----- video player api (vimeo) ----- */
var iframe = $('#vplayer')[0],
player = $f(iframe);

// When the player is ready, add listeners for play, pause, finish, and playProgress
player.addEvent('ready', function() {

player.addEvent('play', onPlay);
player.addEvent('pause', onPause);
player.addEvent('finish', onFinish);
player.addEvent('playProgress', onPlayProgress);

});

$('.introContent, iframe').click(function(){    $('.blankOverlay').fadeIn(animSpeed); });
$('.blankOverlay').click(function(){ $(this).fadeOut(animSpeed);  player.api('pause'); });

// ---------------------------------------------------------------------------------------------
});
4

1 回答 1

0

player.api('play');finish事件处理程序中尝试。

像这样的东西

player.addEvent('finish', onFinish);

function onFinish(){
  player.api('play'); // this should take the video to the start again
}

如果您只想将视频恢复到初始状态,您可以使用

player.api('unload'); // this should take the video to initial state but will not automatically start

这是一个更新的演示,这里是更多方法的参考

更新

  1. 变量player在函数内部定义并从外部访问
  2. onPlayProgress根本没有定义引发错误的事件处理程序。

这是一个更新的演示

希望这可以帮助。

于 2015-04-16T14:59:18.463 回答