mirror of
https://github.com/librespot-org/librespot.git
synced 2026-04-27 08:15:50 +03:00
[GH-ISSUE #17] Provide more/better event hooks #5
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#5
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 @michaelherger on GitHub (Jan 29, 2018).
Original GitHub issue: https://github.com/librespot-org/librespot/issues/17
librespot does provide runtime parameters to trigger an external script on some events. I'd like to see this expanded to support native events in the library code. Plus more events than start/stop/change. Eg. a track skip, volume change etc. are not supported at this point.
Background: my main interest currently is Spotify on Squeezebox/Logitech Media Server (LMS). Integration with this environment isn't trivial, as audio data isn't fed to the player hardware, but would go through LMS, then over the network to the players. In order to keep the player UI up to date and in sync with the actual playback, I need to know about changes.
The users of this plugin run LMS on all kinds of platforms, from Windows, over Mac, to various NAS devices, Raspberry Pi, desktop Linux and even FreeBSD. Scripting these platforms in a generic and reliable way is difficult. I therefore forked librespot to add hooks in place of the above which would trigger http requests to LMS. While this works pretty well, it's a hack. I added code mostly to the player.rs code, but would be happy to get back to plain librespot code...
@michaelherger commented on GitHub (Jan 29, 2018):
Related to issue #25
@sashahilton00 commented on GitHub (Feb 1, 2018):
Probably best implemented in #20
@plietar commented on GitHub (Feb 8, 2018):
It seems like the onstart/onstop/onchange hooks are more or less sufficient for your usecase, unless I am missing something?
What needs to be done is in
player.rsswitch them into arbitrary closures and move the "execute external program" part tomain.rs. This way you'll be able to use your custom code by only patching/writing your ownmain.rs@michaelherger commented on GitHub (Feb 8, 2018):
That's a starting point. But the player state handling is somewhat irritating: if a track plays out (ends) and a new one begins, I'd get a stop event. I was having a hard time trying to figure out from the callee whether the playback really ended or not. But that's probably my convoluted way of using librespot :-).
FWIW: as I'm not using librespot's playback but am piping the PCM stream through LMS, I did add volume change events, too. But that's really a non-standard use case.
@sashahilton00 commented on GitHub (Mar 22, 2018):
Continued discussion in #189 and being handled in #190. Closing in favour of those.