]> git.plutz.net Git - serve0/blob - actions/playctl.sh
bugfixes and visual fixes in player control
[serve0] / actions / playctl.sh
1 #!/bin/zsh
2 # Copyright 2016 Paul Hänsch
3 #
4 # This file is part of Serve0
5 #
6 # Serve0 is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU Affero General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
10 #
11 # Serve0 is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU Affero General Public License for more details.
15 #
16 # You should have received a copy of the GNU Affero General Public License
17 # along with Serve0  If not, see <http://www.gnu.org/licenses/>.
18
19 fifofile="${_DATA}/mplayer.fifo"
20 volfile="${_DATA}/mplayer.volume"
21
22 if   [ -n "${_POST[amp]+x}" ]; then
23   amp $(validate "${_POST[amp]}" '(on|off)' off)
24 elif [ -n "${_POST[vol]+x}" ]; then
25   vol=$(validate "${_POST[vol]}" '[1-9]?[0-9]|100' 10)
26   printf %s\\n $vol >"$volfile"
27   printf 'volume %s 1\n' $vol >"$fifofile"
28 elif [ -n "${_POST[ctl]+x}" ]; then
29   printf '%s\n' $(validate "${_POST[ctl]}" "pause|stop" pause) >"$fifofile"
30 elif [ -n "${_POST[seek]+x}" ]; then
31   printf 'seek %s\n' $(validate "${_POST[seek]}" "[+-]?[0-9]+" 0) >"$fifofile"
32 elif [ -n "${_POST[osd]+x}" ]; then
33   case ${_POST[osd]} in
34     progression) printf "osd_show_progression\\n";;
35   esac >"$fifofile"
36 fi &
37
38 redirect "$HTTP_REFERER"