@@ -160,6 +160,7 @@ void MediaControls::MediaSliderReleased()
160
160
obs_source_media_set_time (source, GetSliderTime (seek));
161
161
}
162
162
163
+ UpdateLabels (seek);
163
164
seek = lastSeek = -1 ;
164
165
}
165
166
@@ -179,6 +180,7 @@ void MediaControls::MediaSliderMoved(int val)
179
180
{
180
181
if (seekTimer.isActive ()) {
181
182
seek = val;
183
+ UpdateLabels (seek);
182
184
}
183
185
}
184
186
@@ -358,16 +360,7 @@ void MediaControls::SetSliderPosition()
358
360
sliderPosition = 0 .0f ;
359
361
360
362
ui->slider ->setValue ((int )sliderPosition);
361
-
362
- ui->timerLabel ->setText (FormatSeconds ((int )(time / 1000 .0f )));
363
-
364
- if (!countDownTimer)
365
- ui->durationLabel ->setText (
366
- FormatSeconds ((int )(duration / 1000 .0f )));
367
- else
368
- ui->durationLabel ->setText (
369
- QString (" -" ) +
370
- FormatSeconds ((int )((duration - time ) / 1000 .0f )));
363
+ UpdateLabels ((int )sliderPosition);
371
364
}
372
365
373
366
QString MediaControls::FormatSeconds (int totalSeconds)
@@ -535,3 +528,26 @@ void MediaControls::UpdateSlideCounter()
535
528
ui->durationLabel ->setText (" -" );
536
529
}
537
530
}
531
+
532
+ void MediaControls::UpdateLabels (int val)
533
+ {
534
+ OBSSource source = OBSGetStrongRef (weakSource);
535
+ if (!source) {
536
+ return ;
537
+ }
538
+
539
+ float duration = (float )obs_source_media_get_duration (source);
540
+ float percent = (float )val / (float )ui->slider ->maximum ();
541
+
542
+ float time = percent * duration;
543
+
544
+ ui->timerLabel ->setText (FormatSeconds ((int )(time / 1000 .0f )));
545
+
546
+ if (!countDownTimer)
547
+ ui->durationLabel ->setText (
548
+ FormatSeconds ((int )(duration / 1000 .0f )));
549
+ else
550
+ ui->durationLabel ->setText (
551
+ QString (" -" ) +
552
+ FormatSeconds ((int )((duration - time ) / 1000 .0f )));
553
+ }
0 commit comments