All checks were successful
release / release (push) Successful in 10m13s
Replaces the web app (youtube.com/tv in Chromium) with a native Rust + Slint client on sf-ui, built on Netflex TV's page engine. - InnerTube: web client for public pages, the TV client with the account's OAuth token for personal ones, visionOS (direct URLs) for streams, the TV client with yt-dlp's ejs solver (QuickJS) as fallback. - One version, no ads: ad breaks are never requested, ad renderers are skipped in feeds. SponsorBlock skips sponsored parts. - Sign-in with a QR code / youtube.com/activate (OAuth device flow). - Signed out: subscriptions and history on the TV; a home filled with this week's popular Hungarian videos when YouTube's is empty. - Playback: one-quality DASH manifest for GStreamer, H.264 up to 1080p or AV1 up to 4K, captions, quality switching, up next, resume. - Release builds for x86-64 and the Raspberry Pi (aarch64). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
342 lines
12 KiB
Plaintext
342 lines
12 KiB
Plaintext
// Playback. The video itself is the glass backdrop (Rust: glass.set_video),
|
|
// so the controls are glass that refracts the picture. (From Netflex TV.)
|
|
//
|
|
// Stages: "prep" (asking YouTube for the formats), "play", "error". With
|
|
// the controls hidden the remote drives playback directly (OK =
|
|
// play/pause, left/right = seek); shown, up/down moves between the seek
|
|
// bar and the buttons. All focus state is Rust's.
|
|
|
|
import { Tv, GlassRect, GlassPane, GlassButton, GlassMenu, MenuItem, ProgressBar, Spinner, Title, Label, Caption, Item, Icon } from "@sf-ui/sf-ui.slint";
|
|
|
|
export component PlayerScreen inherits Rectangle {
|
|
in property <float> alpha: 1;
|
|
in property <string> stage: "prep";
|
|
in property <string> title;
|
|
// The channel, above the title.
|
|
in property <string> heading;
|
|
// "1080p · 1,2 M megtekintés · Felirat: Magyar"
|
|
in property <string> info;
|
|
// The caption line at the current position.
|
|
in property <string> caption;
|
|
in property <string> stage-text;
|
|
in property <string> detail-text;
|
|
in property <string> error-text;
|
|
// Playing.
|
|
in property <bool> osd;
|
|
in property <bool> paused;
|
|
in property <bool> buffering;
|
|
in property <string> buffer-text;
|
|
in property <float> progress;
|
|
in property <float> buffered;
|
|
in property <string> time-text;
|
|
in property <string> remaining-text;
|
|
in property <string> downloaded-text;
|
|
// Seeking with left/right: the target and how far it is.
|
|
in property <bool> seeking;
|
|
in property <string> seek-text;
|
|
in property <string> seek-delta;
|
|
in property <bool> seek-back;
|
|
// Controls: 0 = seek bar, 1 = buttons; which button.
|
|
in property <int> osd-area;
|
|
in property <int> osd-button;
|
|
in property <bool> has-next;
|
|
in property <bool> has-channel;
|
|
// Panel: 0 = closed, 1 = captions focused, 2 = quality focused.
|
|
in property <int> panel;
|
|
in property <[MenuItem]> subs;
|
|
in property <[MenuItem]> quality;
|
|
in property <int> subs-focus;
|
|
in property <int> quality-focus;
|
|
// Unused (kept for the shared layout).
|
|
in property <string> skip-label;
|
|
// The end: "Következik" card.
|
|
in property <string> next-label;
|
|
in property <string> next-text;
|
|
|
|
out property <float> osd-t: self.stage == "play" && (self.osd || self.paused || self.panel > 0) ? 1 : 0;
|
|
animate osd-t { duration: 320ms; easing: cubic-bezier(0.22, 1, 0.36, 1); }
|
|
out property <float> panel-t: self.panel > 0 ? 1 : 0;
|
|
animate panel-t { duration: 360ms; easing: cubic-bezier(0.22, 1, 0.36, 1); }
|
|
property <float> prep-a: self.alpha * (self.stage == "play" ? 0 : 1);
|
|
property <float> osd-a: self.alpha * self.osd-t;
|
|
property <bool> buttons: self.osd-t > 0.5 && self.osd-area == 1 && self.panel == 0;
|
|
|
|
// Darkens the film behind the controls (Slint over video is fine).
|
|
Rectangle {
|
|
y: root.height * 0.5;
|
|
height: root.height * 0.5;
|
|
background: @linear-gradient(180deg, #00000000 0%, #000000b8 100%);
|
|
opacity: root.osd-a;
|
|
}
|
|
|
|
// ---- preparing / error ----
|
|
VerticalLayout {
|
|
x: Tv.safe-x;
|
|
width: root.width - 2 * Tv.safe-x;
|
|
y: 330 * Tv.u;
|
|
height: 460 * Tv.u;
|
|
spacing: 24 * Tv.u;
|
|
alignment: start;
|
|
opacity: root.prep-a;
|
|
if root.stage == "prep": HorizontalLayout {
|
|
alignment: center;
|
|
Spinner { size: 72 * Tv.u; }
|
|
}
|
|
if root.stage == "error": HorizontalLayout {
|
|
alignment: center;
|
|
Icon { name: "warning"; size: 64 * Tv.u; ink: Tv.danger-ink; }
|
|
}
|
|
Title {
|
|
horizontal-alignment: center;
|
|
text: root.stage == "error" ? "Nem sikerült elindítani" : root.heading == "" ? root.title : root.title + " · " + root.heading;
|
|
}
|
|
Label {
|
|
horizontal-alignment: center;
|
|
text: root.stage == "error" ? root.error-text : root.stage-text;
|
|
wrap: word-wrap;
|
|
color: Tv.text-secondary;
|
|
}
|
|
Caption {
|
|
horizontal-alignment: center;
|
|
text: root.stage == "error" ? "Vissza: vissza a listához" : root.detail-text;
|
|
wrap: word-wrap;
|
|
}
|
|
}
|
|
|
|
// ---- buffering ----
|
|
buf := GlassPane {
|
|
x: (root.width - self.width) / 2;
|
|
y: (root.height - self.height) / 2;
|
|
width: 620 * Tv.u;
|
|
height: 190 * Tv.u;
|
|
radius: 40 * Tv.u;
|
|
frost: 3.2;
|
|
tint: Tv.smoke.with-alpha(0.4);
|
|
alpha: root.stage == "play" && root.buffering && !root.seeking ? root.alpha : 0;
|
|
VerticalLayout {
|
|
padding: 32 * Tv.u;
|
|
spacing: 20 * Tv.u;
|
|
alignment: center;
|
|
opacity: parent.alpha;
|
|
HorizontalLayout {
|
|
alignment: center;
|
|
Spinner { size: 56 * Tv.u; }
|
|
}
|
|
Label {
|
|
horizontal-alignment: center;
|
|
text: root.buffer-text == "" ? "Betöltés…" : root.buffer-text;
|
|
overflow: elide;
|
|
}
|
|
}
|
|
}
|
|
if root.stage == "play" && root.paused && !root.buffering && root.panel == 0 && !root.seeking && root.next-label == "": Icon {
|
|
x: (root.width - self.width) / 2;
|
|
y: (root.height - self.height) / 2 - 60 * Tv.u;
|
|
name: "pause";
|
|
size: 96 * Tv.u;
|
|
opacity: 0.85 * root.alpha;
|
|
}
|
|
|
|
// ---- seek preview ----
|
|
seek := GlassPane {
|
|
x: (root.width - self.width) / 2;
|
|
y: (root.height - self.height) / 2 - 60 * Tv.u;
|
|
width: 520 * Tv.u;
|
|
height: 108 * Tv.u;
|
|
radius: self.height / 2;
|
|
frost: 3.0;
|
|
tint: Tv.smoke.with-alpha(0.4);
|
|
alpha: root.stage == "play" && root.seeking ? root.alpha : 0;
|
|
HorizontalLayout {
|
|
alignment: center;
|
|
spacing: 18 * Tv.u;
|
|
opacity: parent.alpha;
|
|
Icon {
|
|
y: (parent.height - self.height) / 2;
|
|
name: root.seek-back ? "rewind" : "fast-forward";
|
|
size: 40 * Tv.u;
|
|
}
|
|
Text {
|
|
vertical-alignment: center;
|
|
text: root.seek-text;
|
|
font-size: 44 * Tv.u;
|
|
font-weight: 700;
|
|
color: Tv.text;
|
|
}
|
|
Text {
|
|
vertical-alignment: center;
|
|
text: root.seek-delta;
|
|
font-size: 26 * Tv.u;
|
|
color: Tv.text-secondary;
|
|
}
|
|
}
|
|
}
|
|
|
|
// ---- captions (Slint over the video, above the controls when shown) ----
|
|
if root.stage == "play" && root.caption != "": Rectangle {
|
|
property <length> bottom: (root.osd-t > 0.5 ? 400 : 90) * Tv.u;
|
|
x: (root.width - self.width) / 2;
|
|
y: root.height - self.bottom - self.height;
|
|
width: min(1500 * Tv.u, cap.preferred-width + 48 * Tv.u);
|
|
height: cap.preferred-height + 20 * Tv.u;
|
|
border-radius: 12 * Tv.u;
|
|
background: #000000b0;
|
|
animate y { duration: 220ms; easing: ease-out; }
|
|
cap := Text {
|
|
width: min(1452 * Tv.u, self.preferred-width);
|
|
text: root.caption;
|
|
font-size: 38 * Tv.u;
|
|
font-weight: 600;
|
|
color: #ffffff;
|
|
horizontal-alignment: center;
|
|
wrap: word-wrap;
|
|
}
|
|
}
|
|
|
|
// ---- up next ----
|
|
upnext := GlassPane {
|
|
x: root.width - Tv.safe-x - self.width;
|
|
y: root.height - 380 * Tv.u;
|
|
width: 620 * Tv.u;
|
|
height: 168 * Tv.u;
|
|
radius: 40 * Tv.u;
|
|
frost: 3.2;
|
|
tint: Tv.smoke.with-alpha(0.42);
|
|
alpha: root.next-label != "" ? root.alpha : 0;
|
|
VerticalLayout {
|
|
padding: 32 * Tv.u;
|
|
spacing: 6 * Tv.u;
|
|
opacity: parent.alpha;
|
|
Caption { text: "KÖVETKEZIK"; letter-spacing: 2 * Tv.u; }
|
|
Title { text: root.next-label; font-size: 30 * Tv.u; overflow: elide; }
|
|
Label { text: root.next-text; }
|
|
}
|
|
}
|
|
|
|
// ---- controls ----
|
|
Rectangle {
|
|
x: Tv.safe-x;
|
|
y: root.height - 360 * Tv.u + (1 - root.osd-t) * 30 * Tv.u;
|
|
width: root.width - 2 * Tv.safe-x;
|
|
height: 300 * Tv.u;
|
|
opacity: root.osd-a;
|
|
Text {
|
|
x: 0;
|
|
y: 0;
|
|
text: root.heading;
|
|
font-size: 24 * Tv.u;
|
|
font-weight: 700;
|
|
color: #ff8a8a;
|
|
width: parent.width - 420 * Tv.u;
|
|
overflow: elide;
|
|
}
|
|
Text {
|
|
x: 0;
|
|
y: 34 * Tv.u;
|
|
width: parent.width - 420 * Tv.u;
|
|
text: root.title;
|
|
font-size: 44 * Tv.u;
|
|
font-weight: 700;
|
|
letter-spacing: -0.8 * Tv.u;
|
|
color: Tv.text;
|
|
overflow: elide;
|
|
}
|
|
Caption {
|
|
x: 0;
|
|
y: 96 * Tv.u;
|
|
width: parent.width - 420 * Tv.u;
|
|
text: root.info;
|
|
color: Tv.text-secondary;
|
|
}
|
|
Caption {
|
|
x: parent.width - 400 * Tv.u;
|
|
y: 96 * Tv.u;
|
|
width: 400 * Tv.u;
|
|
horizontal-alignment: right;
|
|
text: root.downloaded-text;
|
|
}
|
|
Text {
|
|
x: 0;
|
|
y: 172 * Tv.u;
|
|
text: root.time-text;
|
|
font-size: 24 * Tv.u;
|
|
font-weight: 600;
|
|
color: Tv.text;
|
|
}
|
|
Text {
|
|
x: parent.width - 300 * Tv.u;
|
|
y: 172 * Tv.u;
|
|
width: 300 * Tv.u;
|
|
horizontal-alignment: right;
|
|
text: root.remaining-text;
|
|
font-size: 24 * Tv.u;
|
|
font-weight: 600;
|
|
color: Tv.text-secondary;
|
|
}
|
|
}
|
|
bar := ProgressBar {
|
|
x: Tv.safe-x;
|
|
y: root.height - 222 * Tv.u + (1 - root.osd-t) * 30 * Tv.u;
|
|
width: root.width - 2 * Tv.safe-x;
|
|
height: (root.osd-area == 0 && root.panel == 0 ? 14 : 10) * Tv.u;
|
|
value: root.progress;
|
|
buffered: root.buffered;
|
|
fill: root.seeking ? #ff0033 : Tv.text;
|
|
nested: false;
|
|
alpha: root.osd-a;
|
|
}
|
|
HorizontalLayout {
|
|
x: Tv.safe-x;
|
|
y: root.height - 146 * Tv.u + (1 - root.osd-t) * 30 * Tv.u;
|
|
height: 72 * Tv.u;
|
|
spacing: 20 * Tv.u;
|
|
alignment: start;
|
|
b0 := GlassButton { icon: root.paused ? "play" : "pause"; focused: root.buttons && root.osd-button == 0; alpha: root.osd-a; }
|
|
b1 := GlassButton { icon: "rewind"; text: "10 mp"; focused: root.buttons && root.osd-button == 1; alpha: root.osd-a; }
|
|
b2 := GlassButton { icon: "fast-forward"; text: "10 mp"; focused: root.buttons && root.osd-button == 2; alpha: root.osd-a; }
|
|
b3 := GlassButton { icon: "next"; text: "Következő"; enabled: root.has-next; focused: root.buttons && root.osd-button == 3; alpha: root.has-next ? root.osd-a : 0; visible: root.has-next; }
|
|
b4 := GlassButton { icon: "user"; text: "Csatorna"; enabled: root.has-channel; focused: root.buttons && root.osd-button == 4; alpha: root.has-channel ? root.osd-a : 0; visible: root.has-channel; }
|
|
}
|
|
b5 := GlassButton {
|
|
width: self.preferred-width;
|
|
x: root.width - Tv.safe-x - self.width;
|
|
y: root.height - 146 * Tv.u + (1 - root.osd-t) * 30 * Tv.u;
|
|
icon: "subtitles";
|
|
text: "Felirat és minőség";
|
|
focused: root.buttons && root.osd-button == 5;
|
|
alpha: root.osd-a;
|
|
}
|
|
|
|
// ---- captions and quality panel ----
|
|
property <length> col-w: 600 * Tv.u;
|
|
property <length> panel-y: root.height - 400 * Tv.u;
|
|
m-subs := GlassMenu {
|
|
x: Tv.safe-x;
|
|
y: root.panel-y - self.height + (1 - root.panel-t) * 30 * Tv.u;
|
|
width: root.col-w;
|
|
title: "Felirat";
|
|
items: root.subs;
|
|
focused-index: root.subs-focus;
|
|
active: root.panel == 1;
|
|
alpha: root.alpha * root.panel-t;
|
|
accent: #ff0033;
|
|
visible-rows: 6;
|
|
}
|
|
m-quality := GlassMenu {
|
|
x: Tv.safe-x + root.col-w + 28 * Tv.u;
|
|
y: root.panel-y - self.height + (1 - root.panel-t) * 30 * Tv.u;
|
|
width: 400 * Tv.u;
|
|
title: "Minőség";
|
|
items: root.quality;
|
|
focused-index: root.quality-focus;
|
|
active: root.panel == 2;
|
|
alpha: root.alpha * root.panel-t;
|
|
accent: #ff0033;
|
|
visible-rows: 7;
|
|
}
|
|
|
|
out property <[GlassRect]> glass: [buf.glass, seek.glass, bar.glass, b0.glass, b1.glass, b2.glass, b3.glass, b4.glass, b5.glass, upnext.glass];
|
|
out property <[GlassRect]> glass-subs: m-subs.glass;
|
|
out property <[GlassRect]> glass-quality: m-quality.glass;
|
|
}
|