Skip to content

bug(Angular Youtube player: Getting YT is undefined in Pause video function #29030

@mattiLeBlanc

Description

@mattiLeBlanc

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

No response

Description

For one of our clients we see a lot of errors like YT is not definedReferenceError: YT is not defined.
When I check the source of the error, it is happening in

   /** See https://developers.google.com/youtube/iframe_api_reference#pauseVideo */
    pauseVideo() {
        if (this._player) {
            this._player.pauseVideo();
        }
        else {
            this._getPendingState().playbackState = YT.PlayerState.PAUSED;
        }

YT is not available somehow.

I haven;t been able to reproduce this error so I don't know if it is a firewall related issue, that some youtube code gets flittered out?

Reproduction

I can't reproduce this issue in Stackblitz because it is an internal source code issue.
the Code I use for using the player is:

<youtube-player [height]="height" [width]="width"  (stateChange)="stateChange($event)" [playerVars]="playerVars" #youtubePlayer></youtube-player>

Expected Behavior

No error when pausing video

Actual Behavior

Throwing YT is undefined error

Environment

  • Angular: 17
  • CDK/Material: 17
  • Browser(s): 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36`
  • Operating System (e.g. Windows, macOS, Ubuntu): Android table

Metadata

Metadata

Assignees

Labels

P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: youtube-player

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions