0
Hello, I am creating a time counter, to make a music progress bar. I am using the following code. However, this counter starts counting at 00:00 as obviously, but I would like it to start counting from a value I stipulate, for example: 02:35.
What changes can I make to make that happen? Since I couldn’t.
startCounting: function(time){
start = typeof(time) == 'undefined' ? new Date() : time;
loop = window.setInterval('aTurn.updateCouting()', 1);
},
updateCouting: function(){
aTurn.printTime(aTurn.diffProgress(aTurn.getTime()));
},
printTime: function(time){
$('.atual').text(time);
},
getTime: function(){
return(new Date() - start);
},
diffProgress: function(seconds){
if(isNaN(seconds))
seconds = 0;
var diff = new Date(seconds);
var minutes = diff.getMinutes();
var seconds = diff.getSeconds();
if(minutes < 10)
minutes = '0' + minutes;
if(seconds < 10)
seconds = '0' + seconds;
return minutes + ':' + seconds;
},
startProgress: function(){
if(start){
aTurn.unstartProgress();
}
else{
aTurn.startCounting();
return false;
}
},
unstartProgress: function(){
clearInterval(loop);
start = 0;
aTurn.fillText();
},
clearProgress: function(){
aTurn.unstartProgress();
$('.atual').text(aTurn.diffProgress(0));
},
fillText: function(){
$('.atual').text();
}
I don’t understand, you want the initial value to be 2:35 or you want to start counting when the audio execution comes to that point?
– Leandro Angelo
I want the starting value to be 2:35.
– Paulo Sérgio Filho
Or what I stipulate, because when changing music is another value.
– Paulo Sérgio Filho