Initial Netflex TV app
This commit is contained in:
358
ui/player.slint
Normal file
358
ui/player.slint
Normal file
@@ -0,0 +1,358 @@
|
||||
// Playback. The film itself is the glass backdrop (Rust: glass.set_video),
|
||||
// so the controls are glass that refracts the picture.
|
||||
//
|
||||
// Stages: "prep" (finding the source, starting the torrent), "play",
|
||||
// "error". With the controls hidden the remote drives playback directly
|
||||
// (OK = play/pause or the skip prompt, 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;
|
||||
// Accent line above the title ("S01E03 · Pilot", "3. rész", "2024").
|
||||
in property <string> heading;
|
||||
// "HEVC 2160p · Magyar (+200 ms) · Angol felirat"
|
||||
in property <string> info;
|
||||
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-prev;
|
||||
in property <bool> has-next;
|
||||
// Track panel: 0 = closed, else the focused column + 1 (audio, subtitles, sync, quality).
|
||||
in property <int> panel;
|
||||
in property <[MenuItem]> audio;
|
||||
in property <[MenuItem]> subs;
|
||||
in property <[MenuItem]> sync;
|
||||
in property <[MenuItem]> quality;
|
||||
in property <int> audio-focus;
|
||||
in property <int> subs-focus;
|
||||
in property <int> sync-focus;
|
||||
in property <int> quality-focus;
|
||||
// Anime: "Intro átugrása"... while a segment plays.
|
||||
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 az adatlapra" : 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ---- skip prompt (anime) ----
|
||||
skip := GlassButton {
|
||||
x: root.width - Tv.safe-x - self.width;
|
||||
y: root.height - (root.osd-t > 0.5 ? 340 : 120) * Tv.u;
|
||||
text: root.skip-label;
|
||||
icon: "fast-forward";
|
||||
primary: true;
|
||||
accent: #e50914;
|
||||
focused: root.skip-label != "" && root.osd-t < 0.5 && root.panel == 0;
|
||||
alpha: root.stage == "play" && root.skip-label != "" && root.panel == 0 && root.next-label == "" ? root.alpha : 0;
|
||||
}
|
||||
|
||||
// ---- up next ----
|
||||
upnext := GlassPane {
|
||||
x: root.width - Tv.safe-x - self.width;
|
||||
y: root.height - 380 * Tv.u;
|
||||
width: 520 * 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: 34 * Tv.u; }
|
||||
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;
|
||||
}
|
||||
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 ? #e50914 : 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: "previous"; text: "Előző rész"; enabled: root.has-prev; focused: root.buttons && root.osd-button == 3; alpha: root.has-prev ? root.osd-a : 0; visible: root.has-prev; }
|
||||
b4 := GlassButton { icon: "next"; text: "Következő rész"; enabled: root.has-next; focused: root.buttons && root.osd-button == 4; alpha: root.has-next ? root.osd-a : 0; visible: root.has-next; }
|
||||
}
|
||||
b5 := GlassButton {
|
||||
x: root.width - Tv.safe-x - self.width;
|
||||
y: root.height - 146 * Tv.u + (1 - root.osd-t) * 30 * Tv.u;
|
||||
icon: "subtitles";
|
||||
text: "Hang és felirat";
|
||||
focused: root.buttons && root.osd-button == 5;
|
||||
alpha: root.osd-a;
|
||||
}
|
||||
|
||||
// ---- tracks panel ----
|
||||
property <length> col-w: 400 * Tv.u;
|
||||
property <length> panel-y: root.height - 400 * Tv.u;
|
||||
property <bool> has-quality: root.quality.length > 0;
|
||||
m-audio := GlassMenu {
|
||||
x: Tv.safe-x;
|
||||
y: root.panel-y - self.height + (1 - root.panel-t) * 30 * Tv.u;
|
||||
width: root.col-w;
|
||||
title: "Hang";
|
||||
items: root.audio;
|
||||
focused-index: root.audio-focus;
|
||||
active: root.panel == 1;
|
||||
alpha: root.alpha * root.panel-t;
|
||||
accent: #e50914;
|
||||
visible-rows: 6;
|
||||
}
|
||||
m-subs := 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: root.col-w;
|
||||
title: "Felirat";
|
||||
items: root.subs;
|
||||
focused-index: root.subs-focus;
|
||||
active: root.panel == 2;
|
||||
alpha: root.alpha * root.panel-t;
|
||||
accent: #e50914;
|
||||
visible-rows: 6;
|
||||
}
|
||||
m-sync := GlassMenu {
|
||||
x: Tv.safe-x + 2 * (root.col-w + 28 * Tv.u);
|
||||
y: root.panel-y - self.height + (1 - root.panel-t) * 30 * Tv.u;
|
||||
width: 320 * Tv.u;
|
||||
title: "Hangkésés";
|
||||
items: root.sync;
|
||||
focused-index: root.sync-focus;
|
||||
active: root.panel == 3;
|
||||
alpha: root.alpha * root.panel-t;
|
||||
accent: #e50914;
|
||||
visible-rows: 6;
|
||||
}
|
||||
m-quality := GlassMenu {
|
||||
x: Tv.safe-x + 2 * (root.col-w + 28 * Tv.u) + 348 * Tv.u;
|
||||
y: root.panel-y - self.height + (1 - root.panel-t) * 30 * Tv.u;
|
||||
width: 330 * Tv.u;
|
||||
title: "Minőség";
|
||||
items: root.quality;
|
||||
focused-index: root.quality-focus;
|
||||
active: root.panel == 4;
|
||||
alpha: root.has-quality ? root.alpha * root.panel-t : 0;
|
||||
accent: #e50914;
|
||||
visible-rows: 6;
|
||||
}
|
||||
|
||||
out property <[GlassRect]> glass: [buf.glass, seek.glass, bar.glass, b0.glass, b1.glass, b2.glass, b3.glass, b4.glass, b5.glass, skip.glass, upnext.glass];
|
||||
out property <[GlassRect]> glass-audio: m-audio.glass;
|
||||
out property <[GlassRect]> glass-subs: m-subs.glass;
|
||||
out property <[GlassRect]> glass-sync: m-sync.glass;
|
||||
out property <[GlassRect]> glass-quality: m-quality.glass;
|
||||
}
|
||||
Reference in New Issue
Block a user