Skip to content

chrisongthb/musicpi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

musicpi

Headless Music Jukebox

What?

This is a step by step guide to install raspotify on a rasperry pi (or in my case a antique bananapi).

The killer feature is that you can use a left over (wireless) mouse to control the volume and to stop the spotify playback.

Why?

I have my bananapi already running with Ubuntu Server 16.04 for some other reasons, so I could not use the pre installed image of pimusicbox.

Future plans?

  • install mopidy next to raspotify
  • stop each other playback automatically
  • multiroom feature, maybe with snapcast

How?

Install Raspotify and Alsa

important: it works only, if pulseaudio is not installed.

sudo apt install -y apt-transport-https curl
curl -sSL https://dtcooper.github.io/raspotify/key.asc | sudo apt-key add -v -
echo 'deb https://dtcooper.github.io/raspotify raspotify main' | sudo tee /etc/apt/sources.list.d/raspotify.list
sudo apt update
sudo apt install raspotify alsa-utils

Configure Raspotify

Configure params for raspotify in /etc/default/raspotify. I use a good USB sound card, as the built-in sound card on the bananapi is very bad.

Get your device number with sudo aplay -l. The syntax beneath is --device hw:<card>,<device>:

DEVICE_NAME="BananaPi"
BITRATE="320"
OPTIONS="--device hw:1,0"
VOLUME_ARGS="--linear-volume --initial-volume=100"
BACKEND_ARGS="--backend alsa"

Now (re)start raspotify:

sudo systemctl restart raspotify

And connect your device!

If you have problems getting sound working, see here, here or even here

spotify connect android screenshot

Configure your mouse as media remote

First we plug a mouse to your pi. Then we need to install the stone-age software gpm and setup the event listener. Mind, that we cannot parse mouse wheel events with gpm (wheel up + down have the same event IDs). The left button will lower the volume, the right one raises the volume. The middle click (on the mouse wheel) will stop the playback (restart raspotify).

sudo apt install gpm
sudo curl -o /usr/local/sbin/gpm_spotify_media_control https://raw.githubusercontent.com/chrisongthb/musicpi/master/resources/gpm_spotify_media_control
sudo curl -o /etc/systemd/system/gpm_spotify_media_control.service https://raw.githubusercontent.com/chrisongthb/musicpi/master/resources/gpm_spotify_media_control.service
sudo systemctl daemon-reload
sudo systemctl enable gpm_spotify_media_control.service
sudo systemctl start gpm_spotify_media_control.service
sudo systemctl enable gpm

Now you're done!

picture of remote control mouse

Maybe you want to...

Check setup

  • sudo systemctl is-enabled gpm raspotify gpm_spotify_media_control should print enabled three (!) times.
  • The command sudo systemctl status gpm_spotify_media_control.service should notice "active // running" and
  • sudo journalctl -fu gpm_spotify_media_control should show you what is going on with your mouse, if you click one of the three configured buttons.
  • You may also watch the volume (changes) with sudo alsamixer.

Releases

No releases published

Packages

No packages published

Languages