feat(ipc): add an endpoint for getting current track (#911)
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user