Skip to content

Conversation

@ibrahimcesar
Copy link
Owner

Problem:

  • Users reported seeing CHECKPOINT 1 but not CHECKPOINT 2
  • The iframe was being added to the DOM, but YouTube Player API wasn't initializing
  • Root cause: "listening" postMessage was sent before iframe fully loaded

Solution:

  • Added iframe onload event listener to wait for full iframe initialization
  • Send "listening" message immediately when iframe loads
  • Extended retry delays from [0, 100, 250, 500, 1000]ms to [100, 300, 600, 1200, 2400]ms
  • Handle race conditions where load event might have already fired
  • Fallback strategy with longer delays if ref isn't ready

Technical Details:

  • The component now properly waits for iframe's load event before postMessage
  • YouTube's Player API needs time to initialize even after iframe loads
  • Retry logic ensures reliability across different network speeds
  • Maintains backward compatibility - all 51 tests pass

Impact:

  • Users should now consistently see CHECKPOINT 2 (Player Ready)
  • Events system will work more reliably across different browsers/networks
  • Better handling of slow network conditions

Fixes issue where YouTube Player API wasn't initializing properly.

Problem:
- Users reported seeing CHECKPOINT 1 but not CHECKPOINT 2
- The iframe was being added to the DOM, but YouTube Player API wasn't initializing
- Root cause: "listening" postMessage was sent before iframe fully loaded

Solution:
- Added iframe onload event listener to wait for full iframe initialization
- Send "listening" message immediately when iframe loads
- Extended retry delays from [0, 100, 250, 500, 1000]ms to [100, 300, 600, 1200, 2400]ms
- Handle race conditions where load event might have already fired
- Fallback strategy with longer delays if ref isn't ready

Technical Details:
- The component now properly waits for iframe's load event before postMessage
- YouTube's Player API needs time to initialize even after iframe loads
- Retry logic ensures reliability across different network speeds
- Maintains backward compatibility - all 51 tests pass

Impact:
- Users should now consistently see CHECKPOINT 2 (Player Ready)
- Events system will work more reliably across different browsers/networks
- Better handling of slow network conditions

Fixes issue where YouTube Player API wasn't initializing properly.
@ibrahimcesar ibrahimcesar merged commit 2414923 into main Nov 15, 2025
4 of 5 checks passed
@github-actions
Copy link
Contributor

size-limit report 📦

Path Size
ES Module 2.99 KB (0%)
CommonJS 2.96 KB (0%)
CSS 1.05 KB (0%)

ibrahimcesar pushed a commit that referenced this pull request Nov 15, 2025
Problem:
- Demo was importing from "react-lite-youtube-embed" (v2.6.0 from npm)
- This old version doesn't have the event timing fix from PR #203
- CHECKPOINT 2 wasn't showing because onReady events weren't firing

Solution:
- Changed import to "@ibrahimcesar/react-lite-youtube-embed"
- This uses the local source code (file:..) with all latest fixes
- Rebuilt package and reinstalled demo dependencies

Impact:
- Demo now uses latest event handling code
- CHECKPOINT 2 (Player Ready) should now appear consistently
- All event handlers will work properly

Fixes: CHECKPOINT 2 visibility issue reported by user
ibrahimcesar added a commit that referenced this pull request Nov 15, 2025
Problem:
- Demo was importing from "react-lite-youtube-embed" (v2.6.0 from npm)
- This old version doesn't have the event timing fix from PR #203
- CHECKPOINT 2 wasn't showing because onReady events weren't firing

Solution:
- Changed import to "@ibrahimcesar/react-lite-youtube-embed"
- This uses the local source code (file:..) with all latest fixes
- Rebuilt package and reinstalled demo dependencies

Impact:
- Demo now uses latest event handling code
- CHECKPOINT 2 (Player Ready) should now appear consistently
- All event handlers will work properly

Fixes: CHECKPOINT 2 visibility issue reported by user

Co-authored-by: Claude <[email protected]>
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.

3 participants