Play YouTube playlist randomly

OK... been working on this for a couple of months with no working results as of yet... So, now asking for help! I have a YouTube playlist, ID: PLl_KM23gznEAZW-INW8ty4QNaHH8JCnNW. This playlist has close to 1500 videos on it. I am needing a code that will call the list, and play a random video from the list. and I need it to play all 1500 videos in a random order without repeating any of the videos. then after the playlist is completed, it needs to start over, continuing to play the videos in a completely different random order.

I have tried several code snippets and can't seem to get it all to come together. I either get a shuffle with repeats, or I get just a list that doesn't play anything, or it will randomly pick the first video, then maybe the second one, but it will start playing in order from either the first or the second video. And the current youtube player that is working will only call the videos in a 200 song list. IE: if the payer starts in order, only will play 1 through 200, then stop. Or, I can set it to start with any song in the playlist, for instance, # 999, it will go to that video, but will only play videos fromm 999 to 1198.

I have to randomly pick the song and put it in my code to get it to do that.

I need it to start in shuffle mode, choosing any song from the list of 1500 videos, then continue randomly choosing and playing any other video within the list except those that have already played, until it has played all the videos, then loop the playlist and continuing to play a random video from the playlist in no certain order, including the order it just played. My main thing to avoid... having to create the list array manually. I need to be able to call the url of the playlist, and retrieve a list of the videos either by number, video ID, name of the song, etc. Using the easiest, cleanest code.

PS: having comments in place is extremely helpful for my learning process.

And please don't worry about anything, I am 51, disabled, and trying to remind myself of the coding syntaxes after getting a degree in 2003 and not using a bit of it since! I am working on a project for myself, more or less trying to get myself back into being able to read, repair, and create coding for myself. This part though, has me totally stumped!

I hope this is making sense to someone, I'm getting confused just trying to ask the question!!!

tried this one, got nothing... just a blank page...

var tag = document.createElement('script'); tag.src = "https://www.youtube.com/iframe_api"; var firstScriptTag = document.getElementsByTagName('script')[0]; firstScriptTag.parentNode.insertBefore(tag, firstScriptTag); function onYouTubeIframeAPIReady() { var player = new YT.Player("player", { height: '390', width: '640', events: { 'onReady': function (event) { event.target.cuePlaylist({list: "PLl_KM23gznEAZW-INW8ty4QNaHH8JCnNW"}); event.target.playVideo(); setTimeout(function() { event.target.setShuffle({'shufflePlaylist' : true}); }, 1000); } } }); }

this one will load the player, but doesn't shuffle or play randomly. just starts with the first video, then continues in order...

var tag = document.createElement('script'); tag.src = "https://www.youtube.com/iframe_api"; var firstScriptTag = document.getElementsByTagName('script')[0]; firstScriptTag.parentNode.insertBefore(tag, firstScriptTag); var player; function onYouTubeIframeAPIReady() { player = new YT.Player('player', { height: '390', width: '640', events: { 'onReady': onPlayerReady }, playerVars: { listType:'playlist', list: 'PLl_KM23gznEAZW-INW8ty4QNaHH8JCnNW' } }); } function onPlayerReady(event) { num = _.random(0, 1500); setTimeout(() => { player.playVideoAt(num); }, 1000); }

this one will start with a random video, but then continues in order from there...

var tag = document.createElement('script'); tag.src = "https://www.youtube.com/iframe_api"; var firstScriptTag = document.getElementsByTagName('script')[0]; firstScriptTag.parentNode.insertBefore(tag, firstScriptTag); function onYouTubeIframeAPIReady() { var numPl = Math.floor((Math.random() * 1500) + 1); var player = new YT.Player("player", { height: '390', width: '640', playerVars: { listType:'playlist', list:'PLl_KM23gznEAZW-INW8ty4QNaHH8JCnNW', index: numPl, autoplay: 1, }, events: { 'onReady': function (event) { event.target.cuePlaylist({list: "PLl_KM23gznEAZW-INW8ty4QNaHH8JCnNW"}); event.target.playVideo(); setTimeout(function() { event.target.setShuffle({'shufflePlaylist' : true}); }, 1000); } } }); } function onPlayerReady(event) { event.target.mute(); setTimeout( function() { event.target.setShuffle(true); event.target.setLoop(true); }, 2000); } function getRandomId() { var random_id = 0 while(played_idx.indexOf(random_id) != -1) { random_id = Math.floor(Math.random * playlist.length) } return random_id }

I'm pretty sure there were more, but can't find them at the moment.