dupontgu / retro-ipod-spotify-client

The software that powers the sPot: a 4th generation "Click Wheel" iPod with a full Spotify client.
Apache License 2.0
892 stars 90 forks source link

Can't play music (error no devices) #66

Closed XEROxMEXICANO closed 1 year ago

XEROxMEXICANO commented 1 year ago

Hello I've finally got Spot to auto start and a bunch of other problems fixed but when I try to play a song it gives me this error

"playing spotify:album:6Bp2ojsBc8CtNaYipdxCLt spotify:track:3ZcLmonVVD1MTQtmQb8yf3 error! no devices"

I saw in the Github issue #4 someone had this error but they fixed it so I applied the fix to mine and it didn't do anything. Got a solution or an idea?

doris1347 commented 1 year ago

Had any Luck Yet?

XEROxMEXICANO commented 1 year ago

Had any Luck Yet?

Nope

doris1347 commented 1 year ago

When I try to play a playlist or track it indexes 3 seconds and drops out to no devices (no audio) would you have any ideas?

XEROxMEXICANO commented 1 year ago

Having the same issue,currently just messing around with the code if I find a solution I'll post it here

XEROxMEXICANO commented 1 year ago

Hello @doris1347 I don't if you tried this but on step 12 when configuring raspotify it says comment and fill: OPTIONS="--username --password " where it says USERNAME and PASSWORD, did you try entering your username and password. I tried it and it didn't work am I suppose to leave "<>" those in or not I tried both and none worked.

doris1347 commented 1 year ago

No Do Not Leave Them In you must delete them!!! "<>"

Yes, when I was using a Zero version 1w I tried step 12 and issue #4 with negative results - I'm now using a Zero 2w which has a different config file due to the upgraded (Raspotify/librespot) "/etc/default/raspotify" doesn't exist in versions after 0.31.3. The Zero 2W boots up really fast however poor on power consumption!

https://developer.spotify.com/documentation/web-api/reference/#/operations/transfer-a-users-playback

Perhaps the above?

https://community.spotify.com/t5/Spotify-for-Developers/active-a-playback-device-with-API/td-p/4963267

Obtaining "device id"

XEROxMEXICANO commented 1 year ago

Sorry I've been a little busy today. Thank you so much for the new information and the links I think just from reading the articles I have an idea that could possibly solve this issue (.01% my idea works). I'll have ti try it when I get home.

XEROxMEXICANO commented 1 year ago

Sorry I've been a little busy today. Thank you so much for the new information and the links I think just from reading the articles I have an idea that could possibly solve this issue (.01% my idea works). I'll have ti try it when I get home.

doris1347 commented 1 year ago

Perhaps it's a router/firewall issue? 🤔

XEROxMEXICANO commented 1 year ago

I don't think it could be that, I think it could be that the dependencies were updated and this github isn't up to date on it.

doris1347 commented 1 year ago

Hmmm ... Interesting! Now that gives me an iDea! However I think it's the "Spot App." that's not up to date on it (incompatible with Bullseye & Raspotify versions above 0.31.8).

XEROxMEXICANO commented 1 year ago

My idea failed, I tried all possible ideas and just can't think of anything. I think im going to take a break from this project and I'll come back to this project some other time. Thank you so much for the information and your help, you've been amazing.

XEROxMEXICANO commented 1 year ago

Nope never seen this, im going to try it out right now

XEROxMEXICANO commented 1 year ago

No I've never tried that, but I did put the device id of the ipod itself in line 282 device id = "1234" in Spotify_manager and when I selected a song on the ipod it loaded the song name on the now playing screen and played for 3 seconds no audio unfortunately.

XEROxMEXICANO commented 1 year ago

Thanks for the information I will certainly try this out once I'm home. If you have any trouble with the bluetooth try this it helped me a lot: https://github.com/bablokb/pi-btaudio

And if your Bluetooth speaker isn't connecting at all try this command it helped me: sudo apt-get install pulseaudio pulseaudio-module-bluetooth

and to test it out just load an mp3 file in it and download a mp3 player to test it (for mp3 player I used mpg123 here is a way to install it)

sudo apt-get update sudo apt-get install mpg123 mpg123 your-music.mp3

doris1347 commented 1 year ago

Thanks! ... for the command line mp3 player

Here's The Solution:

I'm now using the desktop version of Legacy Raspberry PiOs Buster v.10 & Raspotify 14.0 on my Zero 2W ... Issue Solved!!! The Zero 2W boots up really fast however poor on power consuption!

Good idea your considering Retro - Dependency.

XEROxMEXICANO commented 1 year ago

Congratulations on solving the issue!! I can't wait to try it once I'm home. Thank you so much for helping me and guiding me, couldn't have done this without you.

doris1347 commented 1 year ago

The latest is that it does work! You must have a Spotify Premium Account!!! Use Raspberry OS imager to image Legacy Buster 10 & download and install Raspotify 14.0 everything works as Stand-Alone!! ---- Raspotify 15.0 or 16.0 probably will work as well, however for me 0.14.0 worked best ... nothing higher worked for me the config file at "/etc/default/raspotify" doesn't exist in versions after 0.31.3.

The config file at /etc/default/raspotify does exist in v. 14.0, 15.0 and 16.

If you get a “PIL” error do the below: sudo apt-get install python3-pil python3-pil.imagetk

File "spotifypod.py", line 13, in from PIL import ImageTK, Image ImportError: cannot import name 'ImageTK' from 'PIL' (/usr/lib/python3/dist-packages/PIL/init.py

It might be necessary to delete pycache from the frontend folder and reboot to make everything work ( rm -r pycache ) it will be recreated automatically upon rebooting.

Note: From Spotify "A Device ID is unique and persistent to some extent (and for some clients). However, this is not guaranteed and any cached device_id should periodically be cleared out and re-fetched as necessary."

Note: You will need "bluealsa" (Alsa with Bluetooth) to be operational for Bluetooth audio in this older version. (This part is tricky however do-able)! Note: bluealsa does not play mp3 files!

You must have bluealsa installed and configured correctly for Bluetooth Audio and the SpoT to work! (see below links): https://sigmdel.ca/michel/ha/rpi/bluetooth_n_buster_01_en.html https://sigmdel.ca/michel/ha/rpi/bluetooth_in_rpios_02_en.html

pulseaudio needs to be disabled not removed!

Check with: sudo systemctl status pulseaudio

XEROxMEXICANO commented 1 year ago

Thank you, right now I got some free time and will try it out your way, again thank you so much couldn't have gotten this far without you!

doris1347 commented 1 year ago

Your Welcome: - I think eventually the "Spot Program's" Python code will probably need to be re-written using latest Python so it can be compatible with the latest versions of Raspberry pi OS (Bullseye) and the latest versions of Raspotify.

rsappia commented 1 year ago

Hi guys, not sure if this was already discussed but this issue looks like the one I had at the very beginning and it was solved by going premium on Spotify. I had my set up running for the last 1.5 years with no issues... Let me know if you want .e to share any part of the code or set up i have running ;)

doris1347 commented 1 year ago

Hi Ricardo!!! ... I have and always have had a Premium account ... I read your article very nice. When you boot your "Spot" is it ready to play tracks or do you need to first need to with your cellphone/computer to Select the "Spot" ... and is that selecting at times difficult?

I am using the 2.0' Adafruit screen. and the Latest Pi Zero 2W running 32bit Raspbian10 Buster & 32bit Raspotify 0.14.0. the problems occurred with the original Zero W as well ... The Zero 2W boots up really fast poor on power consumption.

My "Spot" is working now and with Bluetooth audio using older Raspbian Legacy Buster 10 desktop version and older Raspotify 14.0 newer versions wouldn't work for me probably due to new Python code. however, 0.15.0 & 0.16.0 probably would work as well.

Thanking Guy & Yourself! - for all your hard work!

doris1347 commented 1 year ago

Guy, Ricardo and others had to be using Raspberry PiOs Buster 10 and Raspotify 14, ... 15 or 16 since they originally did their builds over 1.5 years ago the same versions that I'm using now that works!

They were all busy building their "Spots" and (refining the install instructions) around Jan - March of 2021 when Raspotify 16.0 would have been current Buster 10 as well. Things broke in November of the same year with the updates, so anyone building the "Spot" after October 2021 would have problems that so many of us had the only plays for 3 seconds, no devices and no bluetooth audio issue since we were all attempting to install on Bullseye 11 and Raspotify v.0.31.1 or higher.

XEROxMEXICANO commented 1 year ago

Thanks for the info, Yeah I installed Rasbian buster lite with raspotify 14.0 I was to get it to run but I still have the problem that it won't play music individually and wont output audio. In your previous post I noticed you said "Had to use my e-mail address instead of the 7 digit number for user id in /etc/default/rasspotify which does exist in v. 14.0." What did you mean by that?

edit: Do I have to use Pi os buster desktop?

XEROxMEXICANO commented 1 year ago

Correct I am using a pi zero w, When i select a song using raspotify nothing plays. Yes the audio does work i tested it using a mp3 file.

rsappia commented 1 year ago

Hi Ricardo !!! ... I have and always have had a Premium account ... I read your article ... Guy and Yourself are Geniuses !

1. May I ask which version of Rasberry Pi OS and Raspotify your using?

2. Do you ever have trouble selecting your ({["Spot" as a (is_active)"]}=True) device? ;)

3. When you boot your "Spot" is it ready to play tracks or do you need to first be logged in to your Spotify app. with your cellphone or PC and then Select the "Spot" ... is that selecting at times difficult?

4. If you would be willing to share the "Low Battery signal code" and would be willing to explain how and where to define an internal pull-up/down resistor  in the code that would be great.

I am using the 2.0' Adafruit screen. and the Latest Pi Zero 2W running 32bit OS & 32bit Raspotify. the problems occurred with the original Zero W as well.

My "Spot" is working now using older PiOS Legacy Buster 10 desktop version and older Raspotify 14.0 newer versions wouldn't work for me probably due to new Python code could you remember which your using & did you upgrade to Pi OS Bullseye 11 and 0.42.6 Raspotify circa November/2021?

Thanking Guy & You! - so much for all your hard work! and your offer for assistance.

Hi there, sorry for the delay.

  1. May I ask which version of Rasberry Pi OS and Raspotify your using? I am running Raspbian GNU/Linux 10 (buster) and raspotify/unknown,now 0.16.0~librespot.v0.1.3-37-g0adb851 armhf

  2. Do you ever have trouble selecting your ({["Spot" as a (is_active)"]}=True) device? ;) Can you elaborate on that? It has been a while since I played around with the code and I am not sure about what part are you referring to

  3. When you boot your "Spot" is it ready to play tracks or do you need to first be logged in to your Spotify app. with your cellphone or PC and then Select the "Spot" ... is that selecting at times difficult? I don't need to be loged on to my Spotify app, I just turn it on, and is ready to go :). On the other hand, I can see that my Spot is listed as a device if I open the cellphone app.

  4. If you would be willing to share the "Low Battery signal code" and would be willing to explain how and where to define an internal pull-up/down resistor in the code that would be great. I am not sure if I actually fully implemented this function, I need to double-check on the code and come back later to you ;)

XEROxMEXICANO commented 1 year ago

Right now I've been busy and haven't had time to apply the fixes. I might have time later today, But if you were able to get it working then I should be able to.

XEROxMEXICANO commented 1 year ago

I'm still having issues with playing audio. No audio comes from the pi with Bluetooth speaker, and when I click on a song on the pi it will give me an error no devices

doris1347 commented 1 year ago

To attempt a fix for: "when I click on a song on the pi it will give me an error no devices": 1) You must have a Spotify Premium Account!!! 2) ssh into your Pi or connect a monitor & keyboard/mouse. 3) Type the command "sudo systemctl status raspotify" (without the quotes) then press enter. Post a screenshot of your results.

To attempt a fix for: "No audio comes from the pi with Bluetooth speaker": 1) You must have bluealsa installed and configured correctly for Bluetooth Audio to work. (see below links): https://sigmdel.ca/michel/ha/rpi/bluetooth_n_buster_01_en.html

https://sigmdel.ca/michel/ha/rpi/bluetooth_in_rpios_02_en.html 2) ssh into your Pi or connect a monitor & keyboard/mouse. 3) Type the command "sudo systemctl status bluealsa" (without the quotes) then press enter. Post a screenshot of your results.

Note: PulseAudio should be removed!!!

Note: You will need "bluealsa" (Alsa with Bluetooth) to be operational for Bluetooth audio in this older version. (This part is tricky however do-able).

Note: bluealsa does not play .mp3 files!

Test bluealsa with a .wav file! Once installed & configured - Change to the directory that includes your .wav files example: "aplay -D bluealsa MAIN.WAV" (Capitals). (without the quotes) then press enter.

Should you decide to post or "pm" me your two screenshot results then based on those results I should be able to suggest corrective actions.

Below my bluealsa screenshot:

pi@Raspotify:~$ sudo systemctl status bluealsa

Dec 02 22:40:15 Raspotify systemd[1]: Started BluezALSA proxy.

XEROxMEXICANO commented 1 year ago

pi@raspberrypi:~$ sudo systemctl status raspotify ● raspotify.service - Raspotify Loaded: loaded (/lib/systemd/system/raspotify.service; enabled; vendor preset: enabled) Active: activating (auto-restart) (Result: exit-code) since Sun 2022-12-04 00:57:50 PST; 410ms ago Process: 1548 ExecStartPre=/bin/mkdir -m 0755 -p /var/cache/raspotify (code=exited, status=0/SUCCESS) Process: 1549 ExecStartPre=/bin/chown raspotify:raspotify /var/cache/raspotify (code=exited, status=0/SUCCESS) Process: 1550 ExecStart=/usr/bin/librespot --name ${DEVICE_NAME} $BACKEND_ARGS --bitrate ${BITRATE} $CACHE_ARGS $VOLUME_ARGS $OPTIONS (code=exited, status=101) Main PID: 1550 (code=exited, status=101)

Dec 04 00:57:50 raspberrypi librespot[1550]: at src/libstd/panicking.rs:270 Dec 04 00:57:50 raspberrypi librespot[1550]: 32: 0x9bd484 - std::panic::catch_unwind::ha972c7f8a413a94c Dec 04 00:57:50 raspberrypi librespot[1550]: at src/libstd/panic.rs:394 Dec 04 00:57:50 raspberrypi librespot[1550]: 33: 0x9bd484 - std::rt::lang_start_internal::hdf6cc497202d2594 Dec 04 00:57:50 raspberrypi librespot[1550]: at src/libstd/rt.rs:51 Dec 04 00:57:50 raspberrypi librespot[1550]: 34: 0x4f4dc4 - main Dec 04 00:57:50 raspberrypi librespot[1550]: 35: 0xb6cb7718 - __libc_start_main Dec 04 00:57:50 raspberrypi systemd[1]: raspotify.service: Main process exited, code=exited, status=101/n/a Dec 04 00:57:50 raspberrypi systemd[1]: raspotify.service: Failed with result 'exit-code'.

pi@raspberrypi:~$ sudo systemctl status bluealsa ● bluealsa.service - BluezALSA proxy Loaded: loaded (/lib/systemd/system/bluealsa.service; static; vendor preset: enabled) Active: active (running) since Sun 2022-12-04 08:40:15 GMT; 13min ago Main PID: 389 (bluealsa) Tasks: 3 (limit: 877) CGroup: /system.slice/bluealsa.service └─389 /usr/bin/bluealsa -p a2dp-source -p a2dp-sink

Dec 04 08:40:15 raspberrypi systemd[1]: Started BluezALSA proxy.

doris1347 commented 1 year ago

Good Morning, ... I need to ask you a few questions:

1) Do you have a Spotify Premium Account? 2) Were you successful at generating your Authentication .cache file? 3) Were you ever able to play a song even though you had no audio (example: - time lapse counter incremented all the way to the end of the song and not just freeze at 3 seconds)?

doris1347 commented 1 year ago

The below happens to me as well until I can successfully use my cellphone's or computer's Spotify app. to select my "Spot" which is named "Raspotify" to authenticate, once selected successfully I get authenticated, and all works properly, I can then close the Spotify app!

pi@Raspotify:~$ sudo systemctl status raspotify

The Below is what I get once I am successful at authenticating by using my Cellphone Spotify app. (This usually takes many attempts and it's best to wait awhile after a failed attempt.

pi@Raspotify:~$ sudo systemctl status raspotify

Dec 04 22:48:11 Raspotify systemd[1]: Started Raspotify. Dec 04 22:48:11 Raspotify librespot[786]: [2022-12-05T03:48:11Z INFO librespot] librespot (raspotify v0.14.0) 3672214 (2020-01-30). Built on 2020-02-16. Build ID: 7pZDdYUK Dec 04 22:48:12 Raspotify librespot[786]: [2022-12-05T03:48:12Z INFO librespot_core::session] Connecting to AP "ap-gue1.spotify.com:4070" Dec 04 22:48:12 Raspotify librespot[786]: [2022-12-05T03:48:12Z ERROR librespot] Could not connect to server: bytes remaining on stream Dec 04 22:51:20 Raspotify librespot[786]: [2022-12-05T03:51:20Z INFO librespot_core::session] Connecting to AP "ap-gue1.spotify.com:4070" Dec 04 22:51:20 Raspotify librespot[786]: [2022-12-05T03:51:20Z INFO librespot_core::session] Authenticated as "XXXXXXXXX" ! Dec 04 22:51:20 Raspotify librespot[786]: [2022-12-05T03:51:20Z INFO librespot_playback::audio_backend::alsa] Using alsa sink Dec 04 22:51:20 Raspotify librespot[786]: [2022-12-05T03:51:20Z INFO librespot_core::session] Country: "US" Dec 04 22:51:21 Raspotify librespot[786]: [2022-12-05T03:51:21Z INFO librespot_playback::player] Loading with Spotify URI Dec 04 22:51:22 Raspotify librespot[786]: [2022-12-05T03:51:22Z INFO librespot_playback::player] loaded

doris1347 commented 1 year ago

a) There is a configuration file in bluealsa that needs to be properly configured ... configure it to startup on boot as well. b) Pulseaudio needs to be removed from being your default blutooth driver. Note: The two links I posted, and the one below has everything you should need to accomplish the above

XEROxMEXICANO commented 1 year ago

Good morning, yes I was able to play a .wav file through a speaker and yes I do have a premium account, I was also successful on generating the cache files, and no I never got it to play it wouldn't go in increments it would stay at 0. Thank you for the instructions I make sure to follow them in a little bit.

doris1347 commented 1 year ago

Were you ever able to play a Spotify song track even though you had no audio (example: - time lapse counter incremented all the way to the end of the song and not just freeze at 3 seconds)?

XEROxMEXICANO commented 1 year ago

No When I click a song the bar stays in the middle and the time lapse counter stays at zero

doris1347 commented 1 year ago

That's because you were never authenticated by using your cellphone or computer's Spotify app. You have to make that happen its trial and error be patient!

XEROxMEXICANO commented 1 year ago

How do I authenticate it using my computer or phone?

doris1347 commented 1 year ago

Can you see your "Spot" in the Spotify's app. Device list?

XEROxMEXICANO commented 1 year ago

Yes I do see it on the list

doris1347 commented 1 year ago

When I select my "Spot" that's on the device list if it fails to connect sometimes I have to wait a half hour before I try again to finally succeed!!!

That's how you authenticate.

doris1347 commented 1 year ago

While waiting keep checking by using sudo systemctl status raspotify in terminal then when you see a change in the status of raspotify retry selecting from the Spotify apps. Device list !!!

If it fails keep trying starting from the beginning.

doris1347 commented 1 year ago

Sometimes I do a systemctl start raspotify and wait before trying the above procedure.

There are several iterations : systemctl status raspotify

systemctl start raspotify

systemctl restart raspotify

systemctl stop raspotify

I don't understand why we have to go through this, my guess is Spotify tries to discourage unofficial Spotify Connect devices.

As long as all else in your etc/default/raspotify config file is correct and the name in your developer app matches exactly the name in the config file, all you can do is keep trying

Try inputting your device ID in client.py of Spotipy and Spotify_manager.py files.

XEROxMEXICANO commented 1 year ago

yeah I will try it in a minute im going to wait 3-5 minutes till i try to connect it

XEROxMEXICANO commented 1 year ago

Yes I was able to select the pi from the device list

XEROxMEXICANO commented 1 year ago

what do you mean by the name of the developer app matches the name in the config file? and by the way what raspotify version are you using? I'm using 14 Also where do I put my device id in the spotify_manager.py file?

doris1347 commented 1 year ago

Where you received your client ID and Client Secret, you then had to provide a name for your developer app. (See Below link):

https://developer.spotify.com/dashboard/applications/

I am using Raspotify version 0.14.0 and Raspbian GNU/Linux 10 Legacy Buster .

Let me check the file line numbers I will get back to you shortly

XEROxMEXICANO commented 1 year ago

Yeah I'd like to thank you for helping me out sorry if I caused any problems, I'm not super experienced in raspberry pis

doris1347 commented 1 year ago

Spotify_Manager.py - Line 179 ... I used the issue #41 suggested fix! cd /home/pi/retro-ipod-spotify-client/frontend/ nano spotify_manager.py

def refresh_devices(): device = UserDevice('xxxxxxxxxxxxxxxxxxxxxxxxxxxxx','raspotify', True) DATASTORE.setUserDevice(device)

client.py of Spotipy - Line 1726 cd .local/lib/python3.7/site-packages/spotipy/ nano client.py

    data = {"device_ids": ["xxxxxxxxxxxxxxxxxxxxxxxxxx"], "play": force_play}
    return self._put("me/player", payload=data)

Where "xxxxxxxxxxxxxxxx" is the device ID

For device ID: You have to be logged-in to the Developer Dashboard Console then Click get token then copy all the terminal information in the lower black box then paste that into you computer's terminal and press enter

Cheers!

XEROxMEXICANO commented 1 year ago

Im trying to get my device id but it isn't showing up https://developer.spotify.com/console/get-users-available-devices/

Nevermind it showed up after reboot