Trying to get Shuffle Playlist to work

To expect that to work before the playlist has loaded, is foolish in the extreme.

In this example I’ve checked if the playlist has already been shuffled, which seems to work well.

let hasShuffled = false;
  function onPlayerStateChange(event) {
    ...
    if (!hasShuffled) {
      player.setShuffle(true);
      player.playVideoAt(0);
      hasShuffled = true;
    }
    ...
  }
2 Likes