Addressing player.playVideo is not a function error

What about doing this instead?

To remove the error from occurring.

Changing this:
https://jsitor.com/fH5DO8ZU6L

    function play() {
        player.playVideo();
    }

To this:
https://jsitor.com/3zJoQBIuNi

function play() {
  if (player.playVideo)
    player.playVideo();
}

That’s how I fixed it.
And that error message no-longer appears.

Is that good?

Continuing the discussion from Playing YouTube videos from an array:

I just noticed something, in the solution I thought I came up with, it does remove the error from appearing, but, playVideo is just Inoperable if you click too early.

Using autoplay you don’t have to worry about that, because it always works.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.