Open Shogan opened 3 years ago
When I built this, I didn't really think people would actually be trying to run it lol. I'm stoked to hear it hasn't been a complete failure. Thanks for reaching out!
I consciously chose to have the play/pause button only affect whatever's currently playing, reserving the center button for selecting something new. I though this was how the original ipod worked, but I forgot to test it before I ripped it apart.
Keycodes make sense, they seem to be different on every platform. Will add notes about scopes to docs, at some point. The biggest point of friction I found once I integrated with the pi is dealing with Openbox / getting things to launch automatically. If you (or anyone else) know of a clean way to get that done and documented, I would be all ears. I don't even remember how I did most of it admittedly.
ALSO! If you're interested, here's the font. You should just have to install it like you would any system font.
When I built this, I didn't really think people would actually be trying to run it lol. I'm stoked to hear it hasn't been a complete failure. Thanks for reaching out!
I consciously chose to have the play/pause button only affect whatever's currently playing, reserving the center button for selecting something new. I though this was how the original ipod worked, but I forgot to test it before I ripped it apart.
Keycodes make sense, they seem to be different on every platform. Will add notes about scopes to docs, at some point. The biggest point of friction I found once I integrated with the pi is dealing with Openbox / getting things to launch automatically. If you (or anyone else) know of a clean way to get that done and documented, I would be all ears. I don't even remember how I did most of it admittedly.
ALSO! If you're interested, here's the font. You should just have to install it like you would any system font.
Thanks for the insight, that helped me dig into this a bit.
After going through the code (and re-familiarising myself with Python as I haven't touched it in a few years now!), I found the issue I had:
KEYS *
command and sure enough no device:* keys were being saved.refresh_devices()
call in spotify_manager.py at start up to look up devices from the API.refresh_devices()
shows that a specific check for the string "Spotifypod" is done before saving - this must be what raspotify names the connect device? As I'm running on desktop/locally before actually putting onto a Pi Zero my connect device is named after my desktop / workstation hostname.So the fix was simply adding an else statement here to save the device to redis and set device
if it is not "Spotifypod" ๐
Full refresh_devices() function:
def refresh_devices():
results = sp.devices()
print("spotify refresh devices found results:", results)
DATASTORE.clearDevices()
for _, item in enumerate(results['devices']):
if "Spotifypod" in item['name']:
print(item['name'])
device = UserDevice(item['id'], item['name'], item['is_active'])
DATASTORE.setUserDevice(device)
else:
print(item['name'])
device = UserDevice(item['id'], item['name'], item['is_active'])
DATASTORE.setUserDevice(device)
Also, big thanks for the link to that font! That is awesome. Really brings back memories.
I'll probably push some of my findings and updates to a fork repo, so let me know if any of this will be useful to bring back as a PR here.
Also feel free to close this issue - I'm sure those who need help with this particular use case will find it.
Cheers!
Ah right! Spotifypod is what I named my Raspotify instance. Not gonna be the same for everyone. I think Raspotify literally defaults to "raspotify". So ideally that would be an environment variable.
Also - you probably discovered this by now, but there is a refresh_data()
function that pulls all user data from Spotify as well. I am not calling that anywhere from the code - I would SSH in to the pi and do it whenever I felt I needed to because it takes a loooong time. Just a heads up.
Ah right! Spotifypod is what I named my Raspotify instance. Not gonna be the same for everyone. I think Raspotify literally defaults to "raspotify". So ideally that would be an environment variable.
Also - you probably discovered this by now, but there is a
refresh_data()
function that pulls all user data from Spotify as well. I am not calling that anywhere from the code - I would SSH in to the pi and do it whenever I felt I needed to because it takes a loooong time. Just a heads up.
Got it!
I hadn't looked at refresh_data()
yet so thanks for that, you saved me a bit of digging there! I was wondering why I could only see a few random bits and pieces and no albums or artists! Good call on only doing that once in a while with a SSH session.
In my case, no devices will be recognized by spotipy, unless my cell phone is running spotify.. I also cannot see any artist or select any new song to play. All I can do is only play or pause the "Now playing" track that was sele @Shogan @dupontgu do you guys have any clue what could I be missing?
Edit: I solved the "issue" of no playlist or artist data being shown by running refresh_data(). Still having the problem, that I can play tracks only when I am logged in my cellphone or pc :/
Thanks for the comments about refresh_data, I was able to get my spotify playlists to display and play in the UI.
Maybe a dumb question, but I was wondering how you actually added the spotifypod as a device to your spotify account. I can select and play songs through the spotipypod UI, but they play on my other devices (like my phone or car). Looking at my debugger, spotify doesn't have my raspberry pi as a device in sp.devices().
@grr5510 after pairing your zero with your bluetooth speaker, go to spotify settings/devices and there you should see your zero listed.. select it and now your zero will work as speaker :)
The only one thing I still havebt figured out is how to use the zero as standalone device. If there is no other device logged and running spotify (like cellphone or pc) there is no way to play music feom the zero... or at least that has been my experience so far :/
You have to have raspotify running for it to appear in your instance of spotify as a connected speaker. When it is running, and if you have not changed its configs, it will appear on the devices on the same network with the name raspotify, if I'm not mistaken. In raspotify's configs you can define a different name for the instance, and your spotify's username and password for it to connect to your account and be availble everywhere. For this project to connect to that raspotify instance the name you set on the configs must be in the method that @Shogan showed here
def refresh_devices(): results = sp.devices() print("spotify refresh devices found results:", results) DATASTORE.clearDevices() for _, item in enumerate(results['devices']): if "Spotifypod" in item['name']: print(item['name']) device = UserDevice(item['id'], item['name'], item['is_active']) DATASTORE.setUserDevice(device) else: print(item['name']) device = UserDevice(item['id'], item['name'], item['is_active']) DATASTORE.setUserDevice(device)
Just change the "Spotifypod" name to whatever you set.
If you need help configuring raspotify, their github has all the steps you need to put it to work!
https://github.com/dtcooper/raspotify
Hope it helped
@ElCapitanDre found the guilty guy!! it was me! haha. I forgot to uncomment the user /pwd line in the raspotify config file ๐.
I have now a fully functional SpotIpod ๐
error! no devices
i still get this error - even applying the fix above?!
playing spotify:playlist:29PsqPqwo71yUQzyaryJOf spotify:track:05FgZdqxXg40X0WG8MmWMA error! no devices
i changed this code as per the fix above
def refreshdevices(): results = sp.devices() DATASTORE.clearDevices() for , item in enumerate(results['devices']): if "ipod" in item['name']: print(item['name']) device = UserDevice(item['id'], item['name'], item['is_active']) DATASTORE.setUserDevice(device) else: print(item['name']) device = UserDevice(item['id'], item['name'], item['is_active']) DATASTORE.setUserDevice(device)
my raspotify is working ok - the name of the device is 'ipod' and i can see it in Spotify Connect i can play music via the iphone to this Pi device for example
but when i navigate the content via VNC player - and attempt to play a song i get the screen attached here - and the error "error! no devices" in the terminal view
What a great project. I saw it featured on hackaday and have got it mostly setup and running locally (on my PC running uBuntu 20.04 via WSL2 in Windows).
When browsing playlist tracks, are you supposed to be able to hit the "play/pause" button a track (or hit next on the track item) to start playing that instead of whatever is currently playing?
When I do this nothing happens, it just pushes in the Now Playing view and the existing track that is currently playing will just continue. See GIF for demonstration of what I mean:
Example GIF
Just wondering if this is expected, or if it is indeed meant to start playing the selected track? I'm not using Raspotify as a Connect Device as I'm running local on my desktop for now. Just a standard Spotify Windows App (also tried with spotify web player), but I'm not sure if this should make a difference or not.
BTW, a couple of things I found along the way that might trip up others:
xev
to test what codes were used for my directional arrows and P / N which I assigned to previous/next.I have some hardware on order and will attempt a full build once it arrives :]
Thanks!