summaryrefslogtreecommitdiff
path: root/sys/src/cmd/audio
diff options
context:
space:
mode:
authorSigrid Solveig Haflínudóttir <sigrid@ftrv.se>2022-09-19 19:14:33 +0000
committerSigrid Solveig Haflínudóttir <sigrid@ftrv.se>2022-09-19 19:14:33 +0000
commit91791a03db3747cdcb480d62b1fd90b92626f1aa (patch)
treec42deafc4d28bd5b81bd899c66b226e5aa37b637 /sys/src/cmd/audio
parent338e4a0a88982da9f3ea0ce96c167877105bb669 (diff)
audio/zuke: use digits to enter exact seek position
Diffstat (limited to 'sys/src/cmd/audio')
-rw-r--r--sys/src/cmd/audio/zuke/zuke.c35
1 files changed, 32 insertions, 3 deletions
diff --git a/sys/src/cmd/audio/zuke/zuke.c b/sys/src/cmd/audio/zuke/zuke.c
index af7c41a8b..40fa337ae 100644
--- a/sys/src/cmd/audio/zuke/zuke.c
+++ b/sys/src/cmd/audio/zuke/zuke.c
@@ -274,8 +274,8 @@ redraw_(int full)
/* seekbar playback/duration text */
msec = 0;
- dur = getmeta(pcurplaying)->duration;
if(pcurplaying >= 0){
+ dur = getmeta(pcurplaying)->duration;
msec = byteswritten*1000/Bps;
if(dur > 0){
snprint(tmp, sizeof(tmp), "%s%P/%P 100%%",
@@ -297,6 +297,7 @@ redraw_(int full)
msec/1000, volume);
}
}else{
+ dur = 0;
snprint(tmp, sizeof(tmp), "%s%d%%", shuffle != nil ? "∫ " : "", 100);
w = stringwidth(f, tmp);
snprint(tmp, sizeof(tmp), "%s%d%%", shuffle != nil ? "∫ " : "", volume);
@@ -722,8 +723,7 @@ restart:
boffsetlast = boffset;
byteswritten = boffset;
pcurplaying = player->pcur;
- if(c != Cseekrel)
- redraw(0);
+ redraw(1);
while(1){
n = ioread(io, p[1], buf, Relbufsz);
@@ -950,6 +950,25 @@ recenter(void)
}
static void
+seekto(char *s)
+{
+ uvlong p;
+ char *e;
+
+ for(p = 0; *s; s = e){
+ p += strtoll(s, &e, 10);
+ if(s == e)
+ break;
+ if(*e == ':'){
+ p *= 60;
+ e++;
+ }
+ }
+
+ seekrel(playercurr, p - byteswritten/Bps);
+}
+
+static void
search(char d)
{
Meta *m;
@@ -1372,6 +1391,16 @@ threadmain(int argc, char **argv)
break;
case Ekey:
switch(key){
+ default:
+ if(isdigit(key) && pcurplaying >= 0 && getmeta(pcurplaying)->duration > 0){
+ buf[0] = key;
+ buf[1] = 0;
+ if(enter("seek:", buf, sizeof(buf), mctl, &kctl, screen->screen) < 1)
+ redraw(1);
+ else
+ seekto(buf);
+ }
+ break;
case Kleft:
seekrel(playercurr, -(double)Seek);
break;