Merge pull request #373 from pedrobmarin/adjust-playback-to-old-recordings

Adjusting playback to work with old recordings
This commit is contained in:
Pedro Beschorner Marin 2017-02-15 11:16:04 -02:00 committed by GitHub
commit f6ee9b281f
2 changed files with 68 additions and 50 deletions

View File

@ -118,22 +118,30 @@ function removeSlideChangeAttribute() {
function mustShowDesktopVideo(time) { function mustShowDesktopVideo(time) {
var canShow = false; var canShow = false;
for (var m = 0; m < deskshareTimes.length; m++) { if (isThereDeskshareVideo()) {
var start_timestamp = deskshareTimes[m][0]; for (var m = 0; m < deskshareTimes.length; m++) {
var stop_timestamp = deskshareTimes[m][1]; var start_timestamp = deskshareTimes[m][0];
var stop_timestamp = deskshareTimes[m][1];
if(time >= start_timestamp && time <= stop_timestamp) if(time >= start_timestamp && time <= stop_timestamp)
canShow = true; canShow = true;
}
} }
return canShow; return canShow;
} }
function isThereDeskshareVideo() { function isThereDeskshareVideo() {
return deskshareTimes.length > 0; var deskshareVideo = document.getElementById("deskshare-video");
if (deskshareVideo != null) {
return true;
} else {
return false;
}
} }
function resyncVideos() { function resyncVideos() {
if (!isThereDeskshareVideo()) return;
var currentTime = Popcorn('#video').currentTime(); var currentTime = Popcorn('#video').currentTime();
var currentDeskshareVideoTime = Popcorn("#deskshare-video").currentTime(); var currentDeskshareVideoTime = Popcorn("#deskshare-video").currentTime();
if (Math.abs(currentTime - currentDeskshareVideoTime) >= 0.1) if (Math.abs(currentTime - currentDeskshareVideoTime) >= 0.1)
@ -158,10 +166,8 @@ function handlePresentationAreaContent(time) {
sharingDesktop = false; sharingDesktop = false;
} }
if(isThereDeskshareVideo()) { resyncVideos();
resyncVideos(); resizeDeshareVideo();
resizeDeshareVideo();
}
} }
// - - - END OF JAVASCRIPT FUNCTIONS - - - // // - - - END OF JAVASCRIPT FUNCTIONS - - - //
@ -626,13 +632,18 @@ document.addEventListener('media-ready', function(event) {
if ((audioReady || videoReady) && deskshareReady && svgReady) { if ((audioReady || videoReady) && deskshareReady && svgReady) {
runPopcorn(); runPopcorn();
generateThumbnails(); if (firstLoad) initPopcorn();
var p = Popcorn("#video");
p.currentTime(defineStartTime());
} }
}, false); }, false);
function initPopcorn() {
firstLoad = false;
generateThumbnails();
var p = Popcorn("#video");
p.currentTime(defineStartTime());
}
svgobj.addEventListener('load', function() { svgobj.addEventListener('load', function() {
console.log("got svgobj 'load' event"); console.log("got svgobj 'load' event");
document.dispatchEvent(new CustomEvent('media-ready', {'detail': 'svg'})); document.dispatchEvent(new CustomEvent('media-ready', {'detail': 'svg'}));
@ -827,19 +838,17 @@ var resizeSlides = function() {
}; };
var resizeDeshareVideo = function() { var resizeDeshareVideo = function() {
if (!isThereDeskshareVideo()) return;
var deskshareVideo = document.getElementById("deskshare-video"); var deskshareVideo = document.getElementById("deskshare-video");
var $deskhareVideo = $("#deskshare-video");
if (deskshareVideo != null) { var videoWidth = parseInt(deskshareVideo.videoWidth, 10);
var $deskhareVideo = $("#deskshare-video"); var videoHeight = parseInt(deskshareVideo.videoHeight, 10);
var videoWidth = parseInt(deskshareVideo.videoWidth, 10); var aspectRatio = videoWidth/videoHeight;
var videoHeight = parseInt(deskshareVideo.videoHeight, 10); var max = aspectRatio * $deskhareVideo.parent().outerHeight();
$deskhareVideo.css("max-width", max);
var aspectRatio = videoWidth/videoHeight; var height = $deskhareVideo.parent().width() / aspectRatio;
var max = aspectRatio * $deskhareVideo.parent().outerHeight(); $deskhareVideo.css("max-height", height);
$deskhareVideo.css("max-width", max);
var height = $deskhareVideo.parent().width() / aspectRatio;
$deskhareVideo.css("max-height", height);
}
}; };

View File

@ -118,22 +118,30 @@ function removeSlideChangeAttribute() {
function mustShowDesktopVideo(time) { function mustShowDesktopVideo(time) {
var canShow = false; var canShow = false;
for (var m = 0; m < deskshareTimes.length; m++) { if (isThereDeskshareVideo()) {
var start_timestamp = deskshareTimes[m][0]; for (var m = 0; m < deskshareTimes.length; m++) {
var stop_timestamp = deskshareTimes[m][1]; var start_timestamp = deskshareTimes[m][0];
var stop_timestamp = deskshareTimes[m][1];
if(time >= start_timestamp && time <= stop_timestamp) if(time >= start_timestamp && time <= stop_timestamp)
canShow = true; canShow = true;
}
} }
return canShow; return canShow;
} }
function isThereDeskshareVideo() { function isThereDeskshareVideo() {
return deskshareTimes.length > 0; var deskshareVideo = document.getElementById("deskshare-video");
if (deskshareVideo != null) {
return true;
} else {
return false;
}
} }
function resyncVideos() { function resyncVideos() {
if (!isThereDeskshareVideo()) return;
var currentTime = Popcorn('#video').currentTime(); var currentTime = Popcorn('#video').currentTime();
var currentDeskshareVideoTime = Popcorn("#deskshare-video").currentTime(); var currentDeskshareVideoTime = Popcorn("#deskshare-video").currentTime();
if (Math.abs(currentTime - currentDeskshareVideoTime) >= 0.1) if (Math.abs(currentTime - currentDeskshareVideoTime) >= 0.1)
@ -158,10 +166,8 @@ function handlePresentationAreaContent(time) {
sharingDesktop = false; sharingDesktop = false;
} }
if(isThereDeskshareVideo()) { resyncVideos();
resyncVideos(); resizeDeshareVideo();
resizeDeshareVideo();
}
} }
// - - - END OF JAVASCRIPT FUNCTIONS - - - // // - - - END OF JAVASCRIPT FUNCTIONS - - - //
@ -626,13 +632,18 @@ document.addEventListener('media-ready', function(event) {
if ((audioReady || videoReady) && deskshareReady && svgReady) { if ((audioReady || videoReady) && deskshareReady && svgReady) {
runPopcorn(); runPopcorn();
generateThumbnails(); if (firstLoad) initPopcorn();
var p = Popcorn("#video");
p.currentTime(defineStartTime());
} }
}, false); }, false);
function initPopcorn() {
firstLoad = false;
generateThumbnails();
var p = Popcorn("#video");
p.currentTime(defineStartTime());
}
svgobj.addEventListener('load', function() { svgobj.addEventListener('load', function() {
console.log("got svgobj 'load' event"); console.log("got svgobj 'load' event");
document.dispatchEvent(new CustomEvent('media-ready', {'detail': 'svg'})); document.dispatchEvent(new CustomEvent('media-ready', {'detail': 'svg'}));
@ -827,19 +838,17 @@ var resizeSlides = function() {
}; };
var resizeDeshareVideo = function() { var resizeDeshareVideo = function() {
if (!isThereDeskshareVideo()) return;
var deskshareVideo = document.getElementById("deskshare-video"); var deskshareVideo = document.getElementById("deskshare-video");
var $deskhareVideo = $("#deskshare-video");
if (deskshareVideo != null) { var videoWidth = parseInt(deskshareVideo.videoWidth, 10);
var $deskhareVideo = $("#deskshare-video"); var videoHeight = parseInt(deskshareVideo.videoHeight, 10);
var videoWidth = parseInt(deskshareVideo.videoWidth, 10); var aspectRatio = videoWidth/videoHeight;
var videoHeight = parseInt(deskshareVideo.videoHeight, 10); var max = aspectRatio * $deskhareVideo.parent().outerHeight();
$deskhareVideo.css("max-width", max);
var aspectRatio = videoWidth/videoHeight; var height = $deskhareVideo.parent().width() / aspectRatio;
var max = aspectRatio * $deskhareVideo.parent().outerHeight(); $deskhareVideo.css("max-height", height);
$deskhareVideo.css("max-width", max);
var height = $deskhareVideo.parent().width() / aspectRatio;
$deskhareVideo.css("max-height", height);
}
}; };