簡體   English   中英

使用Vimeo API進行視頻控制

[英]Video control using Vimeo API

我這里有一個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'); });

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

嘗試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沒有定義事件處理程序onPlayProgress會引發錯誤。

這是更新的演示

希望這可以幫助。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM