4

I am getting the following error in console shortly after my website loads:

Uncaught TypeError: this.f.isExternalMethodAvailable is not a function

~ Error from file: www-embed-player.js, line number: 669

Which is occurring inside the iframe generated by Youtube so I can't do much about it but wanted to know if this error can be fixed from my end.

I am using following JS code to inject youtube iframe tag in multiple places in DOM

$(this).append('<iframe width="100%" height="100%" src="https://www.youtube.com/embed/' + youtubeVideoID + '?&controls=0&enablejsapi=1&mute=1&theme=dark&autoplay=' + autoPlay + '&autohide=1&modestbranding=0&fs=0&playlist=' + youtubeVideoID + '&showinfo=0&rel=0&iv_load_policy=3&loop=1&playsinline=1" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>');
$(this).parent().find('iframe')[0].contentWindow.postMessage('{"event":"command","func":"playVideo","args":""}', '*');

$(this).parent().find('iframe').eq(0).on('load', function () {
    this.contentWindow.postMessage('{"event":"command","func":"playVideo","args":""}', '*');
});
Mayur
  • 4,345
  • 3
  • 26
  • 40
Imran Bughio
  • 4,811
  • 2
  • 30
  • 53

1 Answers1

2

For anyone finding this via google - I started receiving this error when I enabled the new Permissions-Policy security header on my web site.

Specifically, if the header value contained either of these:

"usb=()" or "payment=()" then the issue appears.

So, removing them seems to have fixed the issue for me.

Veselin Vasilev
  • 3,698
  • 1
  • 15
  • 21