[GH-ISSUE #50] How to start playing without select the device from Spotify client? #42

Closed
opened 2026-02-28 14:24:52 +03:00 by kerem · 2 comments
Owner

Originally created by @lnkpaulo on GitHub (Jul 22, 2024).
Original GitHub issue: https://github.com/devgianlu/go-librespot/issues/50

Hello,

First of all thank you for the excellent work with the go-librespot.

I have a question rather than an issue:

When I start my Spotify client and connect it with go-librespot, everything works perfectly. However, if I store the last played status using TinyDB and try to initiate playback without first connecting via the Spotify client, I encounter an exception:

anic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x48 pc=0x901210]

goroutine 1 [running]:
go-librespot/tracks.(*List).AddToQueue(...)
	/home/myhome/Repository/myproject-librespot/go-librespot/tracks/tracks.go:222
main.(*AppPlayer).addToQueue(0xc0001d8880, 0xc0001d42a0)
	/home/myhome/Repository/myproject-librespot/go-librespot/cmd/daemon/controls.go:306 +0xb0
main.(*AppPlayer).handleApiRequest(0xc0001d8880, {{0xa417db, 0xc}, {0x952c80, 0xc000192310}, 0xc0003909c0})
	/home/myhome/Repository/myproject-librespot/go-librespot/cmd/daemon/player.go:391 +0x931
main.(*AppPlayer).Run(0xc0001d8880, 0xc000182480)
	/home/myhome/Repository/myproject-librespot/go-librespot/cmd/daemon/player.go:431 +0x69a
main.(*App).withAppPlayer(0xc000180280, 0xa?)
	/home/myhome/Repository/myproject-librespot/go-librespot/cmd/daemon/main.go:208 +0x4d2
main.(*App).withCredentials(0xc000180280, {0x9b1160, 0xc0001a65a0})
	/home/myhome/Repository/myproject-librespot/go-librespot/cmd/daemon/main.go:171 +0x38c
main.(*App).UserPass(...)
	/home/myhome/Repository/myproject-librespot/go-librespot/cmd/daemon/main.go:135
main.main()
	/home/myhome/Repository/myproject-librespot/go-librespot/cmd/daemon/main.go:462 +0x4e7
exit status 2

Basically, my question is: Is it possible to start playback without first connecting through the Spotify client?

Thank you for you time.

Originally created by @lnkpaulo on GitHub (Jul 22, 2024). Original GitHub issue: https://github.com/devgianlu/go-librespot/issues/50 Hello, First of all thank you for the excellent work with the go-librespot. I have a question rather than an issue: When I start my Spotify client and connect it with go-librespot, everything works perfectly. However, if I store the last played status using TinyDB and try to initiate playback without first connecting via the Spotify client, I encounter an exception: ``` anic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x48 pc=0x901210] goroutine 1 [running]: go-librespot/tracks.(*List).AddToQueue(...) /home/myhome/Repository/myproject-librespot/go-librespot/tracks/tracks.go:222 main.(*AppPlayer).addToQueue(0xc0001d8880, 0xc0001d42a0) /home/myhome/Repository/myproject-librespot/go-librespot/cmd/daemon/controls.go:306 +0xb0 main.(*AppPlayer).handleApiRequest(0xc0001d8880, {{0xa417db, 0xc}, {0x952c80, 0xc000192310}, 0xc0003909c0}) /home/myhome/Repository/myproject-librespot/go-librespot/cmd/daemon/player.go:391 +0x931 main.(*AppPlayer).Run(0xc0001d8880, 0xc000182480) /home/myhome/Repository/myproject-librespot/go-librespot/cmd/daemon/player.go:431 +0x69a main.(*App).withAppPlayer(0xc000180280, 0xa?) /home/myhome/Repository/myproject-librespot/go-librespot/cmd/daemon/main.go:208 +0x4d2 main.(*App).withCredentials(0xc000180280, {0x9b1160, 0xc0001a65a0}) /home/myhome/Repository/myproject-librespot/go-librespot/cmd/daemon/main.go:171 +0x38c main.(*App).UserPass(...) /home/myhome/Repository/myproject-librespot/go-librespot/cmd/daemon/main.go:135 main.main() /home/myhome/Repository/myproject-librespot/go-librespot/cmd/daemon/main.go:462 +0x4e7 exit status 2 ``` Basically, my question is: Is it possible to start playback without first connecting through the Spotify client? Thank you for you time.
kerem closed this issue 2026-02-28 14:24:53 +03:00
Author
Owner

@devgianlu commented on GitHub (Jul 25, 2024):

The problem is that you are adding something to the queue without having a context initiated, I have mitigated the issue by not crashing the player, but I don't think what you are trying to do is supported by Spotify.

You can try to play the song directly without adding it to the queue.

<!-- gh-comment-id:2249951837 --> @devgianlu commented on GitHub (Jul 25, 2024): The problem is that you are adding something to the queue without having a context initiated, I have [mitigated](https://github.com/devgianlu/go-librespot/commit/04ec5b150bcb917b8d951f5bba053a9b2803adc6) the issue by not crashing the player, but I don't think what you are trying to do is supported by Spotify. You can try to play the song directly without adding it to the queue.
Author
Owner

@lnkpaulo commented on GitHub (Jul 25, 2024):

Hi,

Thank you for the update, the patch solves the crash of the player: "WARN[0171] cannot add to queue without a context".

About the queue, I will follow your suggestion, before to have a context, playing directly works perfectly:

curl -X POST http://localhost:3678/player/play \
-H "Content-Type: application/json" \
-d '{"uri": "spotify:track:..track_id...", "paused": false}'

In conclusion, to my original question the answer is yes, :-), we can play directly without first connecting via the Spotify client.

Thank you once more.

<!-- gh-comment-id:2250016524 --> @lnkpaulo commented on GitHub (Jul 25, 2024): Hi, Thank you for the update, the patch solves the crash of the player: "_WARN[0171] cannot add to queue without a context_". About the queue, I will follow your suggestion, before to have a context, playing directly works perfectly: ```sh curl -X POST http://localhost:3678/player/play \ -H "Content-Type: application/json" \ -d '{"uri": "spotify:track:..track_id...", "paused": false}' ``` In conclusion, to my original question the answer is yes, :-), we can play directly without first connecting via the Spotify client. Thank you once more.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/go-librespot#42
No description provided.