Skip to content

Conversation

@AntonChesnokov
Copy link

Description

Fixes a bug where the YouTube player ignores the startSeconds input when both disablePlaceholder and playerVars.autoplay are set.

Problem

When using the YouTube player with:

  • disablePlaceholder="true"
  • playerVars="{autoplay: 1}"
  • startSeconds="N" (any non-zero value)

The video would autoplay but start from the beginning (0 seconds) instead of the specified start time.

Solution

Modified the condition in _createPlayer() to check for playerVars.autoplay === 1 in addition to the playVideo parameter. When the player is already playing (from autoplay), it now correctly uses seekTo() to jump to the specified startSeconds.

Changes

  • Updated src/youtube-player/youtube-player.ts to check for autoplay in playerVars
  • Added test case in src/youtube-player/youtube-player.spec.ts to validate the fix
  • Updated code comment to clarify the autoplay scenario

Testing

  • All existing tests pass
  • New test added specifically for this scenario

Related Issue

Fixes #32545

…utoplay

Fixes a bug where the YouTube player ignored the startSeconds input when
both disablePlaceholder and playerVars.autoplay were set. The player now
correctly seeks to the specified start time using seekTo() when the video
autoplays.

The issue occurred because the code only checked the playVideo parameter
to determine if seekTo should be called, but didn't account for videos
that autoplay through playerVars.autoplay = 1.

Fixes angular#32545
@AntonChesnokov
Copy link
Author

@adolgachev @tjshiu

Hi folks!
Just checking in on this PR - would appreciate any feedback when you have time.
Let me know if I need to make any changes. Thanks!

@tjshiu tjshiu added action: merge The PR is ready for merge by the caretaker target: patch This PR is targeted for the next patch release labels Dec 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: merge The PR is ready for merge by the caretaker area: youtube-player target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(YoutubePlayer): startSeconds input value is ignored with disablePlaceholder and playerVars containing autoplay: 1

2 participants