/ proof-of-concept / steelsim21
Sign in
proof-of-concept / steelsim21
Return to live view when playback ends
Jeremy Magland <jmagland@flatironinstitute.org> committed commit 38f6b3e8887e parent de24345 Browse files
1 changed file+14−2
src/main.tsmodified+14−2View file
@@ -375,16 +375,28 @@ function buildMovieToolbar(): void {
375375 });
376376 timeLabel.className = "time";
377377 btnLive.addEventListener("click", () => { live = true; updateLiveButton(); });
378+ // Playback drives the movie; afterwards the view returns to where it was (live or scrubbed).
379+ let liveBeforePlay = true;
380+ const endPlayback = () => {
381+ btnPlay.textContent = "Play";
382+ if (liveBeforePlay) {
383+ live = true;
384+ updateLiveButton();
385+ }
386+ };
378387 btnPlay.addEventListener("click", () => {
379- if (player.playing) { player.stop(); btnPlay.textContent = "Play"; return; }
388+ if (player.playing) { player.stop(); endPlayback(); return; }
380389 if (!sim || sim.samples === 0) return;
390+ liveBeforePlay = live;
381391 const offset = live ? 0 : scrubFrame / sim.fps;
382392 live = false;
383393 player.play(sim.processedAudio(), sim.fs, offset, levelSel.value as LevelMode, gainDb());
384394 btnPlay.textContent = "Stop";
385395 updateLiveButton();
386396 });
387- player.onEnded = () => { btnPlay.textContent = "Play"; };
397+ player.onEnded = endPlayback;
398+ scrub.addEventListener("input", () => { liveBeforePlay = false; });
399+ btnLive.addEventListener("click", () => { liveBeforePlay = true; });
388400 btnWav.addEventListener("click", () => {
389401 if (!sim || sim.samples === 0) return;
390402 const blob = encodeWav(sim.processedAudio(), sim.fs, levelSel.value as LevelMode, gainDb());
↑↓ move↵openescclose