From 3987d0e93d3613dcfe7ccfa45b68748568ab09f7 Mon Sep 17 00:00:00 2001 From: Brian Strauch Date: Wed, 1 Dec 2021 20:32:50 -0800 Subject: [PATCH] fix play functionality --- internal/play/play.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/internal/play/play.go b/internal/play/play.go index 9dbc551..1a54994 100644 --- a/internal/play/play.go +++ b/internal/play/play.go @@ -77,9 +77,7 @@ func Play(api internal.APIInterface, track, playlist, album string) (string, err if err := api.Play("", track.URI); err != nil { return "", err } - } - - if album != "" { + } else if album != "" { album, err := internal.SearchAlbum(api, album) if err != nil { return "", err @@ -88,9 +86,7 @@ func Play(api internal.APIInterface, track, playlist, album string) (string, err if err := api.Play(album.URI); err != nil { return "", err } - } - - if playlist != "" { + } else if playlist != "" { playlist, err := internal.SearchPlaylist(api, playlist) if err != nil { return "", err @@ -99,10 +95,14 @@ func Play(api internal.APIInterface, track, playlist, album string) (string, err if err := api.Play(playlist.URI); err != nil { return "", err } + } else { + if err := api.Play(""); err != nil { + return "", err + } } playback, err = internal.WaitForUpdatedPlayback(api, func(playback *spotify.Playback) bool { - hasChanged := len(playback.Item.ID) > 0 && (playback.Item.ID != id || playback.ProgressMs < progressMs) + hasChanged := playback.Item.ID != "" && (playback.Item.ID != id || playback.ProgressMs < progressMs) return !isPlaying && playback.IsPlaying || hasChanged }) if err != nil {