var player;
var users;

var onYouTubeIframeAPIReady = function() {
  player = new YT.Player('player', {
    height: '390',
    width: '640',
    playerVars: {'rel': 0},
    events: {
      'onReady': onPlayerReady,
      'onStateChange': onPlayerStateChange
    }
  });
};

var onPlayerReady = function(event) {
  getUsers();
};

var onPlayerStateChange = function(event) {
  if (event.data == YT.PlayerState.ENDED) {
    loadVideo();
  }
};

var getUsers = function() {
  $.ajax({
    url: 'users.json',
    dataType: 'json',
    success: function(data) {
      users = data;
      loadVideo();
    },
    error: function(xhr) {
      console.log('Error: ' + xhr.status + ' ' + xhr.statusText);
      setTimeout(function() {
        console.log('Retry...');
        getUsers();
      }, 5000);
    }
  });
};

var loadVideo = function() {
  user = shuffle(users)[0];
  $.ajax({
    url: uploadsUrl(user['youtube']),
    dataType: 'xml',
    success: function(data) {
      var url = shuffle(parseVideo(data))[0];
      player.loadVideoByUrl(url);
    },
    error: function(xhr) {
      console.log('Error: ' + xhr.status + ' ' + xhr.statusText);
      setTimeout(function() {
        console.log('Retry...');
        loadVideo();
      }, 5000);
    }
  });
};

var uploadsUrl = function(username) {
  return 'http://gdata.youtube.com/feeds/api/users/' + username + '/uploads'
};

var parseVideo = function(xml) {
  // Or 'content[yt\\:format=5]'
  return $(xml).find('content').map(function() {
    if ($(this).attr('yt:format') == 5) {
      return $(this).attr('url');
    }
  });
};

var shuffle = function(array) {
  // Fisher–Yates Shuffle
  // http://bost.ocks.org/mike/shuffle/
  var m = array.length, t, i;
  while (m) {
    i = Math.floor(Math.random() * m--);
    t = array[m];
    array[m] = array[i];
    array[i] = t;
  }
  return array;
};

@@ -305,16 +305,56 @@
 vent) %7B%0A
+  console.log('YouTube Player ready.');%0A
   getUse
@@ -359,16 +359,16 @@
 sers();%0A
-
 %7D;%0A%0Avar 
@@ -447,24 +447,71 @@
 te.ENDED) %7B%0A
+    console.log('Play ended. Go next video.');%0A
     loadVide
@@ -551,16 +551,56 @@
 ion() %7B%0A
+  console.log('Loading users list...');%0A
   $.ajax
@@ -673,24 +673,52 @@
 ion(data) %7B%0A
+      console.log('Done.');%0A
       users 
@@ -1016,16 +1016,107 @@
 rs)%5B0%5D;%0A
+  console.log('Selected user: ' + user%5B'name'%5D);%0A  console.log('Loading uploads list...');%0A
   $.ajax
@@ -1203,24 +1203,52 @@
 ion(data) %7B%0A
+      console.log('Done.');%0A
       var ur
@@ -1281,16 +1281,110 @@
 a))%5B0%5D;%0A
+      console.log('Selected video: ' + url);%0A      console.log('Loading video... =%3E ' + url);%0A
       pl

Add console.log