6
I have a div <div class="player"></div>
and inside it, I want the last video posted on a channel to always appear.
I have this structure in jQuery, but I can’t get it to pull only 1. Follow the structure:
$(function() {
// Baixar URLs do feed do canal
$.get('http://gdata.youtube.com/feeds/api/users/Rodrigoaraujooficial/uploads?max-results=10&alt=json', function(result) {
var entries = result.feed.entry;
for(var i=0; i<entries.length; i++) {
var url = entries[i].link[0].href;
// Transformar URL de vídeo em URL de embed
// ANTES: http://www.youtube.com/watch?v=aDqExWjK49Y&algumacoisaaqui
// DEPOIS: http://www.youtube.com/embed/aDqExWjK49Y
url = url.replace('/watch?v=', '/embed/');
url = url.substring(0, url.indexOf('&'));
// Fazer append dos vídeos
$('.player').append('<iframe width="480" height="270" src="' + url + '" frameborder="0" allowfullscreen></iframe>');
}
});
});
How to solve this problem?
Oh man, thank you so much! It worked out here!
– Julio Rodrigues
You’re welcome. Good luck with the code!
– Thomas
In case to be another channel I have to change only after users/ID_DO_CANAL ? And in mine here gave an error 410 (Gone).
– Sr. Bigode