Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 1 of 1
  1. #1
    Senior Member RDesignista's Avatar
    Join Date
    Feb 2012
    Location
    Coconut Tree City
    Posts
    822
    Member #
    30921
    Liked
    123 times
    Hi,

    I'm trying to learn how to setup a youtube feed on a website. There doesn't seem to be a lot of plugins for this, but I found something that's pretty cool. The only problem is that it can only return the address of the youtube video, and not the video url itself. I need the video url because I want to use my Shadowbox (Lightbox's cousin) for users to view the videos. You can see how Youtube videos can be set up with Shadowbox here.

    And here is the javascript I am working with to fetch data:

    /**
    * Plugin which renders the YouTube channel videos list to the page
    * @author: H. Yankov (hristo.yankov at gmail dot com)
    * @version: 1.0.0 (Nov/27/2009)
    * http://yankov.us
    *
    * Modified my Dan Hounshell (Jan/2010) to work for favorites or
    * uploads feeds and simplified output
    */

    var __mainDiv;
    var __preLoaderHTML;
    var __opts;

    function __jQueryYouTubeChannelReceiveData(data) {

    var cnt = 0;

    $.each(data.feed.entry, function(i, e) {
    if (cnt < __opts.numberToDisplay) {
    var parts = e.id.$t.split('/');
    var videoId = parts[parts.length-1];
    var out = '<div class="video"><a href="' +
    e.link[0].href + '" rel=lightbox[1]><img src="http://i.ytimg.com/vi/' +
    videoId + '/2.jpg"/></a><br /><a href="' +
    e.link[0].href + '" rel=lightbox[1]>' + e.title.$t + '</a><p>';
    if (!__opts.hideAuthor) {
    out = out + 'Author: ' + e.author[0].name.$t + '';
    }
    out = out + '</p></div>';
    __mainDiv.append(out);
    cnt = cnt + 1;
    }
    });

    // Open in new tab?
    if (__opts.linksInNewWindow) {
    $(__mainDiv).find("li > a").attr("target", "_blank");
    }

    // Remove the preloader and show the content
    $(__preLoaderHTML).remove();
    __mainDiv.show();
    }

    (function($) {
    $.fn.youTubeChannel = function(options) {
    var videoDiv = $(this);

    $.fn.youTubeChannel.defaults = {
    userName: null,
    channel: "favorites", //options are favorites or uploads
    loadingText: "Loading...",
    numberToDisplay: 3,
    linksInNewWindow: true,
    hideAuthor: false
    }

    __opts = $.extend({}, $.fn.youTubeChannel.defaults, options);

    return this.each(function() {
    if (__opts.userName != null) {
    videoDiv.append("<div id=\"channel_div\"></div>");
    __mainDiv = $("#channel_div");
    __mainDiv.hide();

    __preLoaderHTML = $("<p class=\"loader\">" +
    __opts.loadingText + "</p>");
    videoDiv.append(__preLoaderHTML);

    // TODO: Error handling!
    $.ajax({
    url: "http://gdata.youtube.com/feeds/base/users/" +
    __opts.userName + "/" + __opts.channel + "?alt=json",
    cache: true,
    dataType: 'jsonp',
    success: __jQueryYouTubeChannelReceiveData
    });
    }
    });
    };
    })(jQuery);

  2.  


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 06:57 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com