From 3e556a5c546733eab53ada787e9eb2658c990bb2 Mon Sep 17 00:00:00 2001 From: calzoneman Date: Tue, 5 Mar 2013 14:42:14 -0600 Subject: [PATCH] Fix vimeo synch --- www/assets/js/functions.js | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/www/assets/js/functions.js b/www/assets/js/functions.js index ec5f5268..db2cea30 100644 --- a/www/assets/js/functions.js +++ b/www/assets/js/functions.js @@ -311,9 +311,12 @@ function updateVI(data) { else if(data.id != PLAYER.videoid) { initVI(data); } - // Hack because of their async api - // Set this and wait for playProgress to fire to compare it - PLAYER.lastUpdate = data; + + PLAYER.api('getCurrentTime', function(time) { + if(Math.abs(time - data.currentTime) > SYNC_THRESHOLD) { + PLAYER.api('seekTo', data.currentTime); + } + }); } // Loads up a Vimeo player @@ -331,12 +334,6 @@ function initVI(data) { PLAYER.addEvent('ready', function() { // Autoplay PLAYER.api('play'); - // Watch the progress and compare it with the most recent sync - PLAYER.addEvent('playProgress', function(data, id) { - if(Math.abs(parseInt(data.seconds) - PLAYER.lastUpdate.currentTime) > SYNC_THRESHOLD) { - PLAYER.api('seekTo', PLAYER.lastUpdate.currentTime); - } - }); }); MEDIATYPE = "vi"; }