Skip to content

Commit

Permalink
fix play functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
brianstrauch committed Dec 2, 2021
1 parent cb1674f commit 3987d0e
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions internal/play/play.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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 {
Expand Down

0 comments on commit 3987d0e

Please sign in to comment.