From f8974f4164e2f4e0762ea4051392b45ce25a2bd1 Mon Sep 17 00:00:00 2001 From: horner Date: Fri, 9 Dec 2022 02:34:48 -0500 Subject: [PATCH] playClip works better when timer fires slowly --- src/stackTools/playClip.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/stackTools/playClip.js b/src/stackTools/playClip.js index ac764913a..76b0503de 100755 --- a/src/stackTools/playClip.js +++ b/src/stackTools/playClip.js @@ -139,7 +139,7 @@ function playClip(element, framesPerSecond) { playClipData = { intervalId: undefined, framesPerSecond: 30, - lastFrameTimeStamp: undefined, + lastFrameTimeStamp: new Date().getTime(), frameRate: 0, frameTimeVector: undefined, ignoreFrameTimeVector: false, @@ -182,15 +182,23 @@ function playClip(element, framesPerSecond) { startLoadingHandler, endLoadingHandler, errorLoadingHandler, + newlastFrameTimeStamp = new Date().getTime(), + deltatime = newlastFrameTimeStamp - playClipData.lastFrameTimeStamp, + frames = Math.round((playClipData.framesPerSecond / 1000) * deltatime), newImageIdIndex = stackData.currentImageIdIndex; const imageCount = stackData.imageIds.length; + if (frames > 1) { + console.log('frames:', frames); + } + if (playClipData.reverse) { - newImageIdIndex--; + newImageIdIndex -= frames; } else { - newImageIdIndex++; + newImageIdIndex += frames; } + playClipData.lastFrameTimeStamp = newlastFrameTimeStamp; if ( !playClipData.loop &&