fix: syncMedia while playout is paused - #32
Conversation
📝 WalkthroughWalkthroughPaused preview synchronization now seeks active video elements when their media time differs from the timeline position after clip movement or trimming. ChangesMedia synchronization
Estimated code review effort: 2 (Simple) | ~5 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@app.js`:
- Around line 2240-2245: Update the paused-preview seek logic in syncMedia() to
skip writing el.currentTime when a seek is already in flight, using el.seeking
or an equivalent pending-target guard. Preserve the existing frame, activeAt,
and threshold checks while preventing repeated seeks across consecutive paused
frames.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
| // Paused preview: keep decode head on the frame under the playhead. | ||
| // Needed when clips move/trim without setTime (drag does not scrub time). | ||
| if (!state.playing && enabled && c.kind === "video" && activeAt(c, t) && | ||
| Math.abs(el.currentTime - mt) > 0.04) { | ||
| try { el.currentTime = mt; } catch {} | ||
| } |
There was a problem hiding this comment.
🚀 Performance & Scalability | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Locate the relevant function and nearby logic.
rg -n "function syncMedia|syncMedia\\(|currentTime = mt|el\\.seeking|paused preview|activeAt\\(" app.js
# Show the target area with line numbers.
sed -n '2200,2275p' app.jsRepository: ronak-create/FableCut
Length of output: 4284
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Inspect the main loop and any explicit paused-seek callers.
sed -n '3285,3395p' app.js
printf '\n---\n'
rg -n "seekMediaWhilePaused\\(|syncMedia\\(" app.jsRepository: ronak-create/FableCut
Length of output: 4818
🏁 Script executed:
#!/bin/bash
set -euo pipefail
sed -n '1678,1715p' app.js
printf '\n---\n'
sed -n '3500,3635p' app.jsRepository: ronak-create/FableCut
Length of output: 7554
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Look for any explicit use of the media element's seeking state in the file.
rg -n "\.seeking\b|seeked\b|seeking\b" app.jsRepository: ronak-create/FableCut
Length of output: 465
🏁 Script executed:
#!/bin/bash
set -euo pipefail
sed -n '1678,1715p' app.js
printf '\n---\n'
sed -n '3500,3635p' app.js
printf '\n---\n'
rg -n "\.seeking\b|seeked\b|seeking\b" app.jsRepository: ronak-create/FableCut
Length of output: 7865
Skip paused-preview seeks while one is already in flight.
syncMedia() runs every frame while paused, so this currentTime write can retrigger the same seek for several frames on slower clips. Add an !el.seeking or pending-target guard to avoid redundant seeks.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@app.js` around lines 2240 - 2245, Update the paused-preview seek logic in
syncMedia() to skip writing el.currentTime when a seek is already in flight,
using el.seeking or an equivalent pending-target guard. Preserve the existing
frame, activeAt, and threshold checks while preventing repeated seeks across
consecutive paused frames.
What does this PR do?
While paused, syncMedia() did not seek. Dragging a clip on the timeline did not update the preview.
Type of change
How was it verified?
node --check server.js && node --check app.js && node --check mcp-server.jspassesCLAUDE.md/README.mdif the schema, props, or API changedChecklist
Summary by CodeRabbit