[英]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
player
在函數內部定義,可以從外部訪問 onPlayProgress
沒有定義事件處理程序onPlayProgress
會引發錯誤。 希望這可以幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.