Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to play a playlist in go-librespot using the Spotify API #77

Closed
felixstorm opened this issue Sep 2, 2024 · 2 comments
Closed
Labels
bug Something isn't working

Comments

@felixstorm
Copy link
Contributor

When trying to play a playlist using the Spotify API with go-librespot (0.0.17 as well as current master), I get the following error:

ERRO[0062] failed unmarshalling dealer request payload   error="json: cannot unmarshal number into Go struct field RequestPayload.target_alias_id of type string" uri="hm://connect-state/v1/player/command"

I added some debug statements and apparently the JSON that is being received looks like this (formatting for readability):

{
    "message_id": 860749268,
    "target_alias_id": 0,
    "sent_by_device_id": "webapi-cfc0c47944b9400cb5db4f8faf9cbe36",
    "command": {
        "endpoint": "play",
        "context": {
            "uri": "spotify:playlist:37i9dQZF1DX7F6T2n2fegs",
            "url": "context://spotify:playlist:37i9dQZF1DX7F6T2n2fegs"
        },
        "play_origin": {
            "device_identifier": "webapi-cfc0c47944b9400cb5db4f8faf9cbe36"
        },
        "options": {},
        "logging_params": {
            "device_identifier": "webapi-cfc0c47944b9400cb5db4f8faf9cbe36"
        }
    }
}

Changing the type of TargetAliasId from string to uint32 seems to fix this problem, but then the code will panic later on:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x28 pc=0x916012]

goroutine 1 [running]:
main.(*AppPlayer).handlePlayerCommand(_, {0x334fdf7f, 0x0, {0xc00013d140, 0x27}, {{0xc000015dd0, 0x4}, {0x0, 0x0}, {0x0, ...}, ...}})
        .../go-librespot/cmd/daemon/player.go:223 +0x1f2
main.(*AppPlayer).handleDealerRequest(_, {0xc00029c360, {0xc00013c690, 0x24}, {0x334fdf7f, 0x0, {0xc00013d140, 0x27}, {{0xc000015dd0, 0x4}, ...}}})
        .../go-librespot/cmd/daemon/player.go:336 +0xe8
main.(*AppPlayer).Run(0xc000056800, 0xc0000444e0)
        .../go-librespot/cmd/daemon/player.go:520 +0x565
...

Thereafter I commented out the statements causing the segfault and then it seems to finally work. But unfortunately I do not have any real experience with any of the Spotify Connect APIs to estimate whether my first change is appropriate and why the segfault happens or what to do to fix it...

Also see:

@devgianlu devgianlu added the bug Something isn't working label Sep 2, 2024
@devgianlu
Copy link
Owner

Since Spotify does not know what type target_alias_id should have and we are not using it I've removed it. Also fixed the subsequent problem you had regarding the player options overrides.

@felixstorm
Copy link
Contributor Author

Great, thanks a lot!

joussy pushed a commit to joussy/go-librespot that referenced this issue Sep 6, 2024
joussy pushed a commit to joussy/go-librespot that referenced this issue Sep 6, 2024
thilojaeggi pushed a commit to thilojaeggi/go-librespot that referenced this issue Oct 13, 2024
thilojaeggi pushed a commit to thilojaeggi/go-librespot that referenced this issue Oct 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants