Skip to content

Comments

fix: prevent video from auto-playing when it finishes loading#1316

Merged
yiiqii merged 3 commits intofeat/2.8from
fix/video-autoplay
Dec 15, 2025
Merged

fix: prevent video from auto-playing when it finishes loading#1316
yiiqii merged 3 commits intofeat/2.8from
fix/video-autoplay

Conversation

@ChengYi996
Copy link
Collaborator

@ChengYi996 ChengYi996 commented Dec 12, 2025

Summary by CodeRabbit

  • Refactor
    • Improved video loading reliability and error handling for smoother playback start.
    • Optimized event handling to reduce redundant listeners and ensure clearer failure paths.
    • Explicit load triggering to make startup behavior more consistent.
    • No changes to public APIs or exported interfaces; behavior is more robust without surface changes.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 12, 2025

Walkthrough

Replaces the previous play().catch / loadeddata branching with a canplay-based load flow in the downloader module, adding explicit handleCanPlay and handleError handlers, an explicit video.load() call, and updated one-time event listener registration and cleanup. No public API changes.

Changes

Cohort / File(s) Summary
Video loading refactor
packages/effects-core/src/downloader.ts
Reworked loadVideo to resolve on canplay and reject on error; added explicit video.load(); introduced handleCanPlay and handleError; removed loadeddata-based resolve and pending-promise branch; updated event listener registration to use { once: true } and remove the counterpart handler; added a temporary Chinese comment. No exported signatures changed.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Single-file change with focused control-flow adjustments around DOM video events.
  • Review focus:
    • Ensure promise resolution/rejection semantics match previous behavior (timing differences between loadeddata vs canplay).
    • Verify event listener cleanup and the use of { once: true } to avoid leaks or missed handlers.
    • Confirm explicit video.load() does not introduce double-load or race conditions in existing consumers.

Poem

🐰 I nudged the video to wake and play,
Canplay now leads the gentle way,
Errors wave and listeners fall,
Load called once — no missing call,
A hopping fix to tidy the day.

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: preventing video auto-play when loading finishes, which is reflected in the code changes that replace loadeddata-based resolution with canplay-based flow and explicit event handling.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/video-autoplay

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 and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cc972fe and d43e69f.

📒 Files selected for processing (1)
  • packages/effects-core/src/downloader.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Analyze (javascript-typescript)

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
packages/effects-core/src/downloader.ts (1)

299-300: Consider translating the comment to English.

The implementation correctly prevents autoplay by using explicit load() without calling play(). However, the Chinese comment could be translated to English for consistency with the rest of the codebase.

Apply this diff to translate the comment:

-    // 显式触发视频加载
+    // Explicitly trigger video loading
     video.load();
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d43e69f and 0d996c2.

📒 Files selected for processing (1)
  • packages/effects-core/src/downloader.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (1)
packages/effects-core/src/downloader.ts (1)

296-297: Past review concern addressed correctly.

The event listeners now use { once: true }, which ensures automatic cleanup and avoids the previous capture-mismatch issue. The cross-removal pattern in the handlers provides additional safety.

@yiiqii yiiqii merged commit b86e99c into feat/2.8 Dec 15, 2025
2 checks passed
@yiiqii yiiqii deleted the fix/video-autoplay branch December 15, 2025 01:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants