]> git.plutz.net Git - serve0/blobdiff - actions/watch.sh
time display for files from directory
[serve0] / actions / watch.sh
index b0a5920b260535c97295945b2dc3f10abe074490..3fae936a01491b525a3bbb26e0accc6684eea8b5 100755 (executable)
@@ -51,12 +51,36 @@ 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"
+
+    metafile="${_DATA}/meta/${info}.meta"
+
+    playmeta="${_DATA}/mplayer.meta"
+    fifofile="${_DATA}/mplayer.fifo"
+    statusfile="${_DATA}/mplayer.status"
+    volume="$(validate "$(cat "${_DATA}/mplayer.volume")" '[1-9]?[0-9]|100' 20)"
+    [ \! -p "$fifofile" ] && rm -f "$fifofile" && mkfifo -m 600 "$fifofile"
+
+    debug PLAYURI "$playuri"
+
+    [ -f "$metafile" ] && cp "$metafile" "$playmeta" \
+                       || "${_EXEC}"/helpers/genmeta.sh "$playuri" "$playmeta" >/dev/null
+
+    DISPLAY=:0 XDG_RUNTIME_DIR=/run/user/1006 \
+      nohup /usr/bin/mplayer -ao pulse \
+      -slave -input file="$fifofile" \
+      -volume "$volume" \
+      "$playuri" >"$statusfile" 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}"
   ;;