Skip to content

Instantly share code, notes, and snippets.

@prehensile
Last active March 8, 2020 20:55
Show Gist options
  • Save prehensile/c69c2575aedf12772982e53b30187984 to your computer and use it in GitHub Desktop.
Save prehensile/c69c2575aedf12772982e53b30187984 to your computer and use it in GitHub Desktop.
setting up a raspberry pi for streaming

Setting up a Raspberry Pi for use as an audio streamer

TODO

  • Automate setup of spotify in the browser (autofill login etc), probbaly using selenium -- This is probably needed in a caretaker process too, keep an eye on Spotify and reload if "something went wrong" message comes up
  • Implement exclusive playback between spotify / shairport: if one starts playing, the other stops
# run on host machine to prepare SD card
BOOT_VOLUME=/media/prehensile/boot
cp wpa_supplicant.conf $BOOT_VOLUME
touch $BOOT_VOLUME/ssh
cp stage-1.sh $BOOT_VOLUME
cp stage-2.sh $BOOT_VOLUME
## run this on pi to do some basic setup
sudo -s <<HEREDOC
# set screen resolution
sed -i 's/.*hdmi_mode=.*/hdmi_mode=16/' /boot/config.txt
sed -i 's/.*hdmi_group=.*/hdmi_group=2/' /boot/config.txt
# automate some config
raspi_config nonint do_hostname streampi
raspi-config nonint do_vnc 0
raspi-config nonint do_boot_behaviour B4
raspi-config nonint do_expand_rootfs
reboot
HEREDOC
## install & setup streaming software after first reboot
# run chromium when lxsession starts
mkdir -p ~/.config/lxsession/LXDE-pi
echo "@chromium-browser https://play.spotify.com" > ~/.config/lxsession/LXDE-pi/autostart
sudo -s <<HEREDOC
# install widevine plugin
# see https://blog.vpetkov.net/2019/07/12/netflix-and-spotify-on-a-raspberry-pi-4-with-latest-default-chromium/
cd /usr/lib/chromium-browser
wget http://blog.vpetkov.net/wp-content/uploads/2019/09/libwidevinecdm.so_.zip
unzip libwidevinecdm.so_.zip && chmod 755 libwidevinecdm.so
rm libwidevinecdm.so_.zip
# install shairport
sudo apt install shairport-sync
# reboot every night
echo "03 05 * * * reboot" | crontab
# reboot
reboot
HEREDOC
/boot: touch ssh, add wpa_supplicant
raspi-config:
- exapnd filesystem
- enable vnc
- set resolution
- set gui boot autologin
extract & install widevine plugin
- cf https://gist.github.com/ruario/19a28d98d29d34ec9b184c42e5f8bf29
- cf https://blog.vpetkov.net/2019/07/12/netflix-and-spotify-on-a-raspberry-pi-4-with-latest-default-chromium/
log in over vnc, load play.spotify.com in chromium. login.
set it as home
set pi to auto-login to desktop
set lxde to autostart chromium
- cf https://raspberrypi.stackexchange.com/questions/101733/raspberry-pi-4-autostart-chromium
set volume?
reboot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment