Skip to content

Commit b030f61

Browse files
committed
fix: avoid crash when advancing without tracks
1 parent 738a289 commit b030f61

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

cmd/daemon/controls.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -660,8 +660,15 @@ func (p *AppPlayer) advanceNext(ctx context.Context, forceNext, drop bool) (bool
660660

661661
// Consider all tracks as recent because we got here by reaching the end of the context
662662
var prevTrackUris []string
663-
for _, track := range p.state.tracks.AllTracks(ctx) {
664-
prevTrackUris = append(prevTrackUris, track.Uri)
663+
if p.state.tracks != nil {
664+
for _, track := range p.state.tracks.AllTracks(ctx) {
665+
prevTrackUris = append(prevTrackUris, track.Uri)
666+
}
667+
}
668+
669+
if len(prevTrackUris) == 0 {
670+
p.app.log.Warnf("cannot resolve autoplay station because there are no previous tracks in context %s", p.state.player.ContextUri)
671+
return false, nil
665672
}
666673

667674
p.app.log.Debugf("resolving autoplay station for %d tracks", len(prevTrackUris))

0 commit comments

Comments
 (0)