From 5b75ceffc0490d0b8a81e2264ef96158f4319322 Mon Sep 17 00:00:00 2001 From: Sanj Date: Mon, 14 Mar 2011 06:34:27 +0530 Subject: [PATCH] handle annot previews, gracefully --- padmaTexts/static/js/views/sidebar.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/padmaTexts/static/js/views/sidebar.js b/padmaTexts/static/js/views/sidebar.js index bd5bce3..d514172 100644 --- a/padmaTexts/static/js/views/sidebar.js +++ b/padmaTexts/static/js/views/sidebar.js @@ -108,8 +108,10 @@ function setupPadmaLink(videoObj, data) { var annotHeight = $(window).height() - 340; $('.annotationText').css({'height': annotHeight + "px"}); var videoElem = $('video'); + var in_ms = npt2ms(linkData.tcIn); + $('.annotationText').html(getLayersHtml(in_ms, padmaConfig.default_layers)); videoElem.bind("loadedmetadata", function() { - $(this).get(0).currentTime = parseInt(npt2ms(linkData.tcIn) / 1000); + $(this).get(0).currentTime = parseInt(in_ms / 1000); $(this).get(0).play(); }); videoElem.bind("play", function() { @@ -117,6 +119,9 @@ function setupPadmaLink(videoObj, data) { var displayLayers = padmaConfig.default_layers; videoObj.interval = setInterval(function() { var currentTime = parseInt(that.currentTime * 1000); + if (currentTime == 0) { return; } //Browser seems to return 0 as current time somewhere in between loadedmetadata, setting currentTime, and the play callback - this is a slightly silly hack - #FIXME. + +// console.log(currentTime); if (currentTime > npt2ms(linkData.tcOut)) { videoElem.get(0).pause(); videoElem.trigger("ended");