GUACAMOLE-346: Playback must take into account that seeking is asynchronous.
Project: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/commit/23cf840b Tree: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/tree/23cf840b Diff: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/diff/23cf840b Branch: refs/heads/master Commit: 23cf840ba6935434752a3160de07206a012e6a25 Parents: b325eb8 Author: Michael Jumper <[email protected]> Authored: Sat Jul 15 16:12:21 2017 -0700 Committer: Michael Jumper <[email protected]> Committed: Sat Jul 15 16:12:21 2017 -0700 ---------------------------------------------------------------------- .../src/main/webapp/modules/SessionRecording.js | 40 ++++++++++---------- 1 file changed, 21 insertions(+), 19 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/23cf840b/guacamole-common-js/src/main/webapp/modules/SessionRecording.js ---------------------------------------------------------------------- diff --git a/guacamole-common-js/src/main/webapp/modules/SessionRecording.js b/guacamole-common-js/src/main/webapp/modules/SessionRecording.js index 13daa96..c4279ee 100644 --- a/guacamole-common-js/src/main/webapp/modules/SessionRecording.js +++ b/guacamole-common-js/src/main/webapp/modules/SessionRecording.js @@ -415,32 +415,34 @@ Guacamole.SessionRecording = function SessionRecording(tunnel) { var continuePlayback = function continuePlayback() { // Advance to next frame - seekToFrame(currentFrame + 1); + seekToFrame(currentFrame + 1, function playbackSeekComplete() { - // If frames remain after advancing, schedule next frame - if (currentFrame + 1 < frames.length) { + // If frames remain after advancing, schedule next frame + if (currentFrame + 1 < frames.length) { - // Pull the upcoming frame - var next = frames[currentFrame + 1]; + // Pull the upcoming frame + var next = frames[currentFrame + 1]; - // Calculate the real timestamp corresponding to when the next - // frame begins - var nextRealTimestamp = next.timestamp - startVideoTimestamp + startRealTimestamp; + // Calculate the real timestamp corresponding to when the next + // frame begins + var nextRealTimestamp = next.timestamp - startVideoTimestamp + startRealTimestamp; - // Calculate the relative delay between the current time and - // the next frame start - var delay = Math.max(nextRealTimestamp - new Date().getTime(), 0); + // Calculate the relative delay between the current time and + // the next frame start + var delay = Math.max(nextRealTimestamp - new Date().getTime(), 0); - // Advance to next frame after enough time has elapsed - playbackTimeout = window.setTimeout(function frameDelayElapsed() { - continuePlayback(); - }, delay); + // Advance to next frame after enough time has elapsed + playbackTimeout = window.setTimeout(function frameDelayElapsed() { + continuePlayback(); + }, delay); - } + } - // Otherwise stop playback - else - recording.pause(); + // Otherwise stop playback + else + recording.pause(); + + }); };
