add status line with media info to bottom of now playing page

This commit is contained in:
Drew Weymouth
2023-06-05 08:55:35 -07:00
parent 6d5900b692
commit fedb9fd70d
5 changed files with 153 additions and 6 deletions
+14
View File
@@ -39,6 +39,10 @@ type CanShowNowPlaying interface {
OnSongChange(song, lastScrobbledIfAny *mediaprovider.Track)
}
type CanShowPlayTime interface {
OnPlayTimeUpdate(curTime, totalTime float64)
}
type BrowsingPane struct {
widget.BaseWidget
@@ -66,6 +70,7 @@ func NewBrowsingPane(app *backend.App) *BrowsingPane {
b.forward = widget.NewButtonWithIcon("", theme.NavigateNextIcon(), b.GoForward)
b.reload = widget.NewButtonWithIcon("", theme.ViewRefreshIcon(), b.Reload)
b.app.PlaybackManager.OnSongChange(b.onSongChange)
b.app.PlaybackManager.OnPlayTimeUpdate(b.onPlayTimeUpdate)
bkgrnd := myTheme.NewThemedRectangle(myTheme.ColorNamePageBackground)
b.pageContainer = container.NewMax(bkgrnd, layout.NewSpacer())
b.settingsBtn = widget.NewButtonWithIcon("", theme.SettingsIcon(), func() {
@@ -175,6 +180,15 @@ func (b *BrowsingPane) onSongChange(song, lastScrobbledIfAny *mediaprovider.Trac
}
}
func (b *BrowsingPane) onPlayTimeUpdate(cur, total float64) {
if b.curPage == nil {
return
}
if p, ok := b.curPage.(CanShowPlayTime); ok {
p.OnPlayTimeUpdate(cur, total)
}
}
func (b *BrowsingPane) addPageToHistory(p Page, truncate bool) {
if truncate {
// allow garbage collection of pages that will be removed from the history