jQuery.YoutubeBackground icon indicating copy to clipboard operation
jQuery.YoutubeBackground copied to clipboard

window.YT.Player is not a constructor

Open joker-777 opened this issue 8 years ago • 1 comments

Happens here which is called here. It mostly happens on windows.

joker-777 avatar Sep 29 '16 13:09 joker-777

You can change ifameIsReady to something like this for the time being:

iframeIsReady = function iframeIsReady(callback) {
      // Listen for Gobal YT player callback
      if (typeof YT === 'undefined' && typeof window.loadingPlayer === 'undefined') {
        // Prevents Ready Event from being called twice
        window.loadingPlayer = true;

        
        // Creates deferred so, other players know when to wait.
        window.dfd = $.Deferred();
        window.onYouTubeIframeAPIReady = function() {
          window.onYouTubeIframeAPIReady = null;
          window.dfd.resolve( "done" );
          callback();
        };
      } else if (typeof YT === 'object')  {
        if(typeof YT.Player !== 'undefined'){
          callback();
        } else{
          window.dfd = $.Deferred();
          window.onYouTubeIframeAPIReady = function() {
            window.onYouTubeIframeAPIReady = null;
            window.dfd.resolve( "done" );
            callback();
          };
        }
        
      } else {
        window.dfd.done(function( name ) {
          callback();
        });
      }
    };

viperfx07 avatar Dec 12 '16 04:12 viperfx07