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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

1 participant