Howto: StreamTuner2 + MPD

Share your own howto's etc. Not for support questions!

Howto: StreamTuner2 + MPD

Postby bester69 » 2016-07-15 23:56

Image
subir imagenes




mpd-player.sh
-->>Toggle play/stop song by pressing Streamtuner "play button"<<--
Code: Select all
#!/bin/bash
#
MYHOST='192.168.1.128' # or your MPD host

touch ~/.mpd/flag
touch ~/.mpd/song
A=$(cat ~/.mpd/flag)
ANT=$(cat ~/.mpd/song)
mpc clearerror
killall  mpc &
killall  mpd &
killall  -9 mpc &
killall  -9 mpd &
mpd
mpd

#echo $1 > ~/fich.txt
case "$1" in
*m3u*) OPT="m3u" ;; # Para SurfMusci Tab
*pls*) OPT="m3u" ;; # Para Shoutcast tab
*  ) OPT="gener";;
esac
 
#Pinta la opción escogida 
#echo $OPT > ~/fich.txt;echo "$1" >> ~/fich.txt;echo "$2" >> ~/fich.txt
 
 
if [ "$A" = "1" ]
  then
 
 
 if [ "$OPT" = "m3u" ]
  then
    mpc -h $MYHOST load $1
    index=$(mpc -h $MYHOST playlist|wc -l)
    mpc -h $MYHOST play $index
     
  else
    mpc -h $MYHOST add $1
    index=$(mpc -h $MYHOST playlist|wc -l)
    mpc -h $MYHOST play $index
  fi
 
   
  ACT=$(mpc -h $MYHOST current)
  mpc -h $MYHOST stop
  if [ "$ACT" = "$ANT" ]
    then
      echo "0" > ~/.mpd/flag
      mpc stop   
     
     else
   
 
 
 if [ "$OPT" = "m3u" ]
  then
    mpc -h $MYHOST load $1
    index=$(mpc -h $MYHOST playlist|wc -l)
    mpc -h $MYHOST play $index
   
     
  else
    mpc -h $MYHOST add $1
    index=$(mpc -h $MYHOST playlist|wc -l)
    mpc -h $MYHOST play $index
   
  fi

   mpc -h $MYHOST current >  ~/.mpd/song
    echo "1" > ~/.mpd/flag
     
    fi
     else
     
if [ "$OPT" = "m3u" ]
  then
    mpc -h $MYHOST load $1
    index=$(mpc -h $MYHOST playlist|wc -l)
    mpc -h $MYHOST play $index
   
     
  else
    mpc -h $MYHOST add $1
    index=$(mpc -h $MYHOST playlist|wc -l)
    mpc -h $MYHOST play $index
   
  fi
 
  mpc -h $MYHOST current >  ~/.mpd/song
   echo "1" > ~/.mpd/flag

fi



bester69 wrote:You wont change my mind when I know Im right, Im not an ...
User avatar
bester69
 
Posts: 1485
Joined: 2015-04-02 13:15

Return to Docs, Howtos, Tips & Tricks

Who is online

Users browsing this forum: No registered users and 4 guests

fashionable