Updated elapsed time while user is dragging the progress slider.
Also ensure that only one seek event can be triggered at a time.
This commit is contained in:
parent
756095c5ff
commit
d89673dd56
11
mopidy_musicbox_webclient/static/js/controls.js
vendored
11
mopidy_musicbox_webclient/static/js/controls.js
vendored
@ -360,13 +360,18 @@ function doSingle() {
|
|||||||
* Use a timer to prevent looping of commands *
|
* Use a timer to prevent looping of commands *
|
||||||
***********************************************/
|
***********************************************/
|
||||||
function doSeekPos(value) {
|
function doSeekPos(value) {
|
||||||
if (mopidy) {
|
if (!positionChanging) {
|
||||||
mopidy.playback.seek({'time_position': Math.round(value)});
|
positionChanging = value;
|
||||||
|
mopidy.playback.seek({'time_position': Math.round(value)}).then( function() {
|
||||||
|
positionChanging = null;
|
||||||
|
});;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function setPosition(pos) {
|
function setPosition(pos) {
|
||||||
setProgressTimer(pos);
|
if (!positionChanging && $("#trackslider").val() != pos) {
|
||||||
|
setProgressTimer(pos);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************
|
/***********************************************
|
||||||
|
|||||||
@ -14,7 +14,9 @@ var consume;
|
|||||||
var single;
|
var single;
|
||||||
var mute;
|
var mute;
|
||||||
var volumeChanging;
|
var volumeChanging;
|
||||||
var volumeSliding;
|
var volumeSliding = false;
|
||||||
|
|
||||||
|
var positionChanging;
|
||||||
|
|
||||||
var initgui = true;
|
var initgui = true;
|
||||||
var popupData = {};
|
var popupData = {};
|
||||||
|
|||||||
@ -569,8 +569,15 @@ $(document).ready(function(event) {
|
|||||||
event.stopImmediatePropagation(); }
|
event.stopImmediatePropagation(); }
|
||||||
} );
|
} );
|
||||||
|
|
||||||
$( "#trackslider" ).on( "slidestart", function() { progressTimer.stop(); } );
|
$( "#trackslider" ).on( "slidestart", function() {
|
||||||
$( "#trackslider" ).on( "slidestop", function() { doSeekPos( $(this).val() ); } );
|
progressTimer.stop();
|
||||||
|
$( "#trackslider" ).on( "change", function() { updatePosition( $(this).val() ); } );
|
||||||
|
} );
|
||||||
|
|
||||||
|
$( "#trackslider" ).on( "slidestop", function() {
|
||||||
|
$( "#trackslider" ).off( "change");
|
||||||
|
doSeekPos( $(this).val() );
|
||||||
|
} );
|
||||||
|
|
||||||
$( "#volumeslider" ).on( "slidestart", function() { volumeSliding = true; } );
|
$( "#volumeslider" ).on( "slidestart", function() { volumeSliding = true; } );
|
||||||
$( "#volumeslider" ).on( "slidestop", function() { volumeSliding = false; } );
|
$( "#volumeslider" ).on( "slidestop", function() { volumeSliding = false; } );
|
||||||
|
|||||||
@ -112,7 +112,7 @@ function format(milliseconds) {
|
|||||||
if (milliseconds === Infinity) {
|
if (milliseconds === Infinity) {
|
||||||
return '(n/a)';
|
return '(n/a)';
|
||||||
} else if (milliseconds == 0) {
|
} else if (milliseconds == 0) {
|
||||||
return '';
|
return '0:00';
|
||||||
}
|
}
|
||||||
|
|
||||||
var seconds = Math.floor(milliseconds / 1000);
|
var seconds = Math.floor(milliseconds / 1000);
|
||||||
@ -160,6 +160,10 @@ function setProgressTimer(pos) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function updatePosition(pos) {
|
||||||
|
positionNode.nodeValue = format(pos);
|
||||||
|
}
|
||||||
|
|
||||||
function startProgressTimer() {
|
function startProgressTimer() {
|
||||||
reset();
|
reset();
|
||||||
progressTimer.start();
|
progressTimer.start();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user