Fix play button not restarting ended clip#2261
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Here's a visual recap of what changed: Open the full interactive recap |
There was a problem hiding this comment.
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.

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.pausedasfalse(orisPlayingstale) 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
togglePlaybackto checkvideo.endedfirst, before checkingpaused/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 thev.endedcheck ahead of the!v.paused || isPlayingcheck intogglePlayback, so an ended clip resetscurrentTimeto 0 and callsrequestPlay()instead of being paused again.video-player.test.tsx: Added a test simulating an "ended" event wherepausedremainsfalse, verifying that clicking the player surface afterward resetscurrentTimeto 0 and resumes playback.To clone this PR locally use the Github CLI with command
gh pr checkout 2261You can tag me at @BuilderIO for anything you want me to fix or change