Skip to content

Conversation

@ibrahimcesar
Copy link
Owner

The player state events (onPlay, onPause, onStateChange, etc.) were not firing reliably in the demo because the "listening" postMessage was sent before the YouTube iframe API was fully initialized.

Changes:

  • Add retry logic with exponential backoff delays (0, 100, 250, 500, 1000ms)
  • YouTube iframe initialization time varies by network/browser conditions
  • Multiple retry attempts ensure the listening message is received
  • Fix TypeScript type for setTimeout (use ReturnType instead of NodeJS.Timeout)

This resolves the issue where the Player State display would stay stuck on "Not Started" even after playing the video.

Impact:

  • Fixes event tracking in the demo's Interactive Events section
  • Improves reliability for all event handlers (onReady, onPlay, etc.)
  • No breaking changes - fully backward compatible
  • All 51 tests passing

The player state events (onPlay, onPause, onStateChange, etc.) were not
firing reliably in the demo because the "listening" postMessage was sent
before the YouTube iframe API was fully initialized.

Changes:
- Add retry logic with exponential backoff delays (0, 100, 250, 500, 1000ms)
- YouTube iframe initialization time varies by network/browser conditions
- Multiple retry attempts ensure the listening message is received
- Fix TypeScript type for setTimeout (use ReturnType instead of NodeJS.Timeout)

This resolves the issue where the Player State display would stay stuck
on "Not Started" even after playing the video.

Impact:
- Fixes event tracking in the demo's Interactive Events section
- Improves reliability for all event handlers (onReady, onPlay, etc.)
- No breaking changes - fully backward compatible
- All 51 tests passing
@github-actions
Copy link
Contributor

size-limit report 📦

Path Size
ES Module 2.91 KB (+0.95% 🔺)
CommonJS 2.87 KB (+0.93% 🔺)
CSS 1.05 KB (0%)

@ibrahimcesar ibrahimcesar changed the title Fix player state not updating on play fix: player state not updating on play Nov 15, 2025
@ibrahimcesar ibrahimcesar merged commit 6f6bed0 into main Nov 15, 2025
7 of 8 checks passed
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