From 309cadaa47d7efd1ec504122f6076ea75602565f Mon Sep 17 00:00:00 2001 From: Sigve Sebastian Farstad Date: Sat, 1 Jul 2023 14:35:19 +0200 Subject: [PATCH] Store cuePoints across page loads This way, you don't need to set your cue points again and again. --- renin/src/renin.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/renin/src/renin.ts b/renin/src/renin.ts index 16e545c..3ee6231 100644 --- a/renin/src/renin.ts +++ b/renin/src/renin.ts @@ -64,6 +64,8 @@ export interface Options { maxHeight?: number; } +const stored = JSON.parse(localStorage.getItem('renin:stored') || '{}'); + export class Renin { static instance: Renin; width: number = 1; @@ -71,7 +73,7 @@ export class Renin { audioBar: AudioBar; music = new Music(); sync: Sync; - frame = 0; + frame = stored.frame || 0; oldTime: number = 0; time: number = 0; dt: number = 0; @@ -418,6 +420,9 @@ export class Renin { this.music.setPlaybackRate(playbackRates[e.key]); } }); + if (stored.frame) { + this.jumpToFrame(stored.frame); + } } startRealTimeScreenRecording() { @@ -638,6 +643,13 @@ export class Renin { if (this.options.productionMode) { return false; } + localStorage.setItem( + 'renin:stored', + JSON.stringify({ + frame: this.frame, + cuePoints: this.cuePoints.length > 0 ? this.cuePoints : null, + }) + ); let needsRenderAfter = false; const time = performance.now(); needsRenderAfter ||= this.fullscreenAnimation.update(this.uiTime);