Fix rate resetting by storing it in a cookie and using that on initial event load. Fixes #2319

This commit is contained in:
Isaac Connor 2018-11-29 09:43:21 -05:00
parent 8404f0ef64
commit 605397b565
3 changed files with 17 additions and 3 deletions

View File

@ -38,6 +38,8 @@ $Monitor = $Event->Monitor();
if (isset($_REQUEST['rate'])) { if (isset($_REQUEST['rate'])) {
$rate = validInt($_REQUEST['rate']); $rate = validInt($_REQUEST['rate']);
} else if ( isset($_COOKIE['zmEventRate']) ) {
$rate = $_COOKIE['zmEventRate'];
} else { } else {
$rate = reScale(RATE_BASE, $Monitor->DefaultRate(), ZM_WEB_DEFAULT_RATE); $rate = reScale(RATE_BASE, $Monitor->DefaultRate(), ZM_WEB_DEFAULT_RATE);
} }

View File

@ -235,6 +235,7 @@ function getCmdResponse( respObj, respText ) {
streamPause( ); streamPause( );
} else { } else {
$j('#rateValue').html(streamStatus.rate); $j('#rateValue').html(streamStatus.rate);
Cookie.write('zmEventRate', streamStatus.rate*100, {duration: 10*365});
streamPlay( ); streamPlay( );
} }
$j('#progressValue').html(secsToTime(parseInt(streamStatus.progress))); $j('#progressValue').html(secsToTime(parseInt(streamStatus.progress)));
@ -303,8 +304,10 @@ function playClicked( ) {
} }
function vjsPlay() { //catches if we change mode programatically function vjsPlay() { //catches if we change mode programatically
if ( intervalRewind )
stopFastRev(); stopFastRev();
$j('#rateValue').html(vid.playbackRate()); $j('#rateValue').html(vid.playbackRate());
Cookie.write('zmEventRate', vid.playbackRate(), {duration: 10*365});
streamPlay(); streamPlay();
} }
@ -331,6 +334,7 @@ function streamFastFwd( action ) {
if ( rates.indexOf(vid.playbackRate()*100)-1 == -1 ) if ( rates.indexOf(vid.playbackRate()*100)-1 == -1 )
setButtonState($('fastFwdBtn'), 'unavail'); setButtonState($('fastFwdBtn'), 'unavail');
$j('#rateValue').html(vid.playbackRate()); $j('#rateValue').html(vid.playbackRate());
Cookie.write('zmEventRate', vid.playbackRate()*100, {duration: 10*365});
} else { } else {
streamReq.send(streamParms+"&command="+CMD_FASTFWD); streamReq.send(streamParms+"&command="+CMD_FASTFWD);
} }
@ -359,6 +363,7 @@ function streamSlowRev( action ) {
function stopFastRev() { function stopFastRev() {
clearInterval(intervalRewind); clearInterval(intervalRewind);
vid.playbackRate(1); vid.playbackRate(1);
Cookie.write('zmEventRate', vid.playbackRate()*100, {duration: 10*365});
revSpeed = .5; revSpeed = .5;
} }
@ -369,13 +374,14 @@ function streamFastRev( action ) {
setButtonState( $('slowFwdBtn'), 'unavail' ); setButtonState( $('slowFwdBtn'), 'unavail' );
setButtonState( $('slowRevBtn'), 'unavail' ); setButtonState( $('slowRevBtn'), 'unavail' );
setButtonState( $('fastRevBtn'), 'active' ); setButtonState( $('fastRevBtn'), 'active' );
if ( vid ) { //There is no reverse play with mp4. Set the speed to 0 and manualy set the time back. if ( vid ) { //There is no reverse play with mp4. Set the speed to 0 and manually set the time back.
revSpeed = rates[rates.indexOf(revSpeed*100)-1]/100; revSpeed = rates[rates.indexOf(revSpeed*100)-1]/100;
if ( rates.indexOf(revSpeed*100) == 0 ) { if ( rates.indexOf(revSpeed*100) == 0 ) {
setButtonState( $('fastRevBtn'), 'unavail' ); setButtonState( $('fastRevBtn'), 'unavail' );
} }
clearInterval(intervalRewind); clearInterval(intervalRewind);
$j('#rateValue').html(-revSpeed); $j('#rateValue').html(-revSpeed);
Cookie.write('zmEventRate', vid.playbackRate()*100, {duration: 10*365});
intervalRewind = setInterval(function() { intervalRewind = setInterval(function() {
if (vid.currentTime() <= 0) { if (vid.currentTime() <= 0) {
clearInterval(intervalRewind); clearInterval(intervalRewind);
@ -997,6 +1003,11 @@ function initPage() {
vid.on('pause', vjsPause); vid.on('pause', vjsPause);
vid.on('click', function(event){handleClick(event);}); vid.on('click', function(event){handleClick(event);});
vid.on('timeupdate', function (){$j('#progressValue').html(secsToTime(Math.floor(vid.currentTime())))}); vid.on('timeupdate', function (){$j('#progressValue').html(secsToTime(Math.floor(vid.currentTime())))});
if ( rate > 1 ) {
// rate should be 100 = 1x, etc.
vid.playbackRate(rate/100);
}
} else { } else {
progressBarNav(); progressBarNav();
streamCmdTimer = streamQuery.delay( 250 ); streamCmdTimer = streamQuery.delay( 250 );

View File

@ -41,6 +41,7 @@ var filterQuery = '<?php echo isset($filterQuery)?validJsStr(htmlspecialchars_de
var sortQuery = '<?php echo isset($sortQuery)?validJsStr(htmlspecialchars_decode($sortQuery)):'' ?>'; var sortQuery = '<?php echo isset($sortQuery)?validJsStr(htmlspecialchars_decode($sortQuery)):'' ?>';
var rates = <?php echo json_encode(array_keys($rates)) ?>; var rates = <?php echo json_encode(array_keys($rates)) ?>;
var rate = '<?php echo $rate ?>'; // really only used when setting up initial playback rate.
var scale = "<?php echo $scale ?>"; var scale = "<?php echo $scale ?>";
var LabelFormat = "<?php echo validJsStr($Monitor->LabelFormat())?>"; var LabelFormat = "<?php echo validJsStr($Monitor->LabelFormat())?>";