mirror of
https://github.com/librespot-org/librespot.git
synced 2026-04-27 00:05:55 +03:00
[GH-ISSUE #185] --onevent documentation #127
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#127
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 @DavidM42 on GitHub (Mar 10, 2018).
Original GitHub issue: https://github.com/librespot-org/librespot/issues/185
The documentation describes how to use the apparently older --onstart and --onstop event handler but the help text and the project itself demand a --onevent handler.
Sorry for my Noob question but I couldn't find any info on how to use it in the wiki or anywhre else. I searched for it on the issue tracker,Google,.. but still got no results.
I know there is a help text but it's pretty shortly explained there.
So to break it down could you please instruct me how the explicit event type get's passed and I would be happy to try to update your wiki on this option.
@2pl commented on GitHub (Mar 10, 2018):
As far as I could test, you get passed a "start" or "stop" value through environment variable PLAYER_EVENT. So you need to test the value of PLAYER_EVENT in your script and decide the appropriate action.
@kingosticks commented on GitHub (Mar 10, 2018):
You can find the code in question at
github.com/librespot-org/librespot@aa880f8888/src/player_event_handler.rsand hopefully it's quite easy to follow. An updated wikipage would be great. We could also look at adding something (short) to the option's help text.@DavidM42 commented on GitHub (Mar 10, 2018):
Yeah thx for the quick help. I worked it out but it was a hard thing to do. I couldn't test for the environment variables because they were in the "raspotify" user account because I use that project which has librespot as it's core.
I'm now able to get the playback state in a python script which is the onevent handler. Sadly I still gave up for now because my plan to switch rc mains switches vía this script did not work for some damn reason I can't find.
Pain in the ass to get the permissions of files,gpio and everything else when It's run as service in another user account.
Update of the wikipage as well as the help text should not be that much work and it's pretty easy to use if it's standalone librespot.
I would like to help but I don't know if I undestand it enough for now to write an understandable explanation.
@madmodder123 commented on GitHub (Mar 11, 2018):
@DavidM42 Can you share the python code you use to grab the playback state? I am also using raspotify and I am trying to figure out a way to integrate Spotify functionality into my background music script.
Also... do you know if Raspotify uses this branch of librespot or the original one?
@michaelherger commented on GitHub (Mar 11, 2018):
This is the very basic shell script I used for testing:
I'm not a python guy, but the equivalent to
echo $TRACK_IDseems to be:The
OLD_TRACK_IDvariable would be set onchangeevents: when a new track is being played.@DavidM42 commented on GitHub (Mar 11, 2018):
@madmodder123 @michaelherger
Michael's info was totally correct aswell as his Python example but still here is my Python script.
(if you use raspotify keep in mind that the script needs to be executable for raspotify user. I am not very experienced with permissions so I gave it an unsafe chmod 777 rights so everyone can do everything)
@ComlOnline commented on GitHub (Mar 11, 2018):
@DavidM42 File permissons 755 should work fine here (owner has full read write execute, all others have read and execute permissions).
The wiki does need some work, Feel free to update bits where you can :)
@madmodder123 commented on GitHub (Mar 11, 2018):
@DavidM42 @michaelherger
I am decent at working with scripts but I have never had to deal with environmental variables, so for some reason I cannot figure out how to get either of these scripts to work.
I try to run them by doing the following...
But nothing gets displayed in the terminal.
I also tried this command to see if the variables are attached to the user:
sudo runuser -u raspotify 'printenv'But none of the relevant variables are displayed.
I feel stupid, and i'm sure it is something simple I am overlooking, help would be appreciated. :)
@michaelherger commented on GitHub (Mar 12, 2018):
Those environment variables are only exposed when one of the events is triggered. You don't run those scripts stand-alone, but tell librespot to call it when an event fires.
librespot --onevent /path/to/your/script.@madmodder123 commented on GitHub (Mar 13, 2018):
@michaelherger @DavidM42
Thanks, I knew it was something simple. Anyways I seem to have run into another problem.
When I start playing a song I look at the console output and it displays
Over and over...
Looking at my running processes it seems like librespot runs two processes and I imagine one of them is active and the other one isn't, which is causing this issue. Further proof of this is that I set the delay between each echo to 5s and like clockwork the echo messages come in pairs of start/stop.
I'm going to work with the code some more and figure out a way to only run the script once
@sashahilton00 commented on GitHub (Mar 22, 2018):
This is definitely an issue with the event system, as I'm seeing exactly the same thing when testing out #190. Will try and pinpoint what is causing it.