Pin progress bar to bottom, add show/host line with new color scheme
This commit is contained in:
1 parent
1d2021e6f2
commit
607fe9abe4
2 files changed
+43
-16
No files matched your search
@@ -2,8 +2,10 @@
|
||||
|
||||
Tronbyt/Tidbyt app showing the current track on a [SUB/WAVE](https://github.com/perminder-klair/subwave)
|
||||
internet radio station: album art, track title, artist, the current show
|
||||
name, and a progress bar for the track, with title/artist scrolling if they
|
||||
don't fit.
|
||||
and host, and a progress bar for the track pinned to the bottom, with
|
||||
title/artist/show scrolling if they don't fit. Color scheme (cyan
|
||||
title/artist, gray label, white show name, magenta host/progress bar) is
|
||||
loosely modeled on SUB/WAVE's own web now-playing display.
|
||||
|
||||
Not tied to any specific station — set your own station's base URL in the
|
||||
app's config when adding it to a device.
|
||||
@@ -25,8 +27,9 @@ app's config when adding it to a device.
|
||||
instead of stale track info.
|
||||
- If a track has no `subsonic_id`, or the cover fetch fails, falls back to a
|
||||
full-width layout with no art rather than a broken image.
|
||||
- Shows the current show name (`context.activeShow.name`) below the artist,
|
||||
and a track progress bar at the bottom.
|
||||
- Shows a "-- Show --" label, the current show name
|
||||
(`context.activeShow.name`), and host name (`dj.name`) below the artist,
|
||||
and a track progress bar pinned to the very bottom.
|
||||
|
||||
**Progress bar caveat:** the now-playing API reports track `duration` but
|
||||
not elapsed/remaining time, so the app tracks playback position itself —
|
||||
|
||||
+36
-12
@@ -1,7 +1,7 @@
|
||||
"""
|
||||
Applet: SUB/WAVE Now Playing
|
||||
Summary: Shows what's playing on a SUB/WAVE station
|
||||
Description: Configure with your SUB/WAVE (github.com/perminder-klair/subwave) station's base URL to display the current track, artist, show, album art, and a progress bar.
|
||||
Description: Configure with your SUB/WAVE (github.com/perminder-klair/subwave) station's base URL to display the current track, artist, show, host, album art, and a progress bar.
|
||||
Author: poprhythm
|
||||
"""
|
||||
|
||||
@@ -15,6 +15,14 @@ DEFAULT_STATION_URL = ""
|
||||
NOWPLAYING_TTL = 20
|
||||
COVER_TTL = 300
|
||||
|
||||
COLOR_TITLE = "#22d3ee" # cyan
|
||||
COLOR_ARTIST = "#22d3ee" # cyan
|
||||
COLOR_LABEL = "#888888" # muted gray, for the "-- Show --" label
|
||||
COLOR_SHOW = "#e0e0e0" # near-white
|
||||
COLOR_HOST = "#ec4899" # magenta/pink
|
||||
COLOR_BAR_FILLED = "#c026d3" # magenta/purple
|
||||
COLOR_BAR_EMPTY = "#333333"
|
||||
|
||||
def main(config):
|
||||
station_url = config.get("station_url", DEFAULT_STATION_URL)
|
||||
if station_url:
|
||||
@@ -33,16 +41,31 @@ def main(config):
|
||||
art = _fetch_cover(station_url, now["subsonic_id"])
|
||||
progress = _track_progress(now["subsonic_id"], now["duration"])
|
||||
|
||||
lines = [
|
||||
render.Marquee(width = 32, child = render.Text(now["title"])),
|
||||
render.Marquee(width = 32, child = render.Text(now["artist"], color = "#aaaaaa")),
|
||||
top_lines = [
|
||||
render.Marquee(width = 32, child = render.Text(now["title"], color = COLOR_TITLE)),
|
||||
render.Marquee(width = 32, child = render.Text(now["artist"], color = COLOR_ARTIST)),
|
||||
]
|
||||
if now["show"]:
|
||||
lines.append(render.Marquee(width = 32, child = render.Text(now["show"], font = "tom-thumb", color = "#666666")))
|
||||
if progress != None:
|
||||
lines.append(_progress_bar(progress["fraction"], width = 32))
|
||||
top_lines.append(render.Text("-- Show --", font = "tom-thumb", color = COLOR_LABEL))
|
||||
show_host_row = [render.Text(now["show"], font = "tom-thumb", color = COLOR_SHOW)]
|
||||
if now["host"]:
|
||||
show_host_row.append(render.Text(" " + now["host"], font = "tom-thumb", color = COLOR_HOST))
|
||||
top_lines.append(render.Marquee(width = 32, child = render.Row(children = show_host_row)))
|
||||
|
||||
text_column = render.Column(children = lines)
|
||||
children = [render.Column(children = top_lines)]
|
||||
if progress != None:
|
||||
children.append(_progress_bar(progress["fraction"], width = 32))
|
||||
|
||||
text_column = render.Box(
|
||||
width = 32,
|
||||
height = 32,
|
||||
child = render.Column(
|
||||
main_align = "space_between",
|
||||
cross_align = "start",
|
||||
expanded = True,
|
||||
children = children,
|
||||
),
|
||||
)
|
||||
|
||||
if art:
|
||||
content = render.Row(children = [render.Image(src = art, width = 32, height = 32), text_column])
|
||||
@@ -52,8 +75,8 @@ def main(config):
|
||||
cross_align = "center",
|
||||
expanded = True,
|
||||
children = [
|
||||
render.Marquee(width = 64, child = render.Text(now["title"])),
|
||||
render.Marquee(width = 64, child = render.Text(now["artist"], color = "#aaaaaa")),
|
||||
render.Marquee(width = 64, child = render.Text(now["title"], color = COLOR_TITLE)),
|
||||
render.Marquee(width = 64, child = render.Text(now["artist"], color = COLOR_ARTIST)),
|
||||
],
|
||||
)
|
||||
|
||||
@@ -72,9 +95,9 @@ def _progress_bar(fraction, width = 32, height = 2):
|
||||
filled = max(0, min(filled, width))
|
||||
children = []
|
||||
if filled > 0:
|
||||
children.append(render.Box(width = filled, height = height, color = "#66bb6a"))
|
||||
children.append(render.Box(width = filled, height = height, color = COLOR_BAR_FILLED))
|
||||
if filled < width:
|
||||
children.append(render.Box(width = width - filled, height = height, color = "#333333"))
|
||||
children.append(render.Box(width = width - filled, height = height, color = COLOR_BAR_EMPTY))
|
||||
return render.Row(children = children)
|
||||
|
||||
def _fetch_now_playing(station_url):
|
||||
@@ -94,6 +117,7 @@ def _fetch_now_playing(station_url):
|
||||
"duration": np.get("duration", 0),
|
||||
"station": dj.get("station", "SUB/WAVE"),
|
||||
"show": active_show.get("name", ""),
|
||||
"host": dj.get("name", ""),
|
||||
"online": bool(data.get("streamOnline", False)),
|
||||
}
|
||||
|
||||
|
||||