X-Git-Url: https://feistymeow.org/gitweb/?a=blobdiff_plain;f=scripts%2Fmultimedia%2Fsound_play.sh;h=250bddb41d17e48f852ba41ba394247c8a232554;hb=d88be084867a87d831ced0bec1169cc91654c60a;hp=f499d30ba349a28b4d868c7c4ab48fafa2a7082f;hpb=858d4fc46ef8b6c14815c137182c9bed9a6c5043;p=feisty_meow.git diff --git a/scripts/multimedia/sound_play.sh b/scripts/multimedia/sound_play.sh index f499d30b..250bddb4 100644 --- a/scripts/multimedia/sound_play.sh +++ b/scripts/multimedia/sound_play.sh @@ -2,32 +2,60 @@ # play the sound files specified. -source "$FEISTY_MEOW_SCRIPTS/core/functions.sh" # provides psfind. +source "$FEISTY_MEOW_SCRIPTS/core/launch_feisty_meow.sh" if [ $# -lt 1 ]; then #echo no sound file specified. exit 0; fi -export PLAYCMD=/usr/bin/play -if [ ! -f "$PLAYCMD" ]; then - PLAYCMD=echo -fi - -if [ ! -z "$(psfind artsd)" ]; then - # we see artsd running... - PLAYCMD=artsplay +export BASIC_PLAY_CMD='echo Unknown basic sound player...' + +if [ -f "/usr/bin/play" ]; then +#echo we see /usr/bin/play available... + BASIC_PLAY_CMD=/usr/bin/play +elif [ ! -z "$(whichable afplay)" ]; then +#echo we see afplay available... + BASIC_PLAY_CMD=afplay +elif [ ! -z "$(psfind artsd)" ]; then +#echo we see artsd running... + BASIC_PLAY_CMD=artsplay elif [ ! -z "$(psfind esd)" ]; then - # we see esd running... - PLAYCMD=esdplay +#echo we see esd running... + BASIC_PLAY_CMD=esdplay +elif [ ! -z "$(psfind pulseaudio)" ]; then +#echo we see pulse running... + BASIC_PLAY_CMD="padsp aplay" elif [ ! -z "$WINDIR" ]; then - # kludge for win32; we provide our own sound player. - PLAYCMD=playsound +#echo kludge for win32; we provide our own sound player. + BASIC_PLAY_CMD=playsound +else + echo "I don't know how to play basic sound files for this OS and sound system." +fi + +export MP3_PLAY_CMD='echo Unknown mp3 player...' + +if [ ! -z "$(whichable mplayer)" ]; then + MP3_PLAY_CMD=mplayer +else + echo "I don't know how to play mp3 files for this OS and sound system." fi -# play the sounds individually; playsound can handle multiple files, but -# "play" doesn't want to on some systems. -for i in $*; do $PLAYCMD $i >/dev/null 2>&1; done +# play the sounds individually; some apps like playsound can handle multiple +# files, but "/usr/bin/play" doesn't want to on some systems. +for filename in $*; do + case "$filename" in + *wav) + $BASIC_PLAY_CMD $filename >/dev/null 2>&1; + ;; + *mp3) + $MP3_PLAY_CMD $filename >/dev/null 2>&1; + ;; + *) + echo "I don't know the file extension here: $filename" + ;; + esac +done exit 0