More progress on the music player for the kids
Slightly simplified the music player for the kids has two jobs:
- Scan for QR codes using the camera and identify the ones that contains a Spotify URI (using
zbarcam
) and - send that URI to the MPD that plays the music from Spotify.
At the moment I am able to set up separate tests for the two jobs and both works, on there own. The problem is that I’m currently not able to set up MPD with Spotify and the zbar
tools at the same time. It seems to have something to do with different operating systems and/or other kinds of conflicting requirements that I need to lock into.
For the tests right now, I use standard Raspbian plus zbar
for bullet point number one and Pi MusicBox for point number two.
For my own memories sake, this is the very simple (and probably quite brittle) shell script that I’m using for bullet point 1:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
#!/bin/bash # Start scanning for QR Codes # Use either of the lines below depending on wheter it's running in an # environment where it can show a live preview or not. zbarcam /dev/video0 --nodisplay | while read line ; do # zbarcam /dev/video0 | while read line ; do # When something is found, verify that it indeed is a QR Code IFS=':' read -r id string <<< "$line" if test $id == "QR-Code" then # Check if it is a Spotify URI IFS=':' read -r id theRest <<< "$string" if test $id == "spotify" then echo "Run this: mpc -h musicbox.local play $string" fi fi done |
Replies and comments
Henrik Carlsson
26 juli, 2019 01:54Henrik Carlsson mentioned this note on blog.henrikcarlsson.se.