Replies: 11 comments
-
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. |
Beta Was this translation helpful? Give feedback.
-
You can find the code in question at https://github.com/librespot-org/librespot/blob/aa880f8888226a8e5fc6e1e54dfb7cf58176ac95/src/player_event_handler.rs and 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. |
Beta Was this translation helpful? Give feedback.
-
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. 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. |
Beta Was this translation helpful? Give feedback.
-
@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. |
Beta Was this translation helpful? Give feedback.
-
This is the very basic shell script I used for testing:
I'm not a python guy, but the equivalent to
The |
Beta Was this translation helpful? Give feedback.
-
@madmodder123 @michaelherger import os
if os.environ['PLAYER_EVENT'] == "start":
os.system("/home/pi/raspberry-remote/send ***** 1 1")
elif os.environ['PLAYER_EVENT'] == "change":
os.system("/home/pi/raspberry-remote/send ***** 1 1")
elif os.environ['PLAYER_EVENT'] == "stop":
os.system("/home/pi/raspberry-remote/send ***** 1 0") |
Beta Was this translation helpful? Give feedback.
-
@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 :) |
Beta Was this translation helpful? Give feedback.
-
@DavidM42 @michaelherger
But nothing gets displayed in the terminal. I feel stupid, and i'm sure it is something simple I am overlooking, help would be appreciated. :) |
Beta Was this translation helpful? Give feedback.
-
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. |
Beta Was this translation helpful? Give feedback.
-
@michaelherger @DavidM42
Over and over... |
Beta Was this translation helpful? Give feedback.
-
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. |
Beta Was this translation helpful? Give feedback.
-
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.
Beta Was this translation helpful? Give feedback.
All reactions