Search code examples
node.jsyoutube-apipopcornjs

Youtube video in popcorn webmaker is not loading, Infinitely buffering a video


I am getting this error in popcorn webmaker

Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('https://www.youtube.com') does not match the recipient window's origin ('http://localhost:8888').

I am not able to play the you tube videos in chrome. In mozilla and safari it is working fine.

So can anybody help me out in resolving this issue.

This is the code of my iframe. I am using the latest api of youtube that is:

https://www.youtube.com/iframe_api

My Iframe code is below:-

<iframe frameborder="0" allowfullscreen="1" title="YouTube video player" width="100%" height="100%" src="https://www.youtube.com/embed/0Fegb4Ew8SM?butteruid=1437727498131&amp;rel=0&amp;modestbranding=1&amp;iv_load_policy=3&amp;disablekb=1&amp;showinfo=0&amp;origin=http%3A%2F%2Flocalhost%3A8888&amp;controls=0&amp;wmode=opaque&amp;html5=1&amp;enablejsapi=1" id="widget4"></iframe>

The video load for 1 or 2 seconds then It goes to an infinite waiting state.

Fore more details you can visit: 54.186.240.149:8888

Please check in chrome.


Solution

  • Thats the solution:-

    // This function needs duration and first play to be ready.
    function onFirstPlay() {
      removeYouTubeEvent( "play", onFirstPlay );
      if ( player.getCurrentTime() === 0 ) {
        setTimeout( onFirstPlay, 0 );
        return;
      }
      addYouTubeEvent( "pause", onFirstPause );
      player.pauseVideo();
      player.seekTo( 0 );
    }
    

    It was initially

    // This function needs duration and first play to be ready.
    function onFirstPlay() {
      removeYouTubeEvent( "play", onFirstPlay );
      if ( player.getCurrentTime() === 0 ) {
        setTimeout( onFirstPlay, 0 );
        return;
      }
      addYouTubeEvent( "pause", onFirstPause );
      player.seekTo( 0 );
      player.pauseVideo();
    }