Encountering an error when using the YouTube Iframe API on Safari 9.1, OS X Yosemite
Issue: Unable to post message to http://www.youtube.com. Recipient has origin https://www.youtube.com
This problem only occurs in Safari, as other browsers like Firefox and Chrome work fine. Additionally, it seems to be specific to one machine while another with the same OS and browser works correctly.
The troubleshooting process is unclear at this point.
The iframe HTML code being generated is:
<iframe id="myVideo" frameborder="0" allowfullscreen="1" title="YouTube video player" width="200" height="200" src="http://www.youtube.com/embed/?html5=1&showinfo=0&autoplay=0&rel=0&controls=1&playsinline=1&enablejsapi=1&origin=http%3A%2F%2Fwww.example.com"></iframe>
And the JavaScript code is as follows:
...
vid_frame = new YT.Player(id, {
height: '200',
width: '200',
videoId: id,
playerVars: {
html5: 1,
showinfo: showVideoInfo,
autoplay: 0,
rel: showRelatedVideos,
controls: showPlayerControls,
playsinline: 1
},
events: {
onReady: onPlayerReady
}
});
The error indicates a potential browser setting blocking communication between the website and YouTube API due to the discrepancy in URLs (http vs. https).
Manually changing http to https in iframe URLs results in warnings about untrusted origins if the main website is served over http.
Looking for solutions and further guidance, referencing a related question on Stack Overflow: Unable to post message to http://www.youtube.com. Recipient has origin https://www.youtube.com
Any suggestions on where to start debugging this issue?