Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Youtube iframe API fails to post message

For awhile now, a piece of javascript I wrote which listens to youtube actions on a certain page worked wonderfully. I am using Youtube's iframe js api: https://developers.google.com/youtube/iframe_api_reference . But one recent content addition, a specific youtube video, the tracking wouldn't work. The events won't fire at all.

In the console, I noticed this post message error: Unable to post message to http://youtube.com. Recipient has origin http://www.youtube.com.

So nothing with my own code helped. Some questions here on stackoverflow suggested this is an issue with initiating new YT.player too soon, so I tried a whole bunch of things like loading the yt js api file on window load and only apply the api after, but that didn't seem to do any good either.

like image 555
ido Avatar asked Apr 17 '13 01:04

ido


1 Answers

I know this post is 3 years old, but for those who are still searching for an answer:

Add this script and everything works fine:

<script src="https://www.youtube.com/iframe_api"></script>

I've had the same problem with jwplayer and fixed it with that script.

like image 117
Peppeneppe Avatar answered Sep 20 '22 14:09

Peppeneppe