]> git.plutz.net Git - serve0/commitdiff
enable live status bar via chunked encoding
authorpaul <paul@plutz.net>
Fri, 29 Apr 2016 11:25:37 +0000 (11:25 +0000)
committerpaul <paul@plutz.net>
Fri, 29 Apr 2016 11:25:37 +0000 (11:25 +0000)
svn path=/trunk/; revision=122

actions/playctl.sh
actions/watch.sh
pages/playctl.sh
static/common.css
templates/frame.html.sh
templates/playctl.html.sh

index bda4d1b208c9b94a5b4152c17514f1494d2a7097..c4aff61200e75fae13f7ef730586f7027e2043e5 100755 (executable)
@@ -17,6 +17,7 @@
 # along with Serve0  If not, see <http://www.gnu.org/licenses/>.
 
 fifofile="${_DATA}/mplayer.fifo"
+statusfile="${_DATA}/mplayer.status"
 volfile="${_DATA}/mplayer.volume"
 
 if   [ -n "${_POST[amp]+x}" ]; then
index 3398b99271fc240fb2b5ecb074b6b4b1fdcd6529..b3463b9aac183627af0c1f04b700f6869e9661f7 100755 (executable)
@@ -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 \
index ded8603313ddff9ffe8682cff43565f4361b2a9e..c5d6c09fb1e9f30d7d5751ae79e30843b5a5e542 100755 (executable)
@@ -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
+}
index 370be05e269a984de7c65422b5cbcfa61c7e776f..667c8ab9f090293e0568805832ec0a3b12f63a97 100644 (file)
@@ -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;
index 924b2bdb9713b1d2d3e49a2b433d8d6d78d87310..c389e103036bc37f180bcde80e30247491b4dde2 100755 (executable)
 cat <<EOF
 <!Doctype HTML>
 
-<html>
-  <head>
-    <meta name="viewport" content="width=device-width">
-    <link rel="stylesheet" href="?static=common.css" />
-    <title>${TITLE:-${PAGE}}</title>
-  </head>
-EOF
-cat <<EOF
-  <body>
-    $([ -x "${BODY}" ] && . "${BODY}" || printf %s Error)
-  </body>
-</html>
+<html><head>
+  <meta name="viewport" content="width=device-width">
+  <link rel="stylesheet" href="?static=common.css" />
+  <title>${TITLE:-${PAGE}}</title>
+</head>
 EOF
 
+printf '<body class="%s">' "${PAGE}"
+
+[ -x "${BODY}" ] && . "${BODY}" || printf %s Error
+
+printf '</body></html>'
+
 # vi:set filetype=html:
index 7ef07009db5ffe7d55d64e66cedb3421e15f6d43..1725f7f784ce1b7c489ca04a2cbe4ff409e6a5ed 100755 (executable)
@@ -29,13 +29,6 @@ cat <<EOF
 
   <a class="panel clearsearch" href="?">Clear All</a>
   <a class="panel" href="${info:+?p=list&amp;${page_this}}${directory:+?p=tree&amp;d=${directory}&amp;${page_this}}#$(urlsafe $info)">Dismiss</a>
-
-  <div class="pagination_nav">
-    <label>Page:</label>
-    <a href="?p=view&amp;${page_prev}">&lt;&lt;</a>
-    <a href="?p=view&amp;${page_this}">$(($page + 1))</a>
-    <a href="?p=view&amp;${page_next}">&gt;&gt;</a>
-  </div>
 </form>
 
 <div id="playctl">
@@ -57,7 +50,7 @@ cat <<EOF
        printf '<button class="%s" type="submit" name="vol" value="%s">&nbsp;</button>' "$([ "$volume" = "$n" ] && printf selected)" "$n"
      done)
      <br>
-     <button type="submit" name="osd" value="progression">Progress</button>
+     <!--button type="submit" name="osd" value="progression">Progress</button -->
   </form>
 
   <span class="info length">$(($length / 60)):$(($length % 60)) min</span>
@@ -105,14 +98,16 @@ cat <<EOF
 
 <div class="panel footer" id="foot">
   <a class="panel toggle" href="#tagger">Edit Tags</a>
-
-  <div class="pagination_nav">
-    <label>Page:</label>
-    <a href="?${page_prev}">&lt;&lt;</a>
-    <a href="?${page_this}">$(($page + 1))</a>
-    <a href="?${page_next}">&gt;&gt;</a>
-  </div>
 </div>
 EOF
 
+cnt=0
+progress \
+| while read n; do
+  printf '<span class="progress"><span style="width: %s%%;">%s</span></span>\n' $n $n
+done
+
+
+
+
 # vi:set filetype=html: