padmatexts:

This commit is contained in:
sanj 2011-01-01 20:36:46 +05:30
parent 1833914788
commit 9019a05ab1
3 changed files with 52 additions and 6 deletions

View File

@ -126,6 +126,18 @@ padmaVideo.prototype.getLayersAtTimecode = function(tc) {
return layers; return layers;
} }
padmaVideo.prototype.getLayerById = function(id) {
var that = this;
var id = $.trim(id);
for (var i=0; i < that.layers.length; i++) {
var thisLayer = that.layers[i];
if (thisLayer.id == id) {
return thisLayer;
}
}
return false;
}
function filterLayersByTracks(layers, tracks) { function filterLayersByTracks(layers, tracks) {
var matchedLayers = [] var matchedLayers = []
for (var i=0; i < layers.length; i++) { for (var i=0; i < layers.length; i++) {

View File

@ -15,17 +15,22 @@
$(this).attr("target", "_blank"); $(this).attr("target", "_blank");
var link = href; var link = href;
if (link.indexOf(PADMA_URL) != -1) { if (link.indexOf(PADMA_URL) != -1) {
$(that).addClass('padmaLink');
var linkData = parsePadmaUrl(link, PADMA_URL); var linkData = parsePadmaUrl(link, PADMA_URL);
if (linkData) { if (linkData && $.inArray(linkData.type, ['info', 'tcRange', 'editor', 'tc', 'layer'])) {
//Don't fetch data twice if video id already exists //Don't fetch data twice if video id already exists
$(that).addClass('padmaLink');
var videoId = linkData.videoId; var videoId = linkData.videoId;
/*
var cacheVideo = padmaVideo.getFromCache(videoId); var cacheVideo = padmaVideo.getFromCache(videoId);
if (cacheVideo) { if (cacheVideo) {
var videoObj = cacheVideo; var videoObj = cacheVideo;
} else { } else {
var videoObj = new padmaVideo(videoId); var videoObj = new padmaVideo(videoId);
} }
*/
var videoObj = new padmaVideo(videoId);
// console.log(linkData); // console.log(linkData);
videoObj.getAllData(setupPadmaLink, {'linkData': linkData, 'jq': that}); videoObj.getAllData(setupPadmaLink, {'linkData': linkData, 'jq': that});

37
test.js
View File

@ -74,10 +74,39 @@ var $padmaQuery = jQuery.noConflict();
sidebarAnimateIn(); sidebarAnimateIn();
} }
padmaContainer.empty(); padmaContainer.empty();
var sidebarWrap = $('<div />').attr("id", "padmaSidebarWrapper").css({'position': 'relative'}).appendTo($container); var sidebarWrap = $('<div />')
var videoElem = $('<video />').addClass('padmaVideo').attr("src", videoObj.getLayerVideo(linkData.tcIn, linkData.tcOut)).attr("autoplay", "autoplay").attr("controls", "controls").appendTo(sidebarWrap).css({'width': '400px'}); .attr("id", "padmaSidebarWrapper")
var annotHeight = $(document).height() - parseInt((videoObj.video.height / videoObj.stream_width) * 400) - 20; .css({'position': 'relative', 'height': '100%'})
var annotations = $('<div />').addClass('annotationText').css({'height': annotHeight + "px", "overflow-y": "auto"}).appendTo(sidebarWrap); .appendTo($container);
var videoElem = $('<video />')
.addClass('padmaVideo')
.attr("src", videoObj.getLayerVideo(linkData.tcIn, linkData.tcOut))
.attr("autoplay", "autoplay")
.attr("controls", "controls")
.appendTo(sidebarWrap)
.css({'width': '400px'});
var annotHeight = $(window).height() - parseInt((videoObj.video.height / videoObj.video.stream_width) * 400) - 20;
var annotations = $('<div />')
.addClass('annotationText')
.css({'height': annotHeight + "px", "overflow-y": "auto"})
.appendTo(sidebarWrap);
var padmaButtons = $('<div />')
.addClass('padmaButtons')
.css({'position': 'absolute', 'bottom': '1px', 'right': '8px', 'color': padmaConfig.color, 'font-size': '12px'})
.appendTo(sidebarWrap);
var padmaUrl = linkData.url;
var padmaLayerBtn = $('<a />')
.addClass('padmaButton')
.text("See on Padma")
.attr("target", "_blank")
.attr("href", padmaUrl)
.css({'text-decoration': 'none', 'color': '#ffff00'})
.appendTo(padmaButtons)
.hover(function() {
$(this).css({'color': padmaConfig.color});
}, function() {
$(this).css({'color': '#ffff00'});
});
var html = getLayersHtml(npt2ms(linkData.tcIn), p.default_layers); var html = getLayersHtml(npt2ms(linkData.tcIn), p.default_layers);
$('.annotationText').html(html); $('.annotationText').html(html);