[Webinar] Learn how to a build a cloud-first strategyRegister Now


List You Tube Playlist videos with jquery

Posted on 2012-08-16
Medium Priority
Last Modified: 2012-08-29
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.
Question by:garyilm
LVL 13

Accepted Solution

JonNorman earned 2000 total points
ID: 38300914
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>';

Open in new window


Author Closing Comment

ID: 38345087

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer…
PROBLEM: The other day I was working on adding an ajax request to a webpage that already had a dialog box on the page.  The dialog box was using relative positioning to be positioned next to a form field I had on the page.  Everything was working…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses
Course of the Month20 days, 12 hours left to enroll

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question