Skip to content

Commit b7fd88f

Browse files
committed
feat: Add simple mockup and implementation of the GJS-based UI for media playback
1 parent c41c23b commit b7fd88f

File tree

6 files changed

+268
-0
lines changed

6 files changed

+268
-0
lines changed

mockups/playback/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.sass-cache
2+
out

mockups/playback/Makefile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
all: build
2+
3+
build:
4+
mkdir -p out
5+
cp video.webp out
6+
scss main.scss out/main.css
7+
blueprint-compiler compile --output out/window.ui window.blp
8+
esbuild --bundle --outfile=out/main.js '--external:gi://*' --platform=neutral main.js
9+
10+
run: build
11+
gjs -m out/main.js
12+
13+
clean:
14+
rm -rf out

mockups/playback/main.js

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
import Adw from "gi://Adw?version=1";
2+
import GObject from "gi://GObject";
3+
import GLib from "gi://GLib";
4+
import Gio from "gi://Gio";
5+
import Gtk from "gi://Gtk?version=4.0";
6+
7+
const application = new Adw.Application({
8+
application_id: "com.pojtinger.felicitas.multiplex.mockups.playback",
9+
});
10+
11+
const dirname = GLib.path_get_dirname(
12+
GLib.Uri.parse(import.meta.url, GLib.UriFlags.NONE).get_path()
13+
);
14+
15+
const Window = GObject.registerClass(
16+
{
17+
GTypeName: "MultiplexWindow",
18+
Template: GLib.filename_to_uri(
19+
GLib.build_filenamev([dirname, "window.ui"]),
20+
null
21+
),
22+
InternalChildren: ["video_player", "video_metadata", "video_controls"],
23+
},
24+
class MultiplexWindow extends Adw.Window {
25+
constructor(...args) {
26+
super(...args);
27+
28+
let hideTimeout;
29+
const resetTimeout = () => {
30+
if (hideTimeout) {
31+
GLib.source_remove(hideTimeout);
32+
}
33+
34+
hideTimeout = GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, 3, () => {
35+
this._video_metadata.reveal_child = false;
36+
this._video_controls.reveal_child = false;
37+
38+
hideTimeout = undefined;
39+
40+
return GLib.SOURCE_REMOVE;
41+
});
42+
};
43+
resetTimeout();
44+
45+
const controller = new Gtk.EventControllerMotion();
46+
controller.connect("motion", () => {
47+
this._video_metadata.reveal_child = true;
48+
this._video_controls.reveal_child = true;
49+
50+
resetTimeout();
51+
});
52+
this.add_controller(controller);
53+
}
54+
55+
get videoPlayer() {
56+
return this._video_player;
57+
}
58+
}
59+
);
60+
61+
application.connect("activate", () => {
62+
const window = new Window({
63+
application,
64+
});
65+
66+
window.videoPlayer.file = Gio.File.new_for_uri(
67+
GLib.filename_to_uri(GLib.build_filenamev([dirname, "video.webp"]), null)
68+
);
69+
70+
const css = new Gtk.CssProvider();
71+
css.load_from_path(GLib.build_filenamev([dirname, "main.css"]));
72+
73+
Gtk.StyleContext.add_provider_for_display(
74+
window.get_display(),
75+
css,
76+
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
77+
);
78+
79+
window.show();
80+
});
81+
82+
application.run([]);

mockups/playback/main.scss

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
.video-player-headerbar {
2+
background: rgba(
3+
0,
4+
0,
5+
0,
6+
0.7
7+
); // To match even when not in focus https://gitlab.gnome.org/GNOME/libadwaita/-/blob/c174e07254aa423c704c3cdb62516249f8df5559/src/stylesheet/_colors.scss#L98
8+
}
9+
10+
.video-player-window {
11+
background: black;
12+
}

mockups/playback/video.webp

588 KB
Loading

mockups/playback/window.blp

Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
using Gtk 4.0;
2+
using Adw 1;
3+
4+
template $MultiplexWindow: Adw.Window {
5+
default-width: 1000;
6+
default-height: 700;
7+
title: _("Multiplex");
8+
9+
Overlay {
10+
Picture video_player {}
11+
12+
[overlay]
13+
Revealer video_metadata {
14+
transition-duration: 250;
15+
transition-type: crossfade;
16+
valign: start;
17+
reveal-child: true;
18+
19+
Adw.HeaderBar {
20+
show-back-button: true;
21+
22+
styles [
23+
"osd",
24+
"video-player-headerbar"
25+
]
26+
}
27+
}
28+
29+
[overlay]
30+
Revealer video_controls {
31+
transition-duration: 250;
32+
transition-type: crossfade;
33+
valign: end;
34+
reveal-child: true;
35+
36+
Box {
37+
orientation: vertical;
38+
margin-start: 24;
39+
margin-end: 24;
40+
margin-bottom: 24;
41+
42+
Box {
43+
spacing: 16;
44+
margin-start: 16;
45+
margin-end: 16;
46+
47+
Label {
48+
label: '00:00:00';
49+
tooltip-text: 'Elapsed time';
50+
51+
styles [
52+
"tabular-nums",
53+
]
54+
}
55+
56+
Scale {
57+
hexpand: true;
58+
orientation: horizontal;
59+
show-fill-level: true;
60+
61+
adjustment: Adjustment {
62+
lower: 0;
63+
upper: 100;
64+
};
65+
}
66+
67+
Label {
68+
label: '01:32:00';
69+
tooltip-text: 'Remaining time';
70+
71+
styles [
72+
"tabular-nums",
73+
]
74+
}
75+
}
76+
77+
Box {
78+
spacing: 8;
79+
80+
Box {
81+
spacing: 8;
82+
83+
Button {
84+
icon-name: "media-seek-backward-symbolic";
85+
sensitive: false;
86+
}
87+
88+
Button {
89+
icon-name: "media-playback-start-symbolic";
90+
}
91+
92+
Button {
93+
icon-name: "media-seek-forward-symbolic";
94+
sensitive: false;
95+
}
96+
}
97+
98+
Box {
99+
hexpand: true;
100+
}
101+
102+
Box {
103+
spacing: 16;
104+
105+
Box {
106+
spacing: 8;
107+
108+
Button {
109+
icon-name: "applications-engineering-symbolic";
110+
}
111+
112+
Button {
113+
icon-name: "media-optical-symbolic";
114+
}
115+
116+
Button {
117+
icon-name: "media-view-subtitles-symbolic";
118+
}
119+
}
120+
121+
Box {
122+
spacing: 8;
123+
124+
Button {
125+
icon-name: "audio-volume-medium-symbolic";
126+
}
127+
128+
Scale {
129+
orientation: horizontal;
130+
show-fill-level: true;
131+
width-request: 125;
132+
133+
adjustment: Adjustment {
134+
lower: 0;
135+
upper: 100;
136+
};
137+
}
138+
}
139+
140+
141+
Button {
142+
icon-name: "view-fullscreen-symbolic";
143+
}
144+
}
145+
}
146+
147+
styles [
148+
"toolbar",
149+
"osd"
150+
]
151+
}
152+
}
153+
}
154+
155+
styles [
156+
"video-player-window"
157+
]
158+
}

0 commit comments

Comments
 (0)