List You Tube Playlist videos with jquery

I need to list all of the videos in a You Tube playlist. I need a sample code that will loop through all the videos.
garyilmAsked:
Who is Participating?
 
JonNormanConnect With a Mentor Commented:
how about:
$(document).ready(function() {
    //playlist : https://www.youtube.com/playlist?list=PLA9A0A8CB8B21E3E6
    var playlist = "A9A0A8CB8B21E3E6";
    var playListURL = 'http://gdata.youtube.com/feeds/api/playlists/'+playlist+'?v=2&alt=json&callback=?';
    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 url = videoURL + videoID;
            var thumb = "http://img.youtube.com/vi/" + videoID + "/default.jpg";
            list_data += '<li><a href="' + url + '" title="' + feedTitle + '"><img alt="' + feedTitle + '" src="' + thumb + '"</a></li>';
        });
        $(list_data).appendTo("ul");
    });
});

Open in new window

http://jsfiddle.net/JonNorman/xMJqb/
0
 
garyilmAuthor Commented:
Perfect.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.