Fin de playlist

This commit is contained in:
Klafyvel 2018-03-25 18:18:41 +02:00
parent 5c30be2c65
commit 227b161de0

View file

@ -56,8 +56,6 @@ function onYouTubeIframeAPIReady() {
// 4. The API will call this function when the video player is ready. // 4. The API will call this function when the video player is ready.
function onPlayerReady(event) { function onPlayerReady(event) {
console.log(current_link);
console.log(tracks.length);
if(tracks.length > 0 && current_link < (tracks.length - 1)) { if(tracks.length > 0 && current_link < (tracks.length - 1)) {
current_link += 1 current_link += 1
player.loadVideoById(tracks[current_link]); player.loadVideoById(tracks[current_link]);
@ -92,6 +90,7 @@ function updateLinks(data) {
links.removeChild(links.firstChild); links.removeChild(links.firstChild);
} }
var model = document.getElementById('link_template'); var model = document.getElementById('link_template');
var rerun = (current_link >= tracks.length ) || current_link < 0;
tracks = []; tracks = [];
for (var i=0; i<data.length; i++) for (var i=0; i<data.length; i++)
{ {
@ -103,7 +102,7 @@ function updateLinks(data) {
links.appendChild(card); links.appendChild(card);
links.append(document.createElement('br')); links.append(document.createElement('br'));
} }
if (current_link < 0) { if (rerun) {
onPlayerReady(); onPlayerReady();
} }
} }