update slider once per second always

This commit is contained in:
Drew Weymouth
2022-12-23 14:55:47 -08:00
parent af24ec56a8
commit 024557d49e
4 changed files with 13 additions and 25 deletions
+2 -3
View File
@@ -148,9 +148,8 @@ func (pc *PlayerControls) doPlayTimeUpdate(curTime, totalTime float64) {
pc.curTimeLabel.SetText(ct)
updated = true
}
if totalTime < 210 || updated {
// if current track is long, we only need to redraw the slider
// when the time label updates, to reduce screen redraws.
if updated {
// Only update slider once a second when time label changes
pc.slider.SetValue(v)
}
}
+5 -2
View File
@@ -1,13 +1,16 @@
package ui
import "fmt"
import (
"fmt"
"math"
)
func SecondsToTimeString(s float64) string {
if s < 0 {
s = 0
}
min := int(s / 60)
sec := int(s - float64(min*60))
sec := int(math.Round(s - float64(min*60)))
return fmt.Sprintf("%2d:%02d", min, sec)
}