Vimeo API Demo
This is a basic demo of using Vimeo API to get information of a video using video URL or just the ID of the video
HTML
<input id="embed" type="text" value="http://vimeo.com/7100569" />
<input type="button" id="loadEmbed" value="load video info"/>
<div id="myuploads">
List of videos :<br/>
</div>
<div id="player" >
</div>
<div id="embedworkspace">
</div>
<div class="template" style="display:none;">
<div>Title: <label class="videotitle"></label></div>
<div>Author:<label class="videoauthor"></label></div><br/>
<div>Description:<label class="videodesc"></label></div><br/>
<b>Click on the ThumbNail to load the player.</b>
<div class="videothumbnail"></div>
<div class="videouserProfile"></div>
<div class="stat">Likes:<span class="likes"></span> Comments:<span class="comments">/<span> Views:<span class="views"></span></div>
</div>
JavaScript
$(function() {
$('#loadEmbed').click(function() {
var embedUrl = $('#embed').val();
var isObjectEmbed = (embedUrl.indexOf('object') != -1 || embedUrl.indexOf('inframe') != -1);
var url = '';
if (isObjectEmbed) {
var isOldEmbedCode = (embedUrl.indexOf('object') != -1);
$('#embedworkspace').html(embedUrl);
if (isOldEmbedCode) {
var link = $('#embedworkspace').find('object').siblings('p').find('a[href^="http"]').first();
url = link.attr('href');
} else {
var iFrame = $('#embedworkspace').find('iframe').first();
if (iFrame) {
url = iFrame.attr('src');
}
}
$('#embedworkspace').html('');
} else {
url = embedUrl;
}
if (url == null || url == '') {
alert('error in url');
return;
}
$.ajax({
url: 'http://www.vimeo.com/api/v2/video/7100569.json?callback=?',
type: 'POST',
cache: false,
dataType: 'json',
data: {
url: url
},
success: function(data) {
loadVimeoVideo(data, 'http://vimeo.com/api/oembed.json?url=' + url + '&callback=?')
}
});
});
});
//the script here is kinda of overengineered, as i ripped it from a working project of mine.
function loadVimeoVideo(data, playerUrl) {
var video = GetJson(data)[0];
if (!video || video == '') {
$.Flash('error', 'The video could not be loaded. Please check the URL and the permissions, only Public videos can be added.');
return;
}
var title = video.title;
var url = video.url;
var videoId = video.id;
var description = video.description;
var thumbnailSmall = video.thumbnail_small;
var thumbNailLarge = video.thumbnail_large;
var thumbNailMedium =...