function getRandom(num){
var my_num = Math.floor(Math.random()*num);
return my_num;
}
var ids =[];
function randomVideo(){
var randomID = getRandom(ids.length);
var src = 'https://player.vimeo.com/video/'+ ids[randomID] +'?api=1&player_id=player1';
$('#player1').attr('src', src);
}
$(function() {
var iframe = $('#player1')[0];
var player = $f(iframe);
// When the player is ready, add listeners for pause, finish, and playProgress
player.addEvent('ready', function() {
player.addEvent('finish', onFinish);
player.api("play");
});
function onFinish(id) {
randomVideo();
}
});
$.getJSON('https://vimeo.com/api/v2/user1666688/all_videos.json', function(data) {
$.each(data, function(index, el) {
id = el.id;
ids.push(id)
});
randomVideo();
});