player icon indicating copy to clipboard operation
player copied to clipboard

fix(youtube): add allowSeekAhead parameter to seekTo command

Open pzanella opened this issue 2 months ago • 0 comments

Related:

Closes: #1714

Description:

Fix YouTube Provider Seek Issues by adding allowSeekAhead parameter

This PR fixes a critical issue in the YouTube provider where seeking operations (especially currentTime = 0) would cause the player to get stuck in a "waiting" state or throw Uncaught TypeError: K.Wp.o1 is not a function errors.

Root Cause: The YouTube iframe API's seekTo() method requires two parameters: seekTo(seconds, allowSeekAhead). Passing the first parameter, causing YouTube to reject seeks to unbuffered content and leading to corrupted internal state. Here the YouTube documentation.

Changes Made:

  1. Updated YouTube provider's setCurrentTime() method to pass allowSeekAhead: true
  2. Modified command type definitions to support multiple arguments for seekTo
  3. Enhanced #remote() method to handle seekTo specially without double-wrapping arguments
  4. Added proper YouTube API compliance by passing both required parameters

Key Fix:

// Before (broken):
this.#remote('seekTo', time);

// After (fixed):
this.#remote('seekTo', [time, true]); // enables allowSeekAhead

This ensures YouTube receives player.seekTo(time, true); with the correct parameters, allowing seeks to any position regardless of buffer state.

Ready?

Yes - This PR is ready for review. The fix has been tested and resolves the YouTube seeking issues.

Anything Else?

  • All existing functionality preserved
  • Only affects YouTube provider behavior
  • Backward compatible with current API

pzanella avatar Nov 10 '25 18:11 pzanella