pi rasplex and squeezelite

1 install rasplex

With standard method

2 install squeezelite

As described in this article, binary named squeezelite, saved in /storage/.plexht/userdata

3 install autoplay script

Modified from this article as I always want to start the auto playlist; saved as /storage/.plexht/userdata/squeezeliteAutostart.sh :

#! /bin/sh

###vars:
## the mac from your RPI/squeezelite session
playerID="b8:27:eb:a0:2f:9e"

## The Backup Playlist when the actual playlist is empty.
## The Path must be the exact path where your lms finds the playlist!
my_playlist="/media/Music/playlist/AutostartLounge.m3u"

## The IP from your LMS System
server=lms

## The CLI Port from your LMS
port=9090


## before doing anything - we want to know tha actual Facts about the Player 😉
playerstatus=$(printf "$playerID power ?\nexit\n" |nc $server $port|cut -d ' ' -f 3)

## Older squeezelite Versions answer with 0 and 1 when using power?
## Newer Versions answers with on/off!!

if [ $playerstatus = 1 ]
   then
   playerstatus=on
fi


if [ ! $playerstatus = on ]
   then
   echo "powering player on"
   printf "$playerID power 1\nexit\n"|nc $server $port
else
   echo "player was on already"
fi

## If the Player has a Playlist it should start the next Song...
# playermode=$(printf "$playerID mode ?\nexit\n" |nc $server $port|cut -d ' ' -f 3)
# if [ ! $playermode = play ]
#    then
#    echo "nothing to play"
#    echo "try to play players playlist"
#    printf "$playerID  play\nexit\n"|nc $server $latex port
#    sleep 2
#    playermode=$(printf "$playerID mode ?\nexit\n"|nc $server $port|cut -d ' ' -f 3)
#    if [ ! $playermode = play ]
#       then
      echo "no playlist loaded we play $my_playlist now"
      printf "$playerID playlist play $my_playlist\nexit\n"|nc $server $port
#    fi
# else
#    echo "playing"
# fi
exit 0#+end_src

and made executable by

#+begin_src sh 
chmod +x ./squeezeliteAutostart.sh

4 The autostart file

As described in this article, but simplified, to use USB dac and not hdmi

#!/bin/sh

# ALSA-SETUP
############
# Force Alsa output to HDMI (2=HDMI)
# amixer cset numid=3 2
# Set Alsa volume to 100%
# amixer cset numid=1 400

# SQUEEZELITE-SETUP
###################

/storage/.plexht/userdata/squeezelite -n "Lounge" -o "sysdefault:CARD=DAC" -a 5000 -z

/storage/.plexht/userdata/squeezeliteAutostart.sh
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s