qqqr: QR code music player
Ever wished you had physical albums for all your cloud music? Tired of carrying a dozen milk crates full of vinyl records up and down stairs when you move?
qqqr is a Raspberry Pi Zero W project which uses ZBar and OpenCV to read paper QR code cards encoding Google Play Music track IDs and plays the songs over a Bluetooth speaker.
Project status: abandoned. Everything worked. But I found out that I can use the Spotify app to scan Spotify Codes, so I decided not to put more time into polishing qqqr.
Fair warning: if you go on an archaeological dig in the code, you'll see that I tried
mopidy for playback. I found that all of them took about 10 - 30 seconds to start playing from Google Play Music after the track ID was identified, whether streaming or pre-caching. I'm sure there's a solution but I didn't keep digging. My workaround solution was to use Spotify Connect for playback instead of local playback from Google Play Music.
Raspberry Pi config
Raspberry PI hardware RNG
(Fixes "getrandom() initialization failed" error)
sudo apt install rng-tools
Camera focal length adjustment
video stream preview (2-3 second lag)
raspivid -t 0 -l -o tcp://0.0.0.0:3333
focal length adjustment
(counter-clockwise is closer focal length)
OpenCV SD card image
SD card image with precompiled OpenCV binaries
Instructions for compiling OpenCV on Raspberry Pi. (Turned out this takes 24+ hours on Raspberry Pi Zero so I gave up and used the ROSbots SD card image above.)
QR code scanning
Pairing Bluetooth speaker
Reconnect Bluetooth speaker
bluetoothctl -a connect C0:28:8D:02:8D:8E quit
Play a test wav
aplay -D bluealsa:HCI=hci0,DEV=C0:28:8D:02:8D:8E,PROFILE=a2dp /usr/share/sounds/alsa/Front_Center.wav
pi@qqpi:~ $ cat .asoundrc defaults.bluealsa.interface "hci0" defaults.bluealsa.device "C0:28:8D:02:8D:8E" defaults.bluealsa.profile "a2dp"
Auto-connect Bluetooth speaker
streaming mp3 playback
Mopidy installation and playback
(no longer using Mopidy—see explanation at top of page)
sudo apt remove python-pip wget -q https://bootstrap.pypa.io/get-pip.py sudo python get-pip.py sudo apt-get install python-dev libxml2-dev libxslt1-dev zlib1g-dev sudo apt-get install python-lxml pip install mopidy-gmusic sudo pip install mopidy-gmusic --ignore-installed pyasn1 --ignore-installed lxml
pi@qqpi:~ $ vi ~/.config/mopidy/mopidy.conf [audio] #mixer = software #mixer_volume = output = alsasink device = bluealsa #buffer_time = [http] #enabled = true #hostname = 127.0.0.1 hostname = :: [local] #enabled = true #library = json media_dir = /home/pi/bluetooth_audio
control via mpd client
mpc add local:track:Untitled3.wav && mpc repeat && mpc play mpc ls 'Google Music/Albums/The Grateful Dead - 5-8-77' mpc add gmusic:track:7649c1b0-9499-36ef-bfe4-4f2a121ac08a && mpc play