X-Git-Url: http://git.plutz.net/?a=blobdiff_plain;f=actions%2Fwatch.sh;h=3398b99271fc240fb2b5ecb074b6b4b1fdcd6529;hb=a68bd6b9df0235cbe92a88f13be638825d86aac9;hp=d0987177c6e157318b6b46ec4e35ed773100ca1a;hpb=47b905d14103c01625d16fe557e63e34317c6453;p=serve0 diff --git a/actions/watch.sh b/actions/watch.sh index d098717..3398b99 100755 --- a/actions/watch.sh +++ b/actions/watch.sh @@ -27,6 +27,8 @@ linkinfo="$(urlsafe "$info")" if [ "${_COOKIE[fakemp4]}" = yes ] && [ "${info##*.}" != mp4 ]; then [ -e "${_DATA}/videos/${info%.*}.mp4" ] || ln -s "${_DATA}/videos/$info" "${_DATA}/mp4/${info%.*}.mp4" videourl="$(urlsafe "mp4/${info%.*}.mp4")" +elif [ -z "$info" ]; then + videourl="$(urlsafe "${location#/}")" else videourl="$(urlsafe "videos/$info")" fi @@ -49,12 +51,29 @@ case "${_COOKIE[watch]}" in redirect "$videourl" ;; server) - if [ -n "$info" ]; then - DISPLAY=:0 XDG_RUNTIME_DIR=/run/user/1006 nohup /usr/bin/mplayer -ao pulse --quiet "${_DATA}/videos/$info" >/dev/null 2>/dev/null & - elif [ -n "$location" ]; then - DISPLAY=:0 XDG_RUNTIME_DIR=/run/user/1006 nohup /usr/bin/mplayer -ao pulse --quiet "${treeroot%/}/${location#/}" >/dev/null 2>/dev/null & - fi - redirect "$HTTP_REFERER" + [ -n "$location" ] && playuri="${treeroot%/}/${location#/}" + [ -n "$info" ] && playuri="${_DATA}/videos/$info" + + fifofile="${_DATA}/mplayer.fifo" + volume="$(validate "$(cat "${_DATA}/mplayer.volume")" '[1-9]?[0-9]|100' 20)" + [ \! -p "$fifofile" ] && rm -f "$fifofile" && mkfifo -m 600 "$fifofile" + + debug PLAYURI $playuri + + DISPLAY=:0 XDG_RUNTIME_DIR=/run/user/1006 \ + nohup /usr/bin/mplayer -ao pulse -quiet \ + -slave -input file="$fifofile" \ + -volume "$volume" \ + "$playuri" >/dev/null 2>/dev/null & + + # # MPlayer2: + # DISPLAY=:0 XDG_RUNTIME_DIR=/run/user/1006 \ + # nohup /usr/bin/mplayer -ao pulse --quiet \ + # --slave --input=file="$fifofile" \ + # --volume="$volume" \ + # "$playuri" >/dev/null 2>/dev/null & + + redirect "?p=playctl&${watch_link}" ;; *) redirect "?p=view&${watch_link}" ;;