Skip to content

fix: syncMedia while playout is paused - #32

Merged
ronak-create merged 1 commit into
ronak-create:mainfrom
PlkMarudny:syncMedia-fix
Jul 18, 2026
Merged

fix: syncMedia while playout is paused#32
ronak-create merged 1 commit into
ronak-create:mainfrom
PlkMarudny:syncMedia-fix

Conversation

@PlkMarudny

@PlkMarudny PlkMarudny commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

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

  • Bug fix
  • New feature (transition / preset / text anim / effect / API)
  • Docs
  • Refactor / internal

How was it verified?

  • node --check server.js && node --check app.js && node --check mcp-server.js passes
  • Opened the editor and confirmed the change in preview
  • Confirmed the change in an export (fast or realtime), if it affects rendering
  • Updated CLAUDE.md / README.md if the schema, props, or API changed

Checklist

  • No new runtime dependencies added
  • Preview and export render identically (single compositor)
  • Commits are focused and messages are descriptive

Summary by CodeRabbit

  • Bug Fixes
    • Improved paused video previews so displayed frames remain synchronized with the timeline after clips are moved or trimmed.
    • Video playback positions now automatically correct minor timing drift during preview.
@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Paused preview synchronization now seeks active video elements when their media time differs from the timeline position after clip movement or trimming.

Changes

Media synchronization

Layer / File(s) Summary
Paused preview seek adjustment
app.js
syncMedia() updates active video currentTime when paused-preview drift exceeds approximately 0.04 seconds.

Estimated code review effort: 2 (Simple) | ~5 minutes

Suggested reviewers: xusnitdinov

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: fixing syncMedia behavior while playback is paused.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 880c7364-81e7-402f-b432-24da8170328e

📥 Commits

Reviewing files that changed from the base of the PR and between b70f469 and 435ccd6.

📒 Files selected for processing (1)
  • app.js
Comment thread app.js
Comment on lines +2240 to +2245
// 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 {}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀 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.js

Repository: 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.js

Repository: 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.js

Repository: 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.js

Repository: 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.js

Repository: 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.
@ronak-create
ronak-create merged commit 4d5c9a9 into ronak-create:main Jul 18, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants