Skip to content

Fix play button not restarting ended clip#2261

Open
shomix wants to merge 1 commit into
mainfrom
ai_main_a20bc868e38447ad8865
Open

Fix play button not restarting ended clip#2261
shomix wants to merge 1 commit into
mainfrom
ai_main_a20bc868e38447ad8865

Conversation

@shomix

@shomix shomix commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes the play/pause toggle in the clips video player so clicking play after a clip finishes always restarts playback from the beginning.

Problem

When a clip finished playing, clicking the play button did nothing. This happened because the browser can leave video.paused as false (or isPlaying stale) at end of stream due to MSE end-of-stream / DB-duration mismatches, causing the toggle logic to treat the click as a "pause" action on an already-ended element instead of replaying it.

Solution

Reordered the toggle logic in togglePlayback to check video.ended first, before checking paused/isPlaying. This ensures a finished clip is always reset to the start and replayed, regardless of the browser's reported paused state.

Key Changes

  • video-player.tsx: Moved the v.ended check ahead of the !v.paused || isPlaying check in togglePlayback, so an ended clip resets currentTime to 0 and calls requestPlay() instead of being paused again.
  • video-player.test.tsx: Added a test simulating an "ended" event where paused remains false, verifying that clicking the player surface afterward resets currentTime to 0 and resumes playback.

Edit in Builder  Preview


To clone this PR locally use the Github CLI with command gh pr checkout 2261

You can tag me at @BuilderIO for anything you want me to fix or change

@netlify

This comment has been minimized.

@builder-io-integration builder-io-integration Bot changed the title Update from the Builder.io agent Fix play button not restarting ended clip Jul 20, 2026
@netlify

This comment has been minimized.

@netlify

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

Here's a visual recap of what changed:

Visual recap

Open the full interactive recap

@builder-io-integration builder-io-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Builder reviewed your changes — looks good ✅

Review Details

Code Review Summary

PR #2261 fixes the clips player replay path by checking HTMLVideoElement.ended before consulting potentially stale paused and React isPlaying state. When a clip has ended, the player now seeks to time 0 and calls the existing requestPlay() path; otherwise, the existing pause/play toggle behavior remains unchanged. The added test specifically models the MSE/end-of-stream edge case where ended is true while paused remains false.

The approach is sound and appropriately localized to the shared VideoPlayer component, with coverage added at the component-test level. Two independent code-review passes found no confirmed high- or medium-severity issues; the hook dependencies and replay control flow are correct. This is a low-risk UI behavior fix, and no actionable findings are being posted.

🧪 Browser testing: Attempted after review, but execution was blocked because the browser-test executor lacked the required Chrome automation tools; no user-facing flows could be verified.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants