Files
spotify/ui/nowplaying.slint
Tamas Csikel 7fd7e242a7
All checks were successful
release / release (push) Successful in 10m37s
0.2.0: play through Spotify Soloist
Spotify refuses librespot the audio keys ("error audio key 0 1",
librespot #1649), so nothing played. Playback now goes through Spotify
Soloist, Spotify's own headless Linux player:

- The TV downloads it from Spotify (redistribution is not allowed), keeps
  it fresh (builds expire after 90 days), runs and restarts it, and drives
  it over its local WebSocket API; its events feed Most szól.
- It needs the user's own Soloist API key: the key screen shows a QR code
  to a small page on the TV where the phone pastes it (or type it on the
  TV); asked once after sign-in, also in Settings. Then the TV is picked
  once in the phone's Spotify app (pairing); home shows that step.
- Soloist is the Connect device; librespot only signs in (pairing code)
  and browses. Its player, Connect and zeroconf are gone, and with them
  GStreamer.
- A track from a list plays and the next ones are queued (Soloist's play
  takes one URI). The queue panel is back (Soloist reports the queue).
- Settings: the player's state and key instead of quality/normalisation/
  autoplay (Soloist decides those).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-03 21:50:44 +01:00

406 lines
15 KiB
Plaintext

// Most szól: the cover, the title, the progress and the controls. With the
// lyrics or the queue open, the cover and the texts move to the left and a
// glass panel holds the lyrics / the queue on the right.
//
// Rust owns the focus: `button` is the focused button (0..7), `area` 1 means
// the progress bar (left/right seek there).
import { Tv, GlassRect, GlassPane, Spinner, Caption } from "@sf-ui/sf-ui.slint";
import { QueueItem } from "types.slint";
import { SpIcon } from "icons.slint";
import { Accent, Equalizer } from "page.slint";
// A round glass control. `on`: a toggle that is on (green icon and dot).
component NpButton inherits Rectangle {
in property <string> icon;
in property <bool> focused;
in property <bool> on;
in property <bool> primary;
in property <float> alpha: 1;
in property <length> size: 80 * Tv.u;
out property <float> f: self.focused ? 1 : 0;
animate f { duration: 220ms; easing: cubic-bezier(0.22, 1, 0.36, 1); }
property <float> s: 1 + 0.08 * self.f;
width: self.size;
height: self.size;
SpIcon {
name: root.icon;
size: root.size * (root.primary ? 0.46 : 0.42);
ink: root.focused ? Tv.ink : root.primary ? #121317 : root.on ? Accent.green : Tv.text;
opacity: root.alpha;
}
if root.on: Rectangle {
x: (parent.width - self.width) / 2;
y: parent.height - 14 * Tv.u;
width: 7 * Tv.u;
height: 7 * Tv.u;
border-radius: self.width / 2;
background: root.focused ? Tv.ink : Accent.green;
opacity: root.alpha;
}
out property <GlassRect> glass: {
x: self.absolute-position.x - self.width * (self.s - 1) / 2,
y: self.absolute-position.y - self.height * (self.s - 1) / 2,
w: self.width * self.s,
h: self.height * self.s,
r: self.height * self.s / 2,
focus: self.f,
alpha: self.alpha,
blur: 1.4,
glow: self.primary ? Accent.green : #ffffff,
tint: self.primary ? (self.focused ? #ffffff.with-alpha(0.9) : Accent.green.with-alpha(0.92)) : #ffffff.with-alpha(0.06 + 0.82 * self.f),
group: 0,
};
}
export component NowPlayingScreen inherits Rectangle {
in property <float> alpha: 1;
in property <string> title;
in property <string> artist;
in property <string> album;
in property <image> art;
in property <bool> explicit;
in property <bool> episode;
in property <bool> playing;
in property <bool> loading;
in property <float> progress;
in property <string> time;
in property <string> duration;
in property <bool> shuffle;
// 0 off, 1 the list, 2 this track
in property <int> repeat;
// -1 unknown, 0 no, 1 yes
in property <int> liked: -1;
in property <int> button: 2;
in property <int> area;
// 0 none, 1 lyrics, 2 queue
in property <int> panel;
in property <[string]> lyrics;
in property <int> lyric-line: -1;
in property <bool> lyrics-synced;
in property <string> lyrics-note;
in property <[QueueItem]> queue;
in property <string> queue-note;
in property <string> device;
// 0: the big layout, 1: side by side with the panel.
out property <float> t: self.panel != 0 ? 1 : 0;
animate t { duration: 520ms; easing: cubic-bezier(0.22, 1, 0.36, 1); }
pure function mix(a: float, b: float) -> length {
(a + (b - a) * root.t) * Tv.u
}
// ---- cover ----
property <length> cover-size: root.mix(600, 360);
Rectangle {
x: root.mix(170, 120);
y: root.mix(190, 120);
width: root.cover-size;
height: root.cover-size;
opacity: root.alpha;
Rectangle {
border-radius: 20 * Tv.u;
background: #1b1d24;
drop-shadow-blur: 60 * Tv.u;
drop-shadow-offset-y: 24 * Tv.u;
drop-shadow-color: #000000b0;
}
Rectangle {
border-radius: 20 * Tv.u;
clip: true;
Image {
width: 100%;
height: 100%;
source: root.art;
image-fit: cover;
}
if root.loading: Rectangle {
background: #00000080;
Spinner { size: 72 * Tv.u; }
}
}
}
// ---- texts ----
property <length> tx: root.mix(870, 120);
property <length> tw: root.mix(900, 620);
property <length> ty: root.mix(220, 520);
HorizontalLayout {
x: root.tx;
y: root.ty;
width: root.tw;
height: 36 * Tv.u;
spacing: 12 * Tv.u;
alignment: start;
opacity: root.alpha;
Equalizer {
y: (parent.height - self.height) / 2;
size: 22 * Tv.u;
moving: root.playing;
}
Text {
vertical-alignment: center;
text: root.device;
font-size: 22 * Tv.u;
font-weight: 600;
color: Accent.green;
overflow: elide;
}
}
title-text := Text {
x: root.tx;
y: root.ty + root.mix(52, 44);
width: root.tw;
height: min(self.preferred-height, root.mix(170, 64));
vertical-alignment: top;
text: root.title;
font-size: root.panel != 0 ? 40 * Tv.u : (root.title.character-count > 30 ? 52 : 68) * Tv.u;
font-weight: 700;
letter-spacing: -1.5 * Tv.u;
color: Tv.text;
wrap: root.panel != 0 ? no-wrap : word-wrap;
overflow: elide;
opacity: root.alpha;
}
HorizontalLayout {
x: root.tx;
y: title-text.y + title-text.height + 10 * Tv.u;
width: root.tw;
height: 44 * Tv.u;
spacing: 12 * Tv.u;
alignment: start;
opacity: root.alpha;
if root.explicit: Rectangle {
y: (parent.height - self.height) / 2;
width: 28 * Tv.u;
height: 28 * Tv.u;
border-radius: 5 * Tv.u;
background: #ffffffb0;
Text {
text: "E";
font-size: 18 * Tv.u;
font-weight: 700;
color: #121317;
}
}
Text {
vertical-alignment: center;
text: root.artist;
font-size: root.mix(34, 28);
font-weight: 600;
color: Tv.text-secondary;
overflow: elide;
}
}
Text {
x: root.tx;
y: title-text.y + title-text.height + 58 * Tv.u;
width: root.tw;
text: root.album;
font-size: 24 * Tv.u;
color: Tv.text-tertiary;
overflow: elide;
opacity: root.alpha;
}
// ---- progress ----
property <length> py: root.ty + root.mix(400, 236);
property <float> pf: root.area == 1 ? 1 : 0;
animate pf { duration: 200ms; easing: ease-out; }
property <length> rail-h: (8 + 6 * self.pf) * Tv.u;
rail := Rectangle {
x: root.tx;
y: root.py - root.rail-h / 2;
width: root.tw;
height: root.rail-h;
opacity: root.alpha;
Rectangle {
x: 0;
width: parent.width * clamp(root.progress, 0, 1);
border-radius: parent.height / 2;
background: root.pf > 0.5 ? Accent.green : #ffffff;
}
if root.area == 1: Rectangle {
x: parent.width * clamp(root.progress, 0, 1) - self.width / 2;
y: (parent.height - self.height) / 2;
width: 28 * Tv.u;
height: 28 * Tv.u;
border-radius: self.width / 2;
background: #ffffff;
drop-shadow-blur: 10 * Tv.u;
drop-shadow-color: #00000080;
}
}
Text {
x: root.tx;
y: root.py + 22 * Tv.u;
text: root.time;
font-size: 22 * Tv.u;
font-weight: 600;
color: Tv.text-secondary;
opacity: root.alpha;
}
Text {
x: root.tx;
y: root.py + 22 * Tv.u;
width: root.tw;
horizontal-alignment: right;
text: root.area == 1 ? "◀ ▶ tekerés" : root.duration;
font-size: 22 * Tv.u;
font-weight: 600;
color: root.area == 1 ? Accent.green : Tv.text-secondary;
opacity: root.alpha;
}
// ---- buttons ----
property <length> bs: root.mix(80, 64);
property <length> gap: root.mix(22, 12);
controls := HorizontalLayout {
x: root.tx;
y: root.py + root.mix(90, 76);
height: root.bs * 1.25;
spacing: root.gap;
alignment: start;
b0 := NpButton { y: (parent.height - self.height) / 2; icon: "shuffle"; size: root.bs; on: root.shuffle; focused: root.area == 0 && root.button == 0; alpha: root.alpha * (root.episode ? 0.4 : 1); }
b1 := NpButton { y: (parent.height - self.height) / 2; icon: "previous"; size: root.bs; focused: root.area == 0 && root.button == 1; alpha: root.alpha; }
b2 := NpButton { y: (parent.height - self.height) / 2; icon: root.playing ? "pause" : "play"; size: root.bs * 1.25; primary: true; focused: root.area == 0 && root.button == 2; alpha: root.alpha; }
b3 := NpButton { y: (parent.height - self.height) / 2; icon: "next"; size: root.bs; focused: root.area == 0 && root.button == 3; alpha: root.alpha; }
b4 := NpButton { y: (parent.height - self.height) / 2; icon: root.repeat == 2 ? "repeat-one" : "repeat"; size: root.bs; on: root.repeat > 0; focused: root.area == 0 && root.button == 4; alpha: root.alpha; }
Rectangle { width: root.mix(24, 6); }
b5 := NpButton { y: (parent.height - self.height) / 2; icon: root.liked == 1 ? "heart-filled" : "heart"; size: root.bs; on: root.liked == 1; focused: root.area == 0 && root.button == 5; alpha: root.alpha * (root.liked < 0 ? 0.4 : 1); }
b6 := NpButton { y: (parent.height - self.height) / 2; icon: "lyrics"; size: root.bs; on: root.panel == 1; focused: root.area == 0 && root.button == 6; alpha: root.alpha; }
b7 := NpButton { y: (parent.height - self.height) / 2; icon: "queue"; size: root.bs; on: root.panel == 2; focused: root.area == 0 && root.button == 7; alpha: root.alpha; }
}
property <[string]> hints: ["Keverés", "Előző", root.playing ? "Szünet" : "Lejátszás", "Következő", "Ismétlés", "Kedvelés", "Dalszöveg", "Lejátszási sor"];
Caption {
x: root.tx;
y: controls.y + controls.height + 18 * Tv.u;
width: root.tw;
text: root.area == 0 ? root.hints[root.button] : "";
opacity: root.alpha;
}
// ---- the panel: lyrics or the queue ----
property <float> pa: root.alpha * clamp(root.t * 1.6 - 0.6, 0, 1);
panel-pane := GlassPane {
x: 820 * Tv.u;
y: 90 * Tv.u;
width: 1000 * Tv.u;
height: 900 * Tv.u;
radius: 48 * Tv.u;
frost: 3.2;
tint: Tv.smoke.with-alpha(0.38);
alpha: root.panel != 0 ? root.pa : 0;
visible: root.t > 0.01;
// lyrics
if root.panel == 1: Rectangle {
clip: true;
opacity: root.pa;
property <length> line-h: 76 * Tv.u;
property <length> offset: root.lyrics-synced && root.lyric-line >= 0 ? self.height * 0.38 - root.lyric-line * self.line-h : 56 * Tv.u;
animate offset { duration: 420ms; easing: cubic-bezier(0.22, 1, 0.36, 1); }
for l[i] in root.lyrics: Text {
x: 64 * Tv.u;
y: parent.offset + i * parent.line-h;
width: parent.width - 128 * Tv.u;
height: parent.line-h;
vertical-alignment: center;
text: l == "" ? "♪" : l;
font-size: 38 * Tv.u;
font-weight: 700;
color: !root.lyrics-synced ? Tv.text : i == root.lyric-line ? Tv.text : i < root.lyric-line ? #ffffff66 : #ffffff8c;
overflow: elide;
animate color { duration: 300ms; }
}
if root.lyrics-note != "": Text {
x: 64 * Tv.u;
width: parent.width - 128 * Tv.u;
horizontal-alignment: center;
text: root.lyrics-note;
font-size: 30 * Tv.u;
font-weight: 600;
color: Tv.text-secondary;
wrap: word-wrap;
}
}
// queue
if root.panel == 2: Rectangle {
clip: true;
opacity: root.pa;
Text {
x: 56 * Tv.u;
y: 44 * Tv.u;
text: "Következik";
font-size: 38 * Tv.u;
font-weight: 700;
color: Tv.text;
}
for q[i] in root.queue: Rectangle {
x: 56 * Tv.u;
y: (120 + i * 84) * Tv.u;
width: parent.width - 112 * Tv.u;
height: 72 * Tv.u;
Rectangle {
x: 0;
width: 64 * Tv.u;
height: 64 * Tv.u;
y: 4 * Tv.u;
border-radius: 8 * Tv.u;
clip: true;
background: #1b1d24;
Image {
width: 100%;
height: 100%;
source: q.image;
image-fit: cover;
}
}
Text {
x: 88 * Tv.u;
y: 6 * Tv.u;
width: parent.width - 88 * Tv.u;
text: q.title;
font-size: 26 * Tv.u;
font-weight: 600;
color: Tv.text;
overflow: elide;
}
Text {
x: 88 * Tv.u;
y: 40 * Tv.u;
width: parent.width - 88 * Tv.u;
text: q.artist;
font-size: 21 * Tv.u;
color: Tv.text-tertiary;
overflow: elide;
}
}
if root.queue-note != "": Text {
x: 56 * Tv.u;
y: 130 * Tv.u;
text: root.queue-note;
font-size: 26 * Tv.u;
color: Tv.text-secondary;
}
}
}
out property <[GlassRect]> glass: [
{
x: rail.absolute-position.x,
y: rail.absolute-position.y,
w: rail.width,
h: rail.height,
r: rail.height / 2,
focus: root.pf,
alpha: root.alpha,
blur: 1.2,
glow: Accent.green,
tint: #ffffff.with-alpha(0.14 + 0.1 * root.pf),
group: 0,
},
b0.glass, b1.glass, b2.glass, b3.glass, b4.glass, b5.glass, b6.glass, b7.glass,
panel-pane.glass,
];
}