/* jqIzeYoutubeVideoInfo - (c) 2010 Emil Müller http://ize.webhop.net/home/jquery-plugins/jqizeyoutubeplayer Released under the GPL License http://www.gnu.org/licenses/gpl-3.0.txt requires: - jQuery 1.4.x */ (function ($) { $.fn.IzeYoutubeVideoInfo = function (settings) { var timer; var config = { width: '640px', height: '90px' }; if (settings) $.extend(config, settings); init = function (el) { setupMainContainer(el); } setupMainContainer = function (el) { $(el).css({ width: config.width, height: config.height }); } showVideoInfo = function (el, info) { clearTimeout(timer); $(el).hide(); $(el).empty(); $(el).append($("
").addClass("thumbnail").css({ width: '120px', height: '70px', background: "url('" + info.media$group.media$thumbnail[0].url + "') no-repeat center center" })); $(el).append($("").addClass("title").text(info.title.$t)); $(el).append($("").addClass("description").text(info.media$group.media$description.$t)); $(el).append($("").addClass("duration").addClass("duration").text(secondsToString(info.media$group.yt$duration.seconds))); $(el).fadeIn(); timer = setTimeout(function () { $(el).fadeOut(); }, 7000); } secondsToString = function (seconds) { var hours = Math.floor(parseInt(seconds) / (60 * 60)); var minutes = Math.floor((parseInt(seconds) - (hours * 60 * 60)) / 60); seconds = parseInt(seconds) - (hours * 60 * 60) - (minutes * 60); if (minutes < 10) minutes = "0" + minutes; if (seconds < 10) seconds = "0" + seconds; if (hours > 0) return hours + ":" + minutes + ":" + seconds; else return minutes + ":" + seconds; } this.show = function (info) { showVideoInfo($(this), info); } this.each(function () { //setup element init(this); }); //put instance of this object in data $(this).data("ytcontrols", this); return this; }; })(jQuery);