You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@guacamole.apache.org by vn...@apache.org on 2017/07/19 18:37:14 UTC
[09/14] incubator-guacamole-client git commit: GUACAMOLE-346: Use
internal seekToFrame() to handle frame timing.
GUACAMOLE-346: Use internal seekToFrame() to handle frame timing.
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/519daeeb
Tree: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/tree/519daeeb
Diff: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/diff/519daeeb
Branch: refs/heads/master
Commit: 519daeebe206f338606ba73d89c8b6c287b6fc29
Parents: ed3c022
Author: Michael Jumper <mj...@apache.org>
Authored: Sat Jul 15 17:10:47 2017 -0700
Committer: Michael Jumper <mj...@apache.org>
Committed: Sat Jul 15 17:10:47 2017 -0700
----------------------------------------------------------------------
.../src/main/webapp/modules/SessionRecording.js | 67 ++++++++------------
1 file changed, 28 insertions(+), 39 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/519daeeb/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 6b74782..87be39c 100644
--- a/guacamole-common-js/src/main/webapp/modules/SessionRecording.js
+++ b/guacamole-common-js/src/main/webapp/modules/SessionRecording.js
@@ -152,16 +152,6 @@ Guacamole.SessionRecording = function SessionRecording(tunnel) {
var startRealTimestamp = null;
/**
- * The ID of the timeout which will play the next frame, if playback is in
- * progress. If playback is not in progress, the ID stored here (if any)
- * will not be valid.
- *
- * @private
- * @type {Number}
- */
- var playbackTimeout = null;
-
- /**
* The ID of the timeout which will continue the in-progress seek
* operation. If no seek operation is in progress, the ID stored here (if
* any) will not be valid.
@@ -327,8 +317,12 @@ Guacamole.SessionRecording = function SessionRecording(tunnel) {
*
* @param {function} callback
* The callback to invoke once the seek operation has completed.
+ *
+ * @param {Number} [delay=0]
+ * The number of milliseconds that the seek operation should be
+ * scheduled to take.
*/
- var seekToFrame = function seekToFrame(index, callback) {
+ var seekToFrame = function seekToFrame(index, callback, delay) {
// Abort any in-progress seek
abortSeek();
@@ -382,13 +376,14 @@ Guacamole.SessionRecording = function SessionRecording(tunnel) {
// If the seek operation has not yet completed, schedule continuation
if (currentFrame !== index)
- seekToFrame(index, callback);
+ seekToFrame(index, callback,
+ Math.max(delay - (new Date().getTime() - startTime), 0));
// Notify that the requested seek has completed
else
callback();
- }, 0);
+ }, delay || 0);
};
@@ -411,35 +406,30 @@ Guacamole.SessionRecording = function SessionRecording(tunnel) {
*/
var continuePlayback = function continuePlayback() {
- // Advance to next frame
- 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];
-
- // Calculate the real timestamp corresponding to when the next
- // frame begins
- var nextRealTimestamp = next.timestamp - startVideoTimestamp + startRealTimestamp;
+ // Pull the upcoming frame
+ var next = frames[currentFrame + 1];
- // Calculate the relative delay between the current time and
- // the next frame start
- var delay = Math.max(nextRealTimestamp - new Date().getTime(), 0);
+ // Calculate the real timestamp corresponding to when the next
+ // frame begins
+ var nextRealTimestamp = next.timestamp - startVideoTimestamp + startRealTimestamp;
- // Advance to next frame after enough time has elapsed
- playbackTimeout = window.setTimeout(function frameDelayElapsed() {
- continuePlayback();
- }, delay);
+ // 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
+ seekToFrame(currentFrame + 1, function frameDelayElapsed() {
+ continuePlayback();
+ }, delay);
- // Otherwise stop playback
- else
- recording.pause();
+ }
- });
+ // Otherwise stop playback
+ else
+ recording.pause();
};
@@ -641,7 +631,7 @@ Guacamole.SessionRecording = function SessionRecording(tunnel) {
*/
this.pause = function pause() {
- // Abort any in-progress seek
+ // Abort any in-progress seek / playback
abortSeek();
// Stop playback only if playback is in progress
@@ -651,8 +641,7 @@ Guacamole.SessionRecording = function SessionRecording(tunnel) {
if (recording.onpause)
recording.onpause();
- // Stop playback
- window.clearTimeout(playbackTimeout);
+ // Playback is stopped
startVideoTimestamp = null;
startRealTimestamp = null;