use plain label for Now Playing status line - we weren't doing any formatting

This commit is contained in:
Drew Weymouth
2023-11-05 09:22:51 -08:00
parent 1a8196d471
commit 91c6addd89
+6 -7
View File
@@ -31,7 +31,7 @@ type NowPlayingPage struct {
title *widget.RichText title *widget.RichText
tracklist *widgets.Tracklist tracklist *widgets.Tracklist
statusLabel *widget.RichText statusLabel *widget.Label
nowPlayingID string nowPlayingID string
container *fyne.Container container *fyne.Container
} }
@@ -83,7 +83,7 @@ func NewNowPlayingPage(
a.tracklist.OnPlayTrackAt = a.onPlayTrackAt a.tracklist.OnPlayTrackAt = a.onPlayTrackAt
a.title = widget.NewRichTextWithText("Now Playing") a.title = widget.NewRichTextWithText("Now Playing")
a.title.Segments[0].(*widget.TextSegment).Style.SizeName = widget.RichTextStyleHeading.SizeName a.title.Segments[0].(*widget.TextSegment).Style.SizeName = widget.RichTextStyleHeading.SizeName
a.statusLabel = widget.NewRichTextWithText("Stopped") a.statusLabel = widget.NewLabel("Stopped")
statusLabelCtr := container.New(&layouts.VboxCustomPadding{ExtraPad: -5}, statusLabelCtr := container.New(&layouts.VboxCustomPadding{ExtraPad: -5},
myTheme.NewThemedRectangle(theme.ColorNameInputBorder), myTheme.NewThemedRectangle(theme.ColorNameInputBorder),
a.statusLabel, a.statusLabel,
@@ -133,8 +133,7 @@ func (a *NowPlayingPage) OnPlayTimeUpdate(_, _ float64) {
func (a *NowPlayingPage) formatStatusLine() { func (a *NowPlayingPage) formatStatusLine() {
playerStats := a.p.GetStatus() playerStats := a.p.GetStatus()
ts := a.statusLabel.Segments[0].(*widget.TextSegment) lastStatus := a.statusLabel.Text
lastStatus := ts.Text
state := "Stopped" state := "Stopped"
switch playerStats.State { switch playerStats.State {
case player.Paused: case player.Paused:
@@ -159,7 +158,7 @@ func (a *NowPlayingPage) formatStatusLine() {
len(a.queue), statusSuffix) len(a.queue), statusSuffix)
if state == "Stopped" { if state == "Stopped" {
ts.Text = fmt.Sprintf("%s | Total time: %s", status, util.SecondsToTimeString(a.totalTime)) a.statusLabel.Text = fmt.Sprintf("%s | Total time: %s", status, util.SecondsToTimeString(a.totalTime))
} else { } else {
audioInfo, err := a.p.GetMediaInfo() audioInfo, err := a.p.GetMediaInfo()
if err != nil { if err != nil {
@@ -172,14 +171,14 @@ func (a *NowPlayingPage) formatStatusLine() {
// Note: bit depth intentionally omitted since MPV reports the decoded bit depth // Note: bit depth intentionally omitted since MPV reports the decoded bit depth
// i.e. 24 bit files get reported as 32 bit. Also b/c bit depth isn't meaningful for lossy. // i.e. 24 bit files get reported as 32 bit. Also b/c bit depth isn't meaningful for lossy.
ts.Text = fmt.Sprintf("%s · %s %g kHz, %d kbps | Total time: %s", a.statusLabel.Text = fmt.Sprintf("%s · %s %g kHz, %d kbps | Total time: %s",
status, status,
codec, codec,
float64(audioInfo.Samplerate)/1000, float64(audioInfo.Samplerate)/1000,
audioInfo.Bitrate/1000, audioInfo.Bitrate/1000,
util.SecondsToTimeString(a.totalTime)) util.SecondsToTimeString(a.totalTime))
} }
if lastStatus != ts.Text { if lastStatus != a.statusLabel.Text {
a.statusLabel.Refresh() a.statusLabel.Refresh()
} }
} }