Mindsect Team
Mindsect Team

Reputation: 2581

Still Possible to set Shuffle Settings on Iframe Embed Code?

I am deciding whether or not I should use the full YouTube API (registering for an API key, calling the YouTube JS and building the player from scratch) or if I should just register for an YouTube account, build a playlist and load this playlist on a client's website as is (using the iframe embed code, seen below):

  <iframe width="100%" height="315" 
  src="https://www.youtube.com/embed/videoseries?list=XXXXXXX
  &autoplay=1&rel=0&loop=1&shuffle=1" frameborder="0" allowfullscreen>
  </iframe>

The embed code is easy enough, but from viewing earlier videos on YouTube Playlist settings, YouTube has removed quite a bit of functionality from basic playlist settings (autoplay, shuffling videos on play, start/stop times of each video in playlist, etc.)

I would imagine the switch for shuffle should be as easy as "&shuffle=1" or something like that. I'm not sure why YouTube makes it so difficult to comprehend new settings after having removed such a powerful feature from such a simple embed code.

Any ideas?

Upvotes: 2

Views: 7381

Answers (2)

Agent Exodus
Agent Exodus

Reputation: 46

Here's an actual solution:

  function onPlayerReady(event) {
    event.target.playVideo();
    setTimeout(setShuffleFunction, 1000);           
  }
  function setShuffleFunction(){
    player.setShuffle(true);
  }

You have to use javascript to load the player.setShuffle(true) event, just after the first video starts (solution given here: YouTube API playlist shuffle). I didn't create it but I tried it and it worked for me too. I went two years thinking the feature was deprecated and no longer possible with embedded playlists. Seeing as this is the primary response when you google this issue, figured I'd help out.

Upvotes: 3

johnh10
johnh10

Reputation: 4185

You can find all the embed parameters YouTube supports here.

Upvotes: 2

Related Questions