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'])) {
$rate = validInt($_REQUEST['rate']);
} else if ( isset($_COOKIE['zmEventRate']) ) {
$rate = $_COOKIE['zmEventRate'];
} else {
$rate = reScale(RATE_BASE, $Monitor->DefaultRate(), ZM_WEB_DEFAULT_RATE);
}

View File

@ -235,6 +235,7 @@ function getCmdResponse( respObj, respText ) {
streamPause( );
} else {
$j('#rateValue').html(streamStatus.rate);
Cookie.write('zmEventRate', streamStatus.rate*100, {duration: 10*365});
streamPlay( );
}
$j('#progressValue').html(secsToTime(parseInt(streamStatus.progress)));
@ -303,8 +304,10 @@ function playClicked( ) {
}
function vjsPlay() { //catches if we change mode programatically
if ( intervalRewind )
stopFastRev();
$j('#rateValue').html(vid.playbackRate());
Cookie.write('zmEventRate', vid.playbackRate(), {duration: 10*365});
streamPlay();
}
@ -331,6 +334,7 @@ function streamFastFwd( action ) {
if ( rates.indexOf(vid.playbackRate()*100)-1 == -1 )
setButtonState($('fastFwdBtn'), 'unavail');
$j('#rateValue').html(vid.playbackRate());
Cookie.write('zmEventRate', vid.playbackRate()*100, {duration: 10*365});
} else {
streamReq.send(streamParms+"&command="+CMD_FASTFWD);
}
@ -359,6 +363,7 @@ function streamSlowRev( action ) {
function stopFastRev() {
clearInterval(intervalRewind);
vid.playbackRate(1);
Cookie.write('zmEventRate', vid.playbackRate()*100, {duration: 10*365});
revSpeed = .5;
}
@ -369,13 +374,14 @@ function streamFastRev( action ) {
setButtonState( $('slowFwdBtn'), 'unavail' );
setButtonState( $('slowRevBtn'), 'unavail' );
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;
if ( rates.indexOf(revSpeed*100) == 0 ) {
setButtonState( $('fastRevBtn'), 'unavail' );
}
clearInterval(intervalRewind);
$j('#rateValue').html(-revSpeed);
Cookie.write('zmEventRate', vid.playbackRate()*100, {duration: 10*365});
intervalRewind = setInterval(function() {
if (vid.currentTime() <= 0) {
clearInterval(intervalRewind);
@ -997,8 +1003,13 @@ function initPage() {
vid.on('pause', vjsPause);
vid.on('click', function(event){handleClick(event);});
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 {
progressBarNav ();
progressBarNav();
streamCmdTimer = streamQuery.delay( 250 );
if ( canStreamNative ) {
var imageFeed = $('imageFeed');

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 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 LabelFormat = "<?php echo validJsStr($Monitor->LabelFormat())?>";