Hello, I am trying to get current time of song playing and I tried to get through slider… I got the time but its not accurate… It always late 2 seconds…
I tested with a song that is long 1:17… Song supposed to end when “current time label” reach 1:17, but it always end when “current time label” reach 1:15… “Current time label” is 2 seconds behind the real time…
Thats how I did that…
String newtime;
int vals = ui->posSlider->value();
int hourss = vals/(1000*60*60);
int minutess = (vals-(hourss*1000*60*60))/(1000*60);
int secondss = (vals-(minutess*1000*60)-(hours*1000*60*60))/1000;
newtime.append(QString( "%1" ).arg(minutess, 2, 10, QLatin1Char('0')) + ":" +
QString( "%1" ).arg(secondss, 2, 10, QLatin1Char('0')));
ui->label_3->setText(newtime);
Song ends and current time is displayed as 1:15 instead of 1:17… Also when song starts its obvious that “current time label” start displaying time 2 seconds after song starts…
So how can I fix that??? Or even better, how can I obtain current time directly from player, since I haven’t seen any function that would allow that… Only duration() which displays total time of the song…
↧