Make the progress bar purely decorative, drop live position tracking
positionMs changes every poll (~20s), so the old live progress bar/elapsed time forced a full flash constantly, even mid-song -- this panel has no partial refresh, so there's no way to show real progress without that. Now it's an outline + total length only, driven by nothing that changes while the same track keeps playing. Verified the rendered image is byte-identical across different positionMs values for the same track. Also dropped elapsed/elapsed_text/progress_pct from the track dict entirely now that nothing renders them.
This commit is contained in:
1 parent
5baa45904c
commit
a5fd39f2af
2 files changed
+9
-14
No files matched your search
+8
-13
@@ -138,12 +138,9 @@ class NavidromeScreen(Screen):
|
|||||||
def _build_track(self, entry: dict, settings: dict, idle: bool) -> dict:
|
def _build_track(self, entry: dict, settings: dict, idle: bool) -> dict:
|
||||||
duration = int(entry.get("duration") or 0)
|
duration = int(entry.get("duration") or 0)
|
||||||
if idle:
|
if idle:
|
||||||
elapsed = 0
|
|
||||||
since = time.time() - float(settings.get("_last_track_at") or time.time())
|
since = time.time() - float(settings.get("_last_track_at") or time.time())
|
||||||
minutes_ago = (int(since // 60) // 5) * 5
|
minutes_ago = (int(since // 60) // 5) * 5
|
||||||
else:
|
else:
|
||||||
elapsed = int((entry.get("positionMs") or 0) / 1000)
|
|
||||||
elapsed = min(elapsed, duration) if duration else elapsed
|
|
||||||
minutes_ago = entry.get("minutesAgo") or 0
|
minutes_ago = entry.get("minutesAgo") or 0
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -158,9 +155,6 @@ class NavidromeScreen(Screen):
|
|||||||
"minutes_ago": minutes_ago,
|
"minutes_ago": minutes_ago,
|
||||||
"duration": duration,
|
"duration": duration,
|
||||||
"duration_text": _format_time(duration),
|
"duration_text": _format_time(duration),
|
||||||
"elapsed": elapsed,
|
|
||||||
"elapsed_text": _format_time(elapsed),
|
|
||||||
"progress_pct": (elapsed / duration) if duration else 0,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def _fetch_cover(self, settings: dict, cover_art_id: str):
|
def _fetch_cover(self, settings: dict, cover_art_id: str):
|
||||||
@@ -300,18 +294,19 @@ class NavidromeScreen(Screen):
|
|||||||
|
|
||||||
items.append((album_font.size * 1.4, draw_genre))
|
items.append((album_font.size * 1.4, draw_genre))
|
||||||
|
|
||||||
if settings.get("show_progress", False) and not idle and track["duration"]:
|
if settings.get("show_progress", False) and track["duration"]:
|
||||||
|
# Purely decorative -- an outline, not a fill. This panel has no
|
||||||
|
# partial refresh, so anything tracking *live* playback position
|
||||||
|
# would change on every poll and force a full flash every ~20s
|
||||||
|
# even mid-song. Shows total length only, never changes while
|
||||||
|
# the same track keeps playing.
|
||||||
bar_h = max(3, int(scale * 0.012))
|
bar_h = max(3, int(scale * 0.012))
|
||||||
bar_gap = status_font.size * 0.3
|
bar_gap = status_font.size * 0.3
|
||||||
|
|
||||||
def draw_progress(yy, bar_h=bar_h, bar_gap=bar_gap):
|
def draw_progress(yy, bar_h=bar_h, bar_gap=bar_gap):
|
||||||
bar_y = yy + bar_gap
|
bar_y = yy + bar_gap
|
||||||
draw.rectangle((x, bar_y, x + w, bar_y + bar_h), outline=(60, 60, 60))
|
draw.rectangle((x, bar_y, x + w, bar_y + bar_h), outline=(180, 180, 180))
|
||||||
fill_w = int(w * min(1.0, track["progress_pct"]))
|
draw.text((centered_x(track["duration_text"], source_font), bar_y + bar_h + status_font.size * 0.4), track["duration_text"], font=source_font, fill=(110, 110, 110))
|
||||||
if fill_w > 0:
|
|
||||||
draw.rectangle((x, bar_y, x + fill_w, bar_y + bar_h), fill=(60, 60, 60))
|
|
||||||
times = f"{track['elapsed_text']} / {track['duration_text']}"
|
|
||||||
draw.text((centered_x(times, source_font), bar_y + bar_h + status_font.size * 0.4), times, font=source_font, fill=(110, 110, 110))
|
|
||||||
|
|
||||||
items.append((bar_gap + bar_h + status_font.size * 0.4 + source_font.size * 1.6, draw_progress))
|
items.append((bar_gap + bar_h + status_font.size * 0.4 + source_font.size * 1.6, draw_progress))
|
||||||
elif track["duration"]:
|
elif track["duration"]:
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="section-label">Display options</div>
|
<div class="section-label">Display options</div>
|
||||||
<label class="checkbox"><input type="checkbox" name="show_progress" {{ "checked" if settings.show_progress }}> Progress bar and times</label>
|
<label class="checkbox"><input type="checkbox" name="show_progress" {{ "checked" if settings.show_progress }}> Progress bar (decorative -- shows length, not live position, so it won't force extra refreshes)</label>
|
||||||
<label class="checkbox"><input type="checkbox" name="show_genre" {{ "checked" if settings.show_genre }}> Genre</label>
|
<label class="checkbox"><input type="checkbox" name="show_genre" {{ "checked" if settings.show_genre }}> Genre</label>
|
||||||
<label class="checkbox"><input type="checkbox" name="show_source" {{ "checked" if settings.show_source }}> Player and listener name</label>
|
<label class="checkbox"><input type="checkbox" name="show_source" {{ "checked" if settings.show_source }}> Player and listener name</label>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in new issue
Block a user