Skip to content

Commit

Permalink
Fix playbackRate breaking syncGroups and loops
Browse files Browse the repository at this point in the history
  • Loading branch information
Codas committed Jul 24, 2024
1 parent 3acf55b commit 4af202e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 12 deletions.
9 changes: 3 additions & 6 deletions src/canvas-effects/canvas-effect.js
Original file line number Diff line number Diff line change
Expand Up @@ -3031,7 +3031,7 @@ export default class CanvasEffect extends PIXI.Container {
setTimeout(() => {
this._resolve(this.data);
this.endEffect();
}, this._totalDuration);
}, this._totalDuration / this.mediaPlaybackRate);
}

_setupTimestampHook(offset) {
Expand Down Expand Up @@ -3069,6 +3069,7 @@ export default class CanvasEffect extends PIXI.Container {
if (!this.hasAnimatedMedia) return;

let creationTimeDifference = this.data.persist ? this.actualCreationTime - this.creationTimestamp : 0;
creationTimeDifference *= this.mediaPlaybackRate

// +1 because "loops: 1" means we run the animation one time, not that it restarts once
// whereas 0 means endless looping.
Expand Down Expand Up @@ -3128,7 +3129,7 @@ export default class CanvasEffect extends PIXI.Container {
if (this.mediaCurrentTime < this._endTime) {
return;
}
if (this.restartLoopHandler) {
if (this.restartLoopHandler != null) {
return;
}

Expand Down Expand Up @@ -3158,10 +3159,6 @@ export default class CanvasEffect extends PIXI.Container {
return;
}

// restart handler already registerd, just return and let it do its thing
if (this.restartLoopHandler != null) {
return
}
this._currentLoops++;
// register restart handler to trigger after loop delay
this.restartLoopHandler = setTimeout(() => {
Expand Down
6 changes: 3 additions & 3 deletions src/canvas-effects/sequencer-sprite-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ class VideoPlaybackControls extends PlaybackControls {
this.#video.pause();
}
get duration() {
return this.#video.duration / this.playbackRate;
return this.#video.duration;
}
get isPlaying() {
return !this.#video.paused;
Expand Down Expand Up @@ -289,7 +289,7 @@ class SpritePlaybackControls extends PlaybackControls {
this.#sprite.stop();
}
get duration() {
return this.#framecount / this.#framerate / this.playbackRate;
return this.#framecount / this.#framerate;
}
get isPlaying() {
return this.#sprite.playing;
Expand Down Expand Up @@ -600,7 +600,7 @@ export class SequencerSpriteManager extends PIXI.Container {
return this.#managedSprites[this.#activePath];
}
async #preloadVariants() {
if (this.#activePath === "TEXT") {
if (this.#activePath === "TEXT" /* SpecialSpriteKeys.Text */) {
return;
}
if (!this.#file || this.#file.isFlipbook) {
Expand Down
3 changes: 0 additions & 3 deletions src/modules/sequencer-file-cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ const SequencerFileCache = {
},

registerSpritesheet(inSrc, inSpriteSheet) {
console.log('register', inSrc)
const existingSheetRef = this._spritesheets.get(inSrc)
if (existingSheetRef ) {
existingSheetRef[1] += 1
Expand All @@ -97,7 +96,6 @@ const SequencerFileCache = {
console.error('trying to unlaod spritesheet that was not loaded:', inSrc)
}
existingSheetRef[1] -= 1
console.log('deregister', inSrc, 'new refscount', existingSheetRef[1])
if (existingSheetRef[1] > 0) {
return
}
Expand All @@ -110,7 +108,6 @@ const SequencerFileCache = {
// clean up related sheets starting with the last (leaf)

const cacheKeys = [get_sheet_image_url(inSrc, sheet), foundry.utils.getRoute(inSrc)]
console.log('unloading', cacheKeys)
PIXI.Assets.unload(cacheKeys.filter(src => !!src))
}
};
Expand Down

0 comments on commit 4af202e

Please sign in to comment.