Move logic to .js file.

pull/2077/head
digital-gnome 2017-09-30 16:35:03 -04:00
parent e339b9e12a
commit 48a3e5eaa6
2 changed files with 32 additions and 29 deletions

View File

@ -169,35 +169,7 @@ if ( $Event->DefaultVideo() ) {
addVideoTimingTrack(document.getElementById('videoobj'), LabelFormat, monitorName, duration, startTime);
nearEventsQuery( eventData.Id );
var video = videojs('videoobj').ready(function(){
var player = this;
player.on('ended', function() {
switch(replayMode.value) {
case 'none':
break;
case 'single':
player.play();
break;
case 'all':
<!--nextEventStartTime.getTime() is a mootools workaround, highjacks Date.parse-->
var gapDuration = (new Date().getTime()) + (nextEventStartTime.getTime() - <?php echo (strtotime($Event->StartTime()) + $Event->Length())*1000 ?>);
var x = setInterval(function() {
var now = new Date().getTime();
var remainder = new Date(Math.round(gapDuration - now)).toISOString().substr(11,8);;
$j("#replayAllCountDown").html(remainder + " to next event.");
if (remainder < 0) {
clearInterval(x);
streamNext( true );
}
}, 1000);
break;
case 'gapless':
streamNext( true );
break;
}
});
});
vjsReplay(<?php echo (strtotime($Event->StartTime()) + $Event->LEngth())*1000 ?>);
</script>
<p id="replayAllCountDown"></p>

View File

@ -1,5 +1,36 @@
var vid = null;
function vjsReplay(endTime) {
var video = videojs('videoobj').ready(function(){
var player = this;
player.on('ended', function() {
switch(replayMode.value) {
case 'none':
break;
case 'single':
player.play();
break;
case 'all':
// nextEventStartTime.getTime() is a mootools workaround, highjacks Date.parse
var gapDuration = (new Date().getTime()) + (nextEventStartTime.getTime() - endTime);
var x = setInterval(function() {
var now = new Date().getTime();
var remainder = new Date(Math.round(gapDuration - now)).toISOString().substr(11,8);;
$j("#replayAllCountDown").html(remainder + " to next event.");
if (remainder < 0) {
clearInterval(x);
streamNext( true );
}
}, 1000);
break;
case 'gapless':
streamNext( true );
break;
}
});
});
}
function setButtonState( element, butClass ) {
if ( element ) {
element.className = butClass;