2

Good Evening, Gentlemen!

I successfully installed spotify-connect on my Raspberry Pi 1 B. I can start it as follows and it works well:

sudo /home/pi/spotify-connect-web.sh --username XXX --password XXX --bitrate 320 --name RaspberryPi --device 1

(--device 1 selects the USB sound card as output device.) My problem is that when I change the Volume of Spotify, spotify-connect changes the volume of the Raspberrys internal sound card instead of the USB sound card!

I've tried blacklisting the internal sound card, but then I get the following error: audio_arg_parser.add_argument('--mixer', '-m', help='alsa mixer name for volume control', default=alsa.mixers()[0]) I think it means that I have to specify the mixer via a --mixer argument, but everything I've tried failed.

Can somebody help me?

Thanks!

2

Solution:

I've solved my problem by simply using another (newer) implementation of librespot, the library behind spotify-connect-web. Here's a small how-to:

  • Make the USB sound card the default:

sudo nano /usr/share/alsa/alsa.conf

Change

defaults.ctl.card 0
defaults.pcm.card 0

to

defaults.ctl.card 1
defaults.pcm.card 1
  • Reboot.
  • Test whether sound works. speaker-test -c 2 -r 48000
  • Go to git/TheBigFatTony/librespot/releases, get the link to the newest zip file.
  • Download the thing. wget https://github.com/TheBigFatTony/librespot/releases/download/XXXX.XX.XX/librespot.zip
  • Unzip. unzip librespot.zip -d .
  • Now you can run and test it, and play around with the parameters. How it works for me: ./librespot --name RaspberryPi

Everything works now, including volume control. Additionally, this version of the library appears to be less buggy and more responsive.

Start automatically upon reboot:

Create a systemd-service (sudo nano /etc/systemd/system/librespot.service) with the following content:

[Unit]
Description=Librespot is an open source client library for Spotify.

[Service]
Type=simple
Restart=on-failure
RestartSec=10
TimeoutStartSec=15
User=pi
WorkingDirectory=/home/pi/
ExecStart=/home/pi/librespot --name RaspberryPi

[Install]
WantedBy=multi-user.target

Start the service and test whether it works:

sudo service librespot start

This command may be useful for debugging:

systemctl status librespot.service

Start the service automatically on bootup:

sudo systemctl enable librespot.service

Librespot updater script:

Put the following code into /home/pi/updater/updater.sh:

#! /bin/bash
echo "last time the updater was started: $(date +"%Y-%d-%m %H:%M")" > last_time_updater_was_started.txt
# get the link to the latest TheBigFatTony/librespot release
latest="$(curl -s https://api.github.com/repos/TheBigFatTony/librespot/releases/latest | grep browser_download_url | cut -d '"' -f 4)"
echo "latest: ${latest}"
# if unsuccessful curl OR empty var OR bad beginning OR bad ending...
if [[ ! $? -eq 0 ]] || [[ -z "$latest" ]] || [[ ! $latest == https://github.com/TheBigFatTony/librespot/releases/download/* ]] || [[ ! $latest == *.zip ]]; then
    echo "URL NOT FOUND OR BAD"
else
    echo "URL FOUND"
    # if there is an update...
    if [ "$latest" == "$(<current_version.txt)" ]; then
        echo "No new version found."
    else
        echo "New version found! Downloading..."
        # download update but install only if download successful.
        wget_output=$(wget -q --output-document=latest.zip "${latest}")
        if [ $? -eq 0 ]; then
            echo "Commencing update..."
            sudo service librespot stop
            unzip -o latest.zip -d /home/pi/
            chmod +x /home/pi/librespot
            sudo service librespot start
            echo -n "${latest}" > current_version.txt
            echo "last time an update was installed: $(date +"%Y-%m-%d %H:%M")" > last_time_an_upate_was_installed.txt
            echo "UPDATE COMPLETE"
        else
            echo "Download unsuccessful"
        fi
    fi
fi

Create a systemd-service (sudo nano /etc/systemd/system/libspotify-updater.service) with the following content:

[Unit]
Description=Updater for librespot.

[Service]
Type=simple
User=pi
WorkingDirectory=/home/pi/updater
ExecStart=/home/pi/updater/updater.sh

[Install]
WantedBy=multi-user.target

Create a systemd-timer (sudo nano /etc/systemd/system/libspotify-updater.timer) with the following content:

[Unit]
Description=An example timer

[Timer]
OnCalendar=*-*-* 04:00:00
# Optional
Persistent=true

[Install]
WantedBy=timers.target

Enable the service and the timer: systemctl enable libspotify-updater.timer, systemctl start libspotify-updater.timer, systemctl enable libspotify-updater.service, systemctl start libspotify-updater.service

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.