jquery - YouTube Playlist Pagination -
i trying pull videos youtube playlist jquery , display them kind of pagination or perhaps next/prev links.
based on code found here have figured out how pull first group of videos. can see working here on jsfiddle
function loadvids(startindex){ if (typeof startindex === "undefined" || startindex===null) startindex = 1; var maxresults = 25; var playlisturl = 'http://gdata.youtube.com/feeds/api/playlists/pl3b8939169e1256c0?orderby=published&v=2&alt=json&&start-index=' + startindex + '&max-results=' + maxresults; var videourl= 'http://www.youtube.com/watch?v='; $.getjson(playlisturl, function(data) { var list_data=""; $.each(data.feed.entry, function(i, item) { var feedtitle = item.title.$t; var feedurl = item.link[1].href; var fragments = feedurl.split("/"); var videoid = fragments[fragments.length - 2]; var vid = item.media$group.yt$videoid.$t; var url = videourl + videoid; var vidtitle = item.title.$t; var thumb = "http://img.youtube.com/vi/"+ videoid +"/default.jpg"; list_data += '<li><a href="'+ url +'" title="'+ feedtitle +'"><img alt="'+ feedtitle+'" src="'+ thumb +'"</a>' + ' - ' + vidtitle + '</li>'; }); $(list_data).appendto(".cont"); }); } // $( document ).ready(function() { loadvids(1); // call on load more click });
after i'm stuck. know can pull next , previous links feed , can max number of videos , maybe use generate pagination, i'm not sure them. found this example, uses php similar; jquery if it's possible. i'm rather new jquery , json why i'm not sure go here.
Comments
Post a Comment