0

I've embed a Youtube playlist on my website.

Once a video finishes the player doesn't play the next video but skips it and plays the one after. It does it whatever the video. Why is that and how to make it play all videos one after the other ?

Here's my web site with the embed playlist : http://www.centpourcentmonnaie.fr

And here is my code :

<div class="video">
<p>
<span id="gauche" onclick="player.previousVideo()">Chapitre pr&eacute;c&eacute;dent</span>
<span id="droite" onclick="player.nextVideo()">Chapitre suivant</span>
</p>

<div id="player"></div>

<script>
  var tag = document.createElement('script');

  tag.src = "//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: '720',
      width: '1280',
      videoId: '3BuJ4RWy49k',
      events: {
        'onReady': onPlayerReady,
      }
    });
  }

    function onPlayerReady(event) { 
        event.target.cuePlaylist({list: "PLE_-2rZv8j2ro-QgxzK9nvi9O61dgE-Hx",suggestedQuality: "hd720"});
    }
</script>
<br>
</p>
</div>
</div>

The console can read different things in different web browsers.

1 Answer 1

2

I solved my problem with this code using playerVars rather than cuePlaylist:

<script>
  var tag = document.createElement('script');

  tag.src = "//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: '720',
      width: '1280',
      videoId: '3BuJ4RWy49k',
      playerVars: { 'autoplay': 1, 'list':'PLE_-2rZv8j2ro-QgxzK9nvi9O61dgE-Hx'},

    });
  }


</script>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.