fix: reconcile inline YouTube play/pause with real playback - #513
Draft
posthog-eu[bot] wants to merge 1 commit into
Draft
fix: reconcile inline YouTube play/pause with real playback#513posthog-eu[bot] wants to merge 1 commit into
posthog-eu[bot] wants to merge 1 commit into
Conversation
The overlay play/pause button drove playback off a reducer-only isPlaying flag seeded from `autoplay`, so picking a topic rendered "Pause" for a video that had never started (YouTube blocks unmuted autoplay). The first click then paused nothing and the button stayed out of step, producing rage-clicks. - Seed isPlaying=false; apply autoplay intent on `onReady` instead of before the embed is playable. - Toggle now drives the media element (play()/pause()) and reconciles the button against playerRef.current.paused, so a rejected click corrects the icon instead of desyncing. - handleSeek's silent-bail branches now re-pin the scrubber to the real position and surface a transient hint (loading / can't-seek) instead of doing nothing. Generated-By: PostHog Code Task-Id: c0a8023d-c3ed-4a75-961a-9d7ac8df1afa
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
InlineYouTubePlayerdrove playback off a reducer-onlyisPlayingflag with nothing reconciling it against the real iframe:createInitialPlayerState(autoplay)seededisPlaying: true, and topic selection passesautoplay, so the overlay renderedaria-label="Pause video"before the embed loaded — but YouTube won't autoplay unmuted without a gesture, so the first click paused a video that never started and the states stayed desynced.handleSeekbailed silently in three branches (not ready, no duration,currentTimethrows), so dragging the scrubber could do nothing with zero feedback.Changes
isPlaying: false; apply autoplay intent inonReadyonce the embed is actually playable.togglePlaynow drives the media element (play()/pause()) and, when the browser rejectsplay()(autoplay policy), corrects the button fromplayerRef.current.pausedinstead of desyncing.handleSeek's silent-bail branches re-pin the thumb to the video's real position and surface a transient hint (Video is still loading…/Couldn't seek right now) via anaria-livestatus.Testing
npx tsc --noEmit— no new errors in the changed file (pre-existing SVG/JSON module-declaration errors are unrelated).Agent context
captureInlineVideoLoadFailedtelemetry in the same files. It doesn't touch the toggle or seek path, so this is additive and merges independently — based ondevto keep review focused.Created with PostHog Desktop from this inbox report.