[Bug] YouTube Provider: TypeError: K.Wp.o1 is not a function when attempting to programmatically seek to 0
Current Behavior: When attempting to programmatically restart a YouTube video (by setting player.currentTime = 0 or using remote.seek(0)), the player throws an Uncaught TypeError: K.Wp.o1 is not a function.
This error originates from the YouTube iframe's internal base.js and appears to happen when the player is in a paused, buffering, or ended state. The player gets "stuck" and cannot be restarted.
Expected Behavior: When a user clicks a custom control (like an "Replay" overlay), the player should:
Seek to the beginning (currentTime = 0).
Unmute (muted = false).
Begin playback (play()).
Steps To Reproduce:
Initialize a
Allow the video to play, then manually pause it.
From an external click handler (like a custom button or overlay), try to restart and unmute the video.
The following code, which attempts to fix the race condition from issue #1605, still fails:
JavaScript
// This code runs inside an async click handler try { // 1. Tell the player to pause. console.log('[DEBUG] 1. Calling player.pause()'); await player.pause();
// 2. Wait for the 'pause' event to confirm it's done. console.log('[DEBUG] 2. Waiting for "pause" event to complete...'); await new Promise(resolve => { const onPause = () => { player.removeEventListener('pause', onPause); resolve(); }; player.addEventListener('pause', onPause); });
// 3. This line triggers the error console.log('[DEBUG] 3. "pause" event complete. Setting currentTime = 0'); player.currentTime = 0;
// 4. Unmute and play player.muted = false; player.volume = 1; await player.play();
} catch (e) { console.error("Error during 'Pause-Wait-Seek' process:", e); } Observe the console for the Uncaught TypeError: K.Wp.o1 is not a function error as soon as player.currentTime = 0 is set.
Error Log: Uncaught TypeError: K.Wp.o1 is not a function at uW.Y (base.js:11477:140) at R82 (base.js:6122:276) at g.H.TL (base.js:11655:255) ... What We've Tried (Workarounds): This appears to be a deep state issue in the YouTube provider, as all logical approaches fail:
Direct player.currentTime = 0: Causes the K.Wp.o1 error.
remote.seek(0): This request is dispatched but is ignored by the provider (no restart, no error).
remote.startLoading(): This also seems to have no effect. It does not reload the media or restart playback.
Play-then-Seek (player.play() -> listen for 'started' -> remote.seek(0)): The seek command is ignored.
Seek-then-Play (remote.seek(0) -> listen for 'seeked' -> player.play()): The initial seek command is ignored, so the 'seeked' event never fires.
It seems the YouTube provider is in a state where it will not accept any seek command (either direct or remote) when it is not actively playing. This makes it impossible to implement a custom "replay" button.
Environment: Framework: Web Components (via CDN)
Browser: Chromium-based browsers (Chrome, Edge)
Vidstack: latest (from https://cdn.vidstack.io/player)
Hi @Gilsz , I've been able to reproduce the issue by following these steps:
- create an external button to change the
currentTimeprogrammatically, for example:
<button id="seek-to-zero">Seek to 0</button>
...
const buttonElement = document.querySelector("#seek-to-zero");
buttonElement.addEventListener("click", async () => {
try {
playerInstance.currentTime = 0;
playerInstance.muted = false;
playerInstance.volume = 1;
await playerInstance.play();
} catch (error) {
console.error("Error during seekTo 0", error);
}
});
- press the play button to start the video content
- after a few seconds, click on "Seek to 0" button. The video restarts correctly from position 0.
- the video content restart from position 0
- after a few more seconds, click on the seek bar at a position that hasn’t been buffered yet.
Result
The player gets stuck and cannot be restarted.
I've created a PR (#1722) to fix this by adding the allowSeekAhead parameter to the seekTo method within the YouTube provider.
With this change, the player no longer gets stuck and works as expected. Let me know.