Skip to content

Conversation

@qubird
Copy link

@qubird qubird commented Apr 18, 2015

Fix for #46.
Instead of creating a new player, use the current one when it's already existing, loading the new video via YT method loadVideoById

Fix for brandly#46.
Instead of creating a new player, use the current one when it's already existing, loading the new video via YT method loadVideoById
@jarethgk
Copy link

jarethgk commented May 1, 2015

I have experienced this same problem. I didn't know what scope.player.d was, but I didn't want to remove that code in case it was doing something. So I decided that when the player was created I would fill it with something that would allow the check to destroy it in the even that it never gets overwritten or filled with something else.

I added this:

           // I don't know why, but in some cases player.d is missing.
           // It is needed in case it needs to be destroyed.
           //So if it is not there, then I just arbitrarily set it to true.
           if (player.d) {
              console.log("YouTube player.d exists in this object: ");
              console.log(player);
           } else {
              player.d = true;
           }

x Jeremy M.

Directive portion in the function: createPlayer
fix for this where I added:

       function createPlayer () {
           var playerVars = angular.copy(scope.playerVars);
           playerVars.start = playerVars.start || scope.urlStartTime;
           var player = new YT.Player(playerId, {
               height: scope.playerHeight,
               width: scope.playerWidth,
               videoId: scope.videoId,
               playerVars: playerVars,
               events: {
                   onReady: onPlayerReady,
                   onStateChange: onPlayerStateChange
               }
           });

           player.id = playerId;

           // I don't know why, but in some cases player.d is missing.
           // It is needed in case it needs to be destroyed.
           //So if it is not there, then I just arbitrarily set it to true.
           if (player.d) {
              console.log("YouTube player.d exists in this object: ");
              console.log(player);
           } else {
              player.d = true;
           }

           return player;
       }

P.S. - I am sorry is this is a newbie way to respond, but I just signed into git hub in order to post this, and so I am indeed a newbie. Hope this helps.

alexthewilde added a commit to alexthewilde/angular-youtube-embed that referenced this pull request Jul 16, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants