zmb3 / spotify

A Go wrapper for the Spotify Web API
Apache License 2.0
1.34k stars 284 forks source link

bug: PlaybackOffset with Position=0 doesn't work #161

Closed insomnimus closed 2 years ago

insomnimus commented 3 years ago

First I want to thank the maintainers of this package for their awesome work.

I've stumbled on this issue while working with my spotify shell, libman.

The snippet below does not work:

client.PlayOpt(&spotify.PlayOptions{
  PlaybackContext: &someURI,
    PlaybackOffset: &spotify.PlaybackOffset{ Position: 0 },
    })

It says in the documentation that the position is 0 based, but since the field has omitempty, it will omit the field essentiall sending a bare PlaybackOffset.

Here's what spotify returns:

error: At least one of "uri" or "position" should be specified

Edit: Fix md syntax.

strideynet commented 2 years ago

Thanks for raising this. I'll try and take a look at this later.

omerhanci commented 2 years ago

I guess this fix broke the usage of URI in PlaybackOffset.

Following code returns: Illegal offset: should be position XOR uri

opts.PlaybackOffset = &spotify.PlaybackOffset{
            URI: songUri,
        }
omerhanci commented 2 years ago

Hi, I created a PR to fix this problem, can you check it? https://github.com/zmb3/spotify/pull/177