AngularJS Youtube player embed very big playlist

2019-04-12 01:13发布

I'm currently building an AngularJS app (I know it's kinda outdated but I'm confident with it so..).

My app need to embed a youtube player that contain a very big playlist (about 1500 items) but I can't code it so that it can embed more than 200 item actually.

I search all over the net and for month to fix that issue but none of what I read seems to work, I litteraly tried everthing I could think of.

Oh by the way I use angular-youtube-embed to make youtube api work with AngularJS.

Here is my code in the controller on how I build up the player

  const home = this;
  var inter = false;
  var playlistArray;
  var playListArrayLength;
  var maxNumber;
  var oldNumber = 0;
  var NewNumber = 0;
  home.playerVars = {
            list: 'LLRmPG23-ao586bxbZFPpvmw',
            rel : "0",
            loop : "1",
            origin : "http://www.youtube.com"
          };
    home.prsAction = function() {
      playlistArray = home.bestPlayer.getPlaylist();
      if (!inter){
          playlistArray = home.bestPlayer.getPlaylist();
          playListArrayLength = playlistArray.length;
          maxNumber = playListArrayLength;
          NewNumber = home.newRandomNumber();
          home.bestPlayer.setShuffle(playlistArray)
          home.bestPlayer.playVideoAt(home.newRandomNumber());
          //home.bestPlayer.playVideo();
        inter = true;
      }else if(inter){
        home.bestPlayer.stopVideo();
        inter = false;
      }
    }
  home.newRandomNumber = function() {
      oldNumber = NewNumber;
      NewNumber = Math.floor(Math.random() * maxNumber);
          return NewNumber;
  }

Some of thoses lines are here to make the player play a random video of the list with a bootstrap collapse effect on the player so don't pay attention to them.

And here is how I call the player in the HTML part

<youtube-video id="player" player-vars="home.playerVars" player="home.bestPlayer" ng-model="home.bestPlayer"></youtube-video>

I really need to make it work so if anyone as some idea don't hesitate.

I can make a plunkr or a fiddle to reproduced the case but since I don't have any error or anything but just a boring limit at 200 items, it's kinda useless.

Thank's in advance. A desperate developer

EDIT : I made a plunker that reproduced my actual problem/state on the player.

https://plnkr.co/edit/vNL0J4M2eR1P3C1IxfZs?p=preview

As you can see on it it load only 197 items in the player (I bieleve it was 199 some times ago but not sure).

As for where from the limit came from : for me it's definitly from the youtube iframe API (since i can't find anything about a limit in the angular-youtube-embed library).

EDIT 2 : In this link provided by google : https://developers.google.com/youtube/youtube_player_demo?hl=fr when I put my playlist ID and try to load it, I have the same issue. I assum that this is definitly comming from youtube API and no solution for it. I'll try to code a workaround solution.

0条回答
登录 后发表回答