mirror of
https://github.com/librespot-org/librespot.git
synced 2026-04-27 08:15:50 +03:00
[GH-ISSUE #457] [Feature Request] local API for play/pause/skip, etc... #290
Labels
No labels
A-Alsa
SpotifyAPI
Tokio 1.0
audio
bug
can't reproduce
compilation
dependencies
duplicate
enhancement
good first issue
help wanted
high priority
imported
imported
invalid
new api
pull-request
question
reverse engineering
wiki
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/librespot#290
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @m-a-x-i-m-z on GitHub (Apr 9, 2020).
Original GitHub issue: https://github.com/librespot-org/librespot/issues/457
I'm using librespot embedded in moodeaudio suite as a headless player based on raspberry-pi zero. In general it's great, but what I'm missing is a possibility to stop/start playback and also skip to the next song in the list (to be activated by the remote control, which is wired and is waiting to be supported by the software).
librespot-java has a local socket-based API, which can be conveniently used from a command line or potentially from a local IR daemon in my case. However, I'm not convinced that running a java thing on the pi-zero hardware is a good idea...
So IDEALLY I would love to know, whether there is a similar API in librespot or whether it can be easily hacked in.
ALTERNATIVELY: I am aware of the official WEB API, however, I'm missing a way of acquiring credentials and IDs of the current spotify user. The player is installed in the living room and is used by five people/accounts, so hard-wiring the login/credentials into the IR event scripts is not an option. But even though it feels strange, that for stopping/pausing the playback locally I have to send a request to a remote server, I would do so if I was aware of getting the bits and pieces needed for forming a spotify's WEB-API request.
Any input is greatly appreciated!
--Max
@bluepuma77 commented on GitHub (Apr 13, 2020):
spotifyd is a "related project" in Rust using librespot, there is a similar feature request.
I have the same challenge, would like to use Spotify Connect and still control music.
Lets see if one of the projects implements this feature 😃
@ashthespy commented on GitHub (Apr 13, 2020):
I implemented a simple socket over at
Vollibrespotthatshouldcould someday work its way intolibrespotd, the fabled daemon version of thelibrespotlibrary ;-)@m-a-x-i-m-z commented on GitHub (Apr 15, 2020):
Good pointers, thanks! I'll keep searching... too bad I don't speak Rust... And even if I did it would include setting up a complete cross-compile tool chain for RPI...
@ashthespy commented on GitHub (Apr 15, 2020):
FWIW, you could grab a pre-compiled release from https://github.com/ashthespy/Vollibrespot/releases/
The
armv6lversion should run on all raspbian images..@m-a-x-i-m-z commented on GitHub (Apr 16, 2020):
OK, it does start, indeed. Great, many thanks! However, now I see two further problems :
I imagine that the simple feedback mechanism of librespot was superseded by the socket mechanism of vollibrespot, so point 1 may be solvable somehow in the end. But for that I need more info about point 2. Any hints?
Thanks in advance!
@ashthespy commented on GitHub (Apr 17, 2020):
@m-a-x-i-m-z
vollibrespotwas born as a way to pipe metadata to a Volumio plugin, so it caters more to that need, the--oneventwas moot as events are instead exposed over a socket and can be used from there.nc -ulp 5030should give you typical events exposed currently..It's not meant to be a drop-in replacement for librespot. I was under the impression you wanted to roll your own interface, it should be quiet simple though - ashthespy/Volumio-SpotifyConnect should give you a simple nodejs based implementation.
But this is all a stopgap, and a long term solution would be to have different metadata providers (websocket/REST/socket) etc similar to how we currently have our backends baked into
librespotd@txoof commented on GitHub (May 2, 2020):
@ashthespy
Thanks for the tip on vollibrespot.
I'm trying to pull the "now playing" JSON data from spotify so I can use it for this project:
https://github.com/txoof/slimpi_epd
I've successfully managed to start up vollibrespot; I'd like to connect to it and start pulling the JSON, but I'm not sure where to begin.
Thanks!
@ashthespy commented on GitHub (May 2, 2020):
@txoof nice project, I have been meaning to do something similar with some nfc cards as well. If you hop onto gitter, I can help you without spamming everyone here ;-)
@HBeserra commented on GitHub (Jul 23, 2020):
if librespot receives a scope and generates the token, the rest can be done by another application
@ashthespy commented on GitHub (Jul 23, 2020):
@HBeserra it does that already - check out
keymaster::get_token@HBeserra commented on GitHub (Jul 24, 2020):
@ashthespy As I understand it, the get_token () function will generate a token based on a section, scope and client_id, but I would like to receive the most recent token from the connected user.
@ashthespy commented on GitHub (Jul 24, 2020):
get_token()lets you generate a token (access_tokenin Spotify's parlance, that with the appropriate scopes can be passed out to an external application that can then control playback, retrieve metadata, or basically what ever Spotify's API's allow you to do..Not sure what you mean by "the most recent token from the connected user" here..Ah -
get_tokenreturns a token for the user attached to the current authenticatedSession@HBeserra commented on GitHub (Jul 28, 2020):
My goal is to define a scope and export the valid
acess_tokento another application and update it from time to time.I didn't find any reference to the function in code besides the keymaster, our a documentation about. Is there any documentation or other repository?
@ashthespy commented on GitHub (Jul 29, 2020):
@HBeserra Just added #512 as a simple example.
The core library only provides you a way to fetch an API token, and doesn't keep track of the expiry of the token and refresh it. But that is trivial to manage in your end application.. :-)