Youtube "Blocked a frame with origin "http://www.youtube.com" from accessing a frame with origin" even if the same protocol is used

19,329

Apparently it seems that the error given by chrome is a bug. In order to solve the black screen with 'Play All' button issue I used the Javascript API (instead of the iframe), like this:

<!DOCTYPE html>
<html>
  <body>
    <div id="player"></div>
    <script>
      var tag = document.createElement('script');
      tag.src = "https://www.youtube.com/iframe_api";
      var firstScriptTag = document.getElementsByTagName('script')[0];
      firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
      var player;
      function onYouTubeIframeAPIReady() {
        player = new YT.Player('player', {
          height: '390',
          width: '640',
          videoId: '',
          events: {
            'onReady': onPlayerReady 
          }
        });
      }
      function onPlayerReady(event) {
        player.cuePlaylist({'listType':'playlist','list':'PLE2714DC8F2BA092D'});
      }
    </script>
  </body>
</html>

Thanks to @jlmcdonald for the answer, as indicated here: Youtube embedded playlist diplays playall button instead of the first video

Share:
19,329

Related videos on Youtube

jbx
Author by

jbx

Updated on June 04, 2022

Comments

  • jbx
    jbx almost 2 years

    When embedding a Youtube playlist I am getting this error:

    Blocked a frame with origin "http://www.youtube.com" from accessing a frame with origin "http://www.mydomain.com". Protocols, domains, and ports must match.

    I am not mixing HTTP with HTTPS anywhere, so I don't know why I am getting this error in the first place.

    I have noticed that recently the Youtube embedded playlist is not displaying the embed image of the first video and just displaying a black screen with a 'Play All' button, and I am wondering if this is being caused by the above error.

    • jlmcdonald
      jlmcdonald almost 11 years
      Here's the chromium issue ... code.google.com/p/chromium/issues/detail?id=17325 it's basically a bug in V8 that needs to be fixed so that Chromium can use proper exception handling to deal with this. It's unrelated to anything you might be seeing with embedded playlists (and, in fact, shouldn't really have any negative effects).
    • jbx
      jbx over 10 years
      I changed to use the javascript API instead. It seems that the problem that I was having is some issue introduced with the latest updates to YouTube which effected the iframe embedding. This is not related it seems. Check my other question here: stackoverflow.com/questions/17832807/…
    • scalopus
      scalopus over 10 years
      can you add the script that call to youtube?
    • SashaZd
      SashaZd over 10 years
      @jbx : Add the script you used to solve the problem, and mark the question as answered.