feat(ipc): add an endpoint for getting current track (#911)

This commit is contained in:
tdakkota
2026-04-20 19:36:11 -07:00
committed by GitHub
parent 56546a9314
commit cfa45a4647
10 changed files with 94 additions and 18 deletions
+19 -1
View File
@@ -47,6 +47,11 @@ type PlaybackManager struct {
// whether autoplay tracks are currently being fetched/enqueued
pendingAutoplay bool
wasLoadTrackPaused bool
// current radio metadata
radioStationName string
radioIcyTitle string
radioIcyArtist string
}
type RemotePlaybackDevice struct {
@@ -157,6 +162,11 @@ func (p *PlaybackManager) addOnTrackChangeHook() {
}()
}
})
p.OnRadioMetadataChange(func(radioName, title, artist string) {
p.radioStationName = radioName
p.radioIcyTitle = title
p.radioIcyArtist = artist
})
}
func (p *PlaybackManager) handleWaveformImageSongChange(item mediaprovider.MediaItem) {
@@ -320,7 +330,15 @@ func (p *PlaybackManager) DisableCallbacks() {
// Gets the now playing media item, if any.
func (p *PlaybackManager) NowPlaying() mediaprovider.MediaItem {
return p.engine.NowPlaying()
item := p.engine.NowPlaying()
if station, ok := item.(*mediaprovider.RadioStation); ok {
station = station.Copy().(*mediaprovider.RadioStation)
station.StationName = p.radioStationName
station.Title = p.radioIcyTitle
station.Artists = []string{p.radioIcyArtist}
item = station
}
return item
}
func (p *PlaybackManager) NowPlayingIndex() int {