From: paul Date: Fri, 29 Apr 2016 11:25:37 +0000 (+0000) Subject: enable live status bar via chunked encoding X-Git-Url: http://git.plutz.net/?a=commitdiff_plain;h=aa4516d7090b7818127a1dd39a281059d3e042cc;hp=2c29a0ff0f4f8d2f9763ba1cc02eb696c4145429;p=serve0 enable live status bar via chunked encoding svn path=/trunk/; revision=122 --- diff --git a/actions/playctl.sh b/actions/playctl.sh index bda4d1b..c4aff61 100755 --- a/actions/playctl.sh +++ b/actions/playctl.sh @@ -17,6 +17,7 @@ # along with Serve0 If not, see . fifofile="${_DATA}/mplayer.fifo" +statusfile="${_DATA}/mplayer.status" volfile="${_DATA}/mplayer.volume" if [ -n "${_POST[amp]+x}" ]; then diff --git a/actions/watch.sh b/actions/watch.sh index 3398b99..b3463b9 100755 --- a/actions/watch.sh +++ b/actions/watch.sh @@ -55,16 +55,17 @@ case "${_COOKIE[watch]}" in [ -n "$info" ] && playuri="${_DATA}/videos/$info" 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 DISPLAY=:0 XDG_RUNTIME_DIR=/run/user/1006 \ - nohup /usr/bin/mplayer -ao pulse -quiet \ + nohup /usr/bin/mplayer -ao pulse \ -slave -input file="$fifofile" \ -volume "$volume" \ - "$playuri" >/dev/null 2>/dev/null & + "$playuri" >"$statusfile" 2>/dev/null & # # MPlayer2: # DISPLAY=:0 XDG_RUNTIME_DIR=/run/user/1006 \ diff --git a/pages/playctl.sh b/pages/playctl.sh index ded8603..c5d6c09 100755 --- a/pages/playctl.sh +++ b/pages/playctl.sh @@ -22,6 +22,7 @@ info="${_GET[i]}" location="$(invalidate "${_GET[l]}" '(.*/)?\.\.(/.*)?|' /)" directory="${location%/*}" +statusfile="$_DATA/mplayer.status" TITLE="$info" @@ -40,3 +41,13 @@ fi volume=$(validate "$(cat "$_DATA/mplayer.volume")" '[1-9]?[0-9]|100' 20) debug VIDEO: $video + +progress(){ + tail --pid=$$ -f "$statusfile" \ + | tr '\r' '\n' \ + | sed -urn 's;^.* ([0-9]{1,3})(,[0-9]+)?% *$;\1;p' \ + | while read n; do + [ "$n" != "$previous" ] && printf "%s\n" "$((100 - $n))" + previous=$n + done +} diff --git a/static/common.css b/static/common.css index 370be05..667c8ab 100644 --- a/static/common.css +++ b/static/common.css @@ -150,6 +150,9 @@ div.panel { overflow: visible; } +body.playctl .panel#search, +body.playctl .panel#foot { padding-right: .25em; } + .panel:target { max-height: 100%; overflow-y: scroll; @@ -368,6 +371,23 @@ div.panel { #playctl form button[name="vol"][value="100"], #playctl form button[name="vol"][value="0"] { width: 6%;} +span.progress { + display: block; + position: fixed; + bottom: 2.5em; + width: 100%; left:0; right: 0; + color: white; + background-color: black; + border-top: 1px solid white; + padding: 0; + height: 1em; +} +span.progress > * { + display: block; + text-align: center; + background-color: #333; +} + @media (min-width: 460px){ #playctl form button { max-width: 4em; diff --git a/templates/frame.html.sh b/templates/frame.html.sh index 924b2bd..c389e10 100755 --- a/templates/frame.html.sh +++ b/templates/frame.html.sh @@ -18,18 +18,17 @@ cat < - - - - - ${TITLE:-${PAGE}} - -EOF -cat < - $([ -x "${BODY}" ] && . "${BODY}" || printf %s Error) - - + + + + ${TITLE:-${PAGE}} + EOF +printf '' "${PAGE}" + +[ -x "${BODY}" ] && . "${BODY}" || printf %s Error + +printf '' + # vi:set filetype=html: diff --git a/templates/playctl.html.sh b/templates/playctl.html.sh index 7ef0700..1725f7f 100755 --- a/templates/playctl.html.sh +++ b/templates/playctl.html.sh @@ -29,13 +29,6 @@ cat <Clear All Dismiss - -
- - << - $(($page + 1)) - >> -
@@ -57,7 +50,7 @@ cat < ' "$([ "$volume" = "$n" ] && printf selected)" "$n" done)
- + $(($length / 60)):$(($length % 60)) min @@ -105,14 +98,16 @@ cat < Edit Tags - -
- - << - $(($page + 1)) - >> -
EOF +cnt=0 +progress \ +| while read n; do + printf '%s\n' $n $n +done + + + + # vi:set filetype=html: