diff options
author | Sigrid Solveig Haflínudóttir <sigrid@ftrv.se> | 2022-09-19 19:35:53 +0000 |
---|---|---|
committer | Sigrid Solveig Haflínudóttir <sigrid@ftrv.se> | 2022-09-19 19:35:53 +0000 |
commit | 518be82da324d9d72bcbd7007809e8c4f76f787b (patch) | |
tree | a3320b70e123f98839f012d560df10e69e2ac7cc /sys/src/cmd/audio | |
parent | 91791a03db3747cdcb480d62b1fd90b92626f1aa (diff) |
audio/zuke: "r" key - "repeat one" mode, based on the patch from qwx (thanks)
Diffstat (limited to 'sys/src/cmd/audio')
-rw-r--r-- | sys/src/cmd/audio/zuke/zuke.c | 45 |
1 files changed, 27 insertions, 18 deletions
diff --git a/sys/src/cmd/audio/zuke/zuke.c b/sys/src/cmd/audio/zuke/zuke.c index 40fa337ae..572fa1354 100644 --- a/sys/src/cmd/audio/zuke/zuke.c +++ b/sys/src/cmd/audio/zuke/zuke.c @@ -90,6 +90,7 @@ static int mincolwidth[10]; static char *cols = "AatD"; static int colspath; static int *shuffle; +static int repeatone; static Rectangle seekbar; static int seekmx, newseekmx = -1; static double seekoff; /* ms */ @@ -273,34 +274,33 @@ redraw_(int full) Image *col; /* seekbar playback/duration text */ + i = snprint(tmp, sizeof(tmp), "%s%s%s", + repeatone ? "¹" : "", + shuffle != nil ? "∫" : "", + (repeatone || shuffle != nil) ? " " : "" + ); msec = 0; if(pcurplaying >= 0){ - dur = getmeta(pcurplaying)->duration; msec = byteswritten*1000/Bps; - if(dur > 0){ - snprint(tmp, sizeof(tmp), "%s%P/%P 100%%", - shuffle != nil ? "∫ " : "", - dur/1000, dur/1000); + if((dur = getmeta(pcurplaying)->duration) > 0){ + snprint(tmp+i, sizeof(tmp)-i, "%P/%P %d%%", dur/1000, dur/1000, 100); w = stringwidth(f, tmp); msec = MIN(msec, dur); - snprint(tmp, sizeof(tmp), "%s%P/%P %d%%", - shuffle != nil ? "∫ " : "", + snprint(tmp+i, sizeof(tmp)-i, "%P/%P %d%%", (uvlong)(newseekmx >= 0 ? seekoff : msec)/1000, - dur/1000, volume); + dur/1000, + volume + ); }else{ - snprint(tmp, sizeof(tmp), "%s%P %d%%", - shuffle != nil ? "∫ " : "", - msec/1000, 100); + snprint(tmp+i, sizeof(tmp)-i, "%P %d%%", msec/1000, 100); w = stringwidth(f, tmp); - snprint(tmp, sizeof(tmp), "%s%P %d%%", - shuffle != nil ? "∫ " : "", - msec/1000, volume); + snprint(tmp, sizeof(tmp), "%P %d%%", msec/1000, volume); } }else{ dur = 0; - snprint(tmp, sizeof(tmp), "%s%d%%", shuffle != nil ? "∫ " : "", 100); + snprint(tmp+i, sizeof(tmp)-i, "%d%%", 100); w = stringwidth(f, tmp); - snprint(tmp, sizeof(tmp), "%s%d%%", shuffle != nil ? "∫ " : "", volume); + snprint(tmp+i, sizeof(tmp)-i, "%d%%", volume); } lockdisplay(display); @@ -727,8 +727,13 @@ restart: while(1){ n = ioread(io, p[1], buf, Relbufsz); - if(n <= 0) + if(n <= 0){ + if(repeatone){ + c = Cseekrel; + boffset = 0; + } break; + } thiscover = nil; if(player->img != nil && nbrecv(player->img, &thiscover) != 0){ @@ -1267,7 +1272,7 @@ threadmain(int argc, char **argv) Scrollwidth = MAX(14, stringwidth(f, "#")); Scrollheight = MAX(16, f->height); Seekthicc = Scrollheight + 2; - Coversz = MAX(64, stringwidth(f, "∫ 00:00:00/00:00:00 100%")); + Coversz = MAX(64, stringwidth(f, "¹∫ 00:00:00/00:00:00 100%")); if((mctl = initmouse(nil, screen)) == nil) sysfatal("initmouse: %r"); @@ -1493,6 +1498,10 @@ playcur: recenter(); full = 1; break; + case 'r': + repeatone ^= 1; + redraw(0); + break; case 'c': case 'p': case ' ': |