Files
spotify/ui/signin.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

350 lines
11 KiB
Plaintext

// Sign-in from the phone (Spotify Connect), the text input overlay (on a
// modal glass pane with the on-screen keyboard) and a plain message screen.
import { Tv, GlassRect, GlassPane, Keyboard, Spinner, Display, Title, Body, Label, Caption, Icon } from "@sf-ui/sf-ui.slint";
import { SpIcon } from "icons.slint";
// Sign-in, two ways: a pairing code (QR code or spotify.com/pair) or this
// TV picked in the Spotify app on the phone (Spotify Connect).
export component ConnectScreen inherits Rectangle {
in property <float> alpha: 1;
in property <string> device;
in property <string> code;
in property <image> qr;
in property <bool> busy;
in property <string> error;
pane := GlassPane {
x: (root.width - self.width) / 2;
y: (root.height - self.height) / 2 - 20 * Tv.u;
width: 1640 * Tv.u;
height: 760 * Tv.u;
radius: 56 * Tv.u;
frost: 3.6;
tint: Tv.smoke.with-alpha(0.46);
glow: #1ed760;
alpha: root.alpha;
// ---- left: title and the two ways ----
VerticalLayout {
x: 80 * Tv.u;
y: 72 * Tv.u;
width: 860 * Tv.u;
height: parent.height - 144 * Tv.u;
spacing: 18 * Tv.u;
opacity: root.alpha;
HorizontalLayout {
spacing: 24 * Tv.u;
alignment: start;
Rectangle {
width: 80 * Tv.u;
height: 80 * Tv.u;
border-radius: self.width / 2;
background: #1ed760;
SpIcon {
name: "audio";
size: 44 * Tv.u;
ink: #121317;
}
}
VerticalLayout {
alignment: center;
Title { text: "Jelentkezz be a telefonoddal"; }
Caption { text: "Spotify Premium fiók kell hozzá"; }
}
}
Rectangle { height: 14 * Tv.u; }
Text {
text: "QR-KÓDDAL";
font-size: 20 * Tv.u;
font-weight: 700;
letter-spacing: 3 * Tv.u;
color: #1ed760;
}
Body {
text: "Olvasd be a kódot a telefon kamerájával, és jelentkezz be. Vagy nyisd meg a spotify.com/pair oldalt, és írd be a kódot.";
font-size: 26 * Tv.u;
color: Tv.text;
}
Rectangle { }
HorizontalLayout {
spacing: 16 * Tv.u;
alignment: start;
height: 48 * Tv.u;
Spinner { size: 40 * Tv.u; }
Label {
vertical-alignment: center;
text: root.busy ? "Bejelentkezés…" : root.error != "" ? root.error : "Várakozás a telefonra…";
color: root.error != "" && !root.busy ? Tv.warn-ink : Tv.text-secondary;
wrap: word-wrap;
}
}
}
// ---- right: the QR code and the code ----
qr-box := Rectangle {
x: parent.width - self.width - 96 * Tv.u;
y: 80 * Tv.u;
width: 440 * Tv.u;
height: 440 * Tv.u;
border-radius: 28 * Tv.u;
background: #ffffff;
opacity: root.alpha;
clip: true;
if root.qr.width > 0: Image {
x: 20 * Tv.u;
y: 20 * Tv.u;
width: parent.width - 40 * Tv.u;
height: parent.height - 40 * Tv.u;
source: root.qr;
image-rendering: pixelated;
}
if root.qr.width == 0: Spinner {
size: 64 * Tv.u;
ink: #121317;
}
}
Text {
x: qr-box.x;
y: qr-box.y + qr-box.height + 28 * Tv.u;
width: qr-box.width;
horizontal-alignment: center;
text: "spotify.com/pair";
font-size: 24 * Tv.u;
font-weight: 600;
color: Tv.text-secondary;
opacity: root.alpha;
}
Text {
x: qr-box.x;
y: qr-box.y + qr-box.height + 66 * Tv.u;
width: qr-box.width;
horizontal-alignment: center;
text: root.code;
font-size: 64 * Tv.u;
font-weight: 700;
letter-spacing: 10 * Tv.u;
color: Tv.text;
opacity: root.alpha;
}
}
Caption {
x: pane.x;
y: pane.y + pane.height + 28 * Tv.u;
width: pane.width;
horizontal-alignment: center;
text: "Vissza: kilépés";
opacity: root.alpha;
}
out property <[GlassRect]> glass: [pane.glass];
}
// A text field over everything (the TV's name...).
export component InputScreen inherits Rectangle {
in property <float> alpha: 1;
in property <string> title;
in property <string> subtitle;
in property <string> placeholder;
in property <string> submit-label: "Kész";
in property <int> min-length: 1;
in-out property <string> text;
in-out property <string> error;
callback submitted(string);
callback cancelled();
public function key(event: KeyEvent) -> EventResult {
kb.key(event)
}
public function reset() {
kb.reset();
}
pane := GlassPane {
x: (root.width - self.width) / 2;
y: (root.height - self.height) / 2 - 24 * Tv.u;
width: 1720 * Tv.u;
height: 720 * Tv.u;
radius: 56 * Tv.u;
frost: 3.8;
tint: Tv.smoke.with-alpha(0.48);
glow: #1ed760;
alpha: root.alpha;
kb := Keyboard {
x: 0;
y: 72 * Tv.u;
width: parent.width;
title: root.title;
subtitle: root.subtitle;
placeholder: root.placeholder;
submit-label: root.submit-label;
min-length: root.min-length;
max-length: 60;
alpha: root.alpha;
active: true;
text <=> root.text;
error <=> root.error;
submitted(t) => { root.submitted(t); }
cancelled => { root.cancelled(); }
}
}
out property <[GlassRect]> glass: [pane.glass];
out property <[GlassRect]> glass-keyboard: kb.glass;
}
// Loading and errors.
export component MessageScreen inherits Rectangle {
in property <float> alpha: 1;
in property <bool> busy;
in property <string> title;
in property <string> text;
VerticalLayout {
x: Tv.safe-x;
width: root.width - 2 * Tv.safe-x;
y: 340 * Tv.u;
height: 400 * Tv.u;
spacing: 24 * Tv.u;
alignment: start;
opacity: root.alpha;
HorizontalLayout {
alignment: center;
if root.busy: Spinner { size: 72 * Tv.u; }
if !root.busy: Icon { name: "warning"; size: 64 * Tv.u; ink: Tv.warn-ink; }
}
Title {
horizontal-alignment: center;
text: root.title;
}
Label {
horizontal-alignment: center;
text: root.text;
wrap: word-wrap;
}
Caption {
horizontal-alignment: center;
text: root.busy ? "" : "Újrapróbálkozik magától. Vissza: kilépés";
}
}
}
// The Soloist API key: a QR code to a page on this TV where the phone pastes
// the key (src/keyserver.rs). OK types it on the TV, Back: later.
export component KeyScreen inherits Rectangle {
in property <float> alpha: 1;
in property <image> qr;
in property <string> url;
pane := GlassPane {
x: (root.width - self.width) / 2;
y: (root.height - self.height) / 2 - 20 * Tv.u;
width: 1640 * Tv.u;
height: 760 * Tv.u;
radius: 56 * Tv.u;
frost: 3.6;
tint: Tv.smoke.with-alpha(0.46);
glow: #1ed760;
alpha: root.alpha;
VerticalLayout {
x: 80 * Tv.u;
y: 72 * Tv.u;
width: 860 * Tv.u;
height: parent.height - 144 * Tv.u;
spacing: 18 * Tv.u;
opacity: root.alpha;
HorizontalLayout {
spacing: 24 * Tv.u;
alignment: start;
Rectangle {
width: 80 * Tv.u;
height: 80 * Tv.u;
border-radius: self.width / 2;
background: #1ed760;
SpIcon {
name: "audio";
size: 44 * Tv.u;
ink: #121317;
}
}
VerticalLayout {
alignment: center;
Title { text: "Még egy lépés: a lejátszó"; }
Caption { text: "A Spotify Soloist saját kulccsal indul"; }
}
}
Rectangle { height: 14 * Tv.u; }
Body {
text: "A zenét a Spotify saját TV-s lejátszója, a Soloist játssza. Ehhez kell egy kulcs a Spotify-fiókodból (Premium).";
font-size: 26 * Tv.u;
color: Tv.text;
}
Text {
text: "1. A TELEFONON";
font-size: 20 * Tv.u;
font-weight: 700;
letter-spacing: 3 * Tv.u;
color: #1ed760;
}
Body {
text: "Nyisd meg: developer.spotify.com/dashboard/soloist, és hozz létre egy kulcsot.";
font-size: 26 * Tv.u;
color: Tv.text;
}
Text {
text: "2. QR-KÓDDAL A TV-RE";
font-size: 20 * Tv.u;
font-weight: 700;
letter-spacing: 3 * Tv.u;
color: #1ed760;
}
Body {
text: "Olvasd be a kódot, és illeszd be a kulcsot. A telefon ugyanazon a Wi-Fin legyen, mint a TV.";
font-size: 26 * Tv.u;
color: Tv.text;
}
Rectangle { }
Caption { text: "OK: beírás a TV-n · Vissza: később (a Beállításokban is megadhatod)"; }
}
qr-box := Rectangle {
x: parent.width - self.width - 96 * Tv.u;
y: 80 * Tv.u;
width: 440 * Tv.u;
height: 440 * Tv.u;
border-radius: 28 * Tv.u;
background: #ffffff;
opacity: root.alpha;
clip: true;
if root.qr.width > 0: Image {
x: 20 * Tv.u;
y: 20 * Tv.u;
width: parent.width - 40 * Tv.u;
height: parent.height - 40 * Tv.u;
source: root.qr;
image-rendering: pixelated;
}
if root.qr.width == 0: Text {
text: "Nincs hálózat";
color: #121317;
font-size: 26 * Tv.u;
}
}
Text {
x: qr-box.x;
y: qr-box.y + qr-box.height + 28 * Tv.u;
width: qr-box.width;
horizontal-alignment: center;
text: root.url;
font-size: 26 * Tv.u;
font-weight: 600;
color: Tv.text-secondary;
opacity: root.alpha;
}
}
out property <[GlassRect]> glass: [pane.glass];
}