46 lines
1.4 KiB
JavaScript
46 lines
1.4 KiB
JavaScript
|
|
function setupVideo(v) {
|
|
var vidInterval = 0;
|
|
var vidSrc = v.video.urls['320'];
|
|
$('#videoPlayer').attr("src", vidSrc).attr("poster", v.getPoster()).get(0).load();
|
|
$('#videoTitle').text(v.video.title);
|
|
$('#videoPlayer').bind("play", function() {
|
|
var $this = $(this);
|
|
clearInterval(vidInterval);
|
|
vidInterval = setInterval(function() {
|
|
var tc = $this.get(0).currentTime;
|
|
var tcMs = parseInt(tc * 1000);
|
|
var currentLayers = v.getLayersAtTimecode(tcMs);
|
|
var annotHtml = getAnnotHtml(currentLayers);
|
|
if (annotHtml == $('#videoAnnotations').html()) {
|
|
$.noop();
|
|
} else {
|
|
$('#videoAnnotations').html(annotHtml);
|
|
}
|
|
// console.log(tc);
|
|
}, 400);
|
|
});
|
|
|
|
$('#videoPlayer').bind("pause", function() {
|
|
clearInterval(vidInterval);
|
|
});
|
|
}
|
|
|
|
function getAnnotHtml(padmaLayers) {
|
|
var html = '';
|
|
var types = ['location', 'keyword', 'description', 'transcript'];
|
|
for (var i=0; i<types.length; i++) {
|
|
var t = types[i];
|
|
html += "<div class='" + t + "'>";
|
|
var theseLayers = filterLayersByTracks(padmaLayers, [t]);
|
|
for (var j=0; j<theseLayers.length; j++) {
|
|
html += "<div class='annotItem'>";
|
|
html += theseLayers[j].value_html;
|
|
html += "</div>";
|
|
}
|
|
html += "</div>";
|
|
}
|
|
return html;
|
|
}
|
|
|