From 2e9725cac753f3e0e481ba264b669a2af2b4a9f1 Mon Sep 17 00:00:00 2001 From: Franzformator <41994422+Franzformator@users.noreply.github.com> Date: Wed, 16 Jan 2019 21:40:45 +0100 Subject: [PATCH 1/2] Change volume during idle/play MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit My son often presses the volume buttons while the Phoniebox is not playing any file. After starting a new file the box is often very load. To prevent this. I created a new File “Change_Volume_Idle”. There you can select between following options: TRUE=Change Volume during all Time (Default) FALSE=Change Volume only during "Play" OnlyDown=It is possible to decrease Volume during Idle OnlyUp=It is possible to increase Volume during Idle Please Test it – This is my first commit on Github and I hope I have done everything wright. Also I hope my commit does not affect other change that happened in the meantime. --- scripts/playout_controls.sh | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/scripts/playout_controls.sh b/scripts/playout_controls.sh index b9eec5a41..e59651cd8 100755 --- a/scripts/playout_controls.sh +++ b/scripts/playout_controls.sh @@ -94,6 +94,16 @@ MINVOL='1' # it will be created or deleted by this script VOLFILE=$PATHDATA/../settings/Audio_Volume_Level +############################################## +# Change volume during idle (or only change it during Play and in the WebApp) +#TRUE=Change Volume during all Time (Default; FALSE=Change Volume only during "Play"; OnlyDown=It is possible to decrease Volume during Idle; OnlyUp=It is possible to increase Volume during Idle +# 1. create a default if file does not exist (set default do TRUE - Volume Change is possible every time) +if [ ! -f $PATHDATA/../settings/Change_Volume_Idle ]; then + echo "TRUE" > $PATHDATA/../settings/Change_Volume_Idle +fi +# 2. then|or read value from file +VOLCHANGEIDLE=`cat $PATHDATA/../settings/Change_Volume_Idle` + ################################# # Idle time after the RPi will be shut down. 0=turn off feature. # 1. create a default if file does not exist @@ -115,6 +125,7 @@ AUDIOFOLDERSPATH=`cat $PATHDATA/../settings/Audio_Folders_Path` #echo $VOLSTEP #echo $VOLFILE #echo $MAXVOL +#echo $VOLCHANGEIDLE #echo `cat $VOLFILE` #echo $IDLETIME #echo $AUDIOFOLDERSPATH @@ -213,6 +224,16 @@ case $COMMAND in fi ;; volumeup) + #check for volume change during idle + if [ $VOLCHANGEIDLE == "FALSE" ] || [ $VOLCHANGEIDLE == "OnlyDown" ]; + then + PLAYSTATE=$(echo -e "status\nclose" | nc -w 1 localhost 6600 | grep -o -P '(?<=state: ).*') + if [ "$PLAYSTATE" != "play" ] + then + #Volume change is not allowed - leave program + exit 1 + fi + fi if [ ! -f $VOLFILE ]; then if [ -z $VALUE ]; then VALUE=1 @@ -240,7 +261,17 @@ case $COMMAND in fi ;; volumedown) - if [ ! -f $VOLFILE ]; then + #check for volume change during idle + if [ $VOLCHANGEIDLE == "FALSE" ] || [ $VOLCHANGEIDLE == "OnlyUp" ]; + then + PLAYSTATE=$(echo -e "status\nclose" | nc -w 1 localhost 6600 | grep -o -P '(?<=state: ).*') + if [ "$PLAYSTATE" != "play" ] + then + #Volume change is not allowed - leave program + exit 1 + fi + fi + if [ ! -f $VOLFILE ]; then if [ -z $VALUE ]; then VALUE=1 fi From 495920bd0409373544633269c950c16b76cefbc0 Mon Sep 17 00:00:00 2001 From: Franzformator <41994422+Franzformator@users.noreply.github.com> Date: Wed, 16 Jan 2019 22:05:54 +0100 Subject: [PATCH 2/2] Make MinVolume configurable I often have the case that my son reduces the Volume to a value that I cannot recognise if the phoniebox is playing. To get rid of this I made some code to set a minimum Volume. Now I have seen that someone has done something comparable. So I only added things I have done additionally. --- scripts/playout_controls.sh | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/scripts/playout_controls.sh b/scripts/playout_controls.sh index e59651cd8..a2116a84a 100755 --- a/scripts/playout_controls.sh +++ b/scripts/playout_controls.sh @@ -86,7 +86,14 @@ fi # 2. then|or read value from file MAXVOL=`cat $PATHDATA/../settings/Max_Volume_Limit` -MINVOL='1' +############################################## +# Min volume limit +# 1. create a default if file does not exist +if [ ! -f $PATHDATA/../settings/Min_Volume_Limit ]; then + echo "0" > $PATHDATA/../settings/Min_Volume_Limit +fi +# 2. then|or read value from file +MINVOL=`cat $PATHDATA/../settings/Min_Volume_Limit` ################################# # path to file storing the current volume level @@ -125,6 +132,7 @@ AUDIOFOLDERSPATH=`cat $PATHDATA/../settings/Audio_Folders_Path` #echo $VOLSTEP #echo $VOLFILE #echo $MAXVOL +#echo $MINVOL #echo $VOLCHANGEIDLE #echo `cat $VOLFILE` #echo $IDLETIME @@ -213,14 +221,22 @@ case $COMMAND in fi ;; setvolume) - #increase volume only if VOLPERCENT is below the max volume limit - if [ $VALUE -le $MAXVOL ]; + #increase volume only if VOLPERCENT is below the max volume limit and above min volume limit + if [ $VALUE -le $MAXVOL ] && [ $VALUE -ge $MINVOL ]; then # set volume level in percent echo -e setvol $VALUE\\nclose | nc -w 1 localhost 6600 else - # if we are over the max volume limit, set the volume to maxvol - echo -e setvol $MAXVOL\\nclose | nc -w 1 localhost 6600 + if [ $VALUE -gt $MAXVOL ]; + then + # if we are over the max volume limit, set the volume to maxvol + echo -e setvol $MAXVOL\\nclose | nc -w 1 localhost 6600 + fi + if [ $VALUE -lt $MINVOL ]; + then + # if we are unter the min volume limit, set the volume to minvol + echo -e setvol $MINVOL\\nclose | nc -w 1 localhost 6600 + fi fi ;; volumeup)