PDA

View Full Version : How to make media duration timer?



adutzu89
10th October 2013, 16:09
I am trying to make a media timer in QML but the problem is that the seconds are going past 60, how can I make the seconds timer reset whenever it hits 60?
I have the following.


Text{
property var pozitieActMin:
parseInt(utilMuz.position/60000)<10 ?
"0"+parseInt(utilMuz.position/60000) : parseInt(utilMuz.position/60000);
property var pozitieActSec:
parseInt(utilMuz.position/1000)<10 ?
"0"+parseInt(utilMuz.position/1000) : parseInt(utilMuz.position/1000);
property var durataMin:
parseInt(utilMuz.duration/60000)<10 ?
"0"+parseInt(utilMuz.duration/60000) : parseInt(utilMuz.duration/60000);
property var durataSec:
parseInt(utilMuz.duration/1000)<10 ?
"0"+parseInt(utilMuz.duration/1000) : parseInt(utilMuz.duration/1000);
text:"Duration "+pozitieActMin+":"+pozitieActSec+"/"+durataMin+":"+durataSec;
}

stampede
11th October 2013, 08:23
For me it looks like your problem is not the timer, but the way you are trying to calculate the result.
A simple example, 123 000 ms =
[(123 000/60 000) min + (3 000 / 1000) s = 2 min + 3 s], but in your code it is
[(123 000 / 60 000) min + (123 000 / 1000) s = 2 min + 123 s]
Do you see where is the problem ?

adutzu89
11th October 2013, 09:21
For me it looks like your problem is not the timer, but the way you are trying to calculate the result.
A simple example, 123 000 ms =
[(123 000/60 000) min + (3 000 / 1000) s = 2 min + 3 s], but in your code it is
[(123 000 / 60 000) min + (123 000 / 1000) s = 2 min + 123 s]
Do you see where is the problem ?

I figured it out, thank you.