Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
5ccf842
ALI-2358: Proposed design tokens for the video and music player
michaelaguiar Dec 2, 2026
2cfb136
ALI-2358: Videos and songs play, in the jailed GPU helper
michaelaguiar Dec 2, 2026
94b32da
ALI-2358: The player's controls, music view and screen-reader support
michaelaguiar Dec 2, 2026
43d0169
ALI-2358: MPRIS, so media controllers and playerctl work (work in pro…
michaelaguiar Dec 2, 2026
713294a
alias-playback: follow #3 to 6afd318 (#2's warm start, Intel and revi…
michaelaguiar Dec 2, 2026
9d4a7f3
Merge branch 'ali-2358-player-video' into ali-2358-player-ui
michaelaguiar Dec 2, 2026
9d7a6bb
Merge branch 'ali-2358-player-ui' into ali-2358-player-mpris
michaelaguiar Dec 2, 2026
8add445
Review fixes: buffers the helper sends, frames on resize, failures, F…
michaelaguiar Dec 2, 2026
6c90566
Merge #7's review fixes; #8 review fixes: focus, announcements, overl…
michaelaguiar Dec 2, 2026
d13d9cf
alias-playback: follow #3 to 74c8c87 (cover art always drawn, warm-lo…
michaelaguiar Dec 2, 2026
3eaae85
Merge branch 'ali-2358-player-video' into ali-2358-player-ui
michaelaguiar Dec 2, 2026
dea3fff
Merge branch 'ali-2358-player-ui' into ali-2358-player-mpris
michaelaguiar Dec 2, 2026
5648de2
Review round 2: a failed file's helper ends; a helper's exit code is …
michaelaguiar Dec 2, 2026
78e57f2
Merge branch 'ali-2358-player-video' into ali-2358-player-ui
michaelaguiar Dec 2, 2026
16f9b62
Merge branch 'ali-2358-player-ui' into ali-2358-player-mpris
michaelaguiar Dec 2, 2026
683afab
MPRIS review fixes: play and pause while opening, Seeked, signals, th…
michaelaguiar Dec 2, 2026
756fbf4
Commands to the helper wait out a full socket; video needs viewporter
michaelaguiar Dec 2, 2026
44c1a86
Merge branch 'ali-2358-player-video' into ali-2358-player-ui
michaelaguiar Dec 2, 2026
b2f1106
Review round 2: back from the grid where it was; hover contrast held;…
michaelaguiar Dec 2, 2026
85a1754
Merge branch 'ali-2358-player-ui' into ali-2358-player-mpris
michaelaguiar Dec 2, 2026
d4c5ab0
Follow alias-playback #3 to e11d5f4; a helper's exit code survives a …
michaelaguiar Dec 2, 2026
bf09af0
Merge branch 'ali-2358-player-video' into ali-2358-player-ui
michaelaguiar Dec 2, 2026
b5c527b
Review round 3: the grid's kept place can't outlive it; a paused resu…
michaelaguiar Dec 2, 2026
d1f6938
Merge branch 'ali-2358-player-ui' into ali-2358-player-mpris
michaelaguiar Dec 2, 2026
5e37507
MPRIS review round 2: tags as they arrive, Seeked after Position, pau…
michaelaguiar Dec 2, 2026
55eb9d3
MPRIS review round 3: Next opens at once, replay's Seeked, paused resume
michaelaguiar Dec 2, 2026
42d4ab2
Follow alias-playback #3 to a314208 (#2's late-Loaded fixes; no pictu…
michaelaguiar Dec 2, 2026
f2be3d6
Merge remote-tracking branch 'origin/ali-2358-player-video' into HEAD
michaelaguiar Dec 2, 2026
0a7ce01
Merge remote-tracking branch 'origin/ali-2358-player-ui' into ali-235…
michaelaguiar Dec 2, 2026
b6cbe18
A buffer's modifier must be one the compositor listed for its format
michaelaguiar Dec 2, 2026
4e4e812
Merge remote-tracking branch 'origin/ali-2358-player-video' into HEAD
michaelaguiar Dec 2, 2026
ec29aa7
Merge remote-tracking branch 'origin/ali-2358-player-ui' into ali-235…
michaelaguiar Dec 2, 2026
69efc81
MPRIS: the player syncs before and after a controller's requests
michaelaguiar Dec 2, 2026
c4eeb7d
Follow alias-playback #3 to its merge of 6c0187c (GPU setup freed on …
michaelaguiar Dec 2, 2026
97a957a
Merge remote-tracking branch 'origin/ali-2358-player-video' into HEAD
michaelaguiar Dec 2, 2026
880d27f
Merge remote-tracking branch 'origin/ali-2358-player-ui' into ali-235…
michaelaguiar Dec 2, 2026
2373ba9
Merge main (#6 and #7 squash-merged) into ali-2358-player-ui
michaelaguiar Dec 2, 2026
6d2f67e
Player tokens approved: their usage notes drop "Proposed"
michaelaguiar Dec 2, 2026
bf75c8e
Hide the pointer with the control bar while a video plays
michaelaguiar Dec 2, 2026
5ec2e71
Merge remote-tracking branch 'origin/ali-2358-player-ui' into ali-235…
michaelaguiar Dec 2, 2026
2fec5ed
README: what brings the pointer back, and where it hides
michaelaguiar Dec 2, 2026
00a3ae4
Merge remote-tracking branch 'origin/ali-2358-player-ui' into ali-235…
michaelaguiar Dec 2, 2026
caa95f4
Use alias-playback from main, now that #2 and #3 are merged
michaelaguiar Dec 3, 2026
78335bc
Merge remote-tracking branch 'origin/ali-2358-player-ui' into ali-235…
michaelaguiar Dec 3, 2026
535b52b
Merge main (alias-view #8, merged) into ali-2358-player-mpris
michaelaguiar Dec 3, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ wayland-protocols = { version = "0.32.13", features = ["client", "staging", "uns
xkbcommon = { version = "0.9.0", default-features = false }
swash = "0.2.10"
rustix = { version = "1.1.6", features = ["fs", "event", "time", "pipe", "process"] }
# MPRIS on the session bus (src/mpris.rs). Already built for accesskit_unix, with the
# same async-io executor; blocking-api adds only the blocking wrappers.
zbus = { version = "5.19.0", default-features = false, features = ["async-io", "blocking-api"] }
# Video and music: libmpv in a jailed helper that draws on the graphics card and hands its
# frames over as dmabufs (ALI-2358).
alias-playback = { git = "https://github.com/aliasproject/alias-playback", branch = "main" }
Expand Down
12 changes: 11 additions & 1 deletion src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ pub struct Grid {
pub scroll: i32,
}

/// The next and previous video or song, and the (place, list length, list) they're for.
type NeighboursCache = ((usize, usize, usize), (Option<usize>, Option<usize>));

pub struct App {
pub files: Vec<PathBuf>,
pub cur: usize,
Expand Down Expand Up @@ -116,6 +119,10 @@ pub struct App {
resume: Option<(PathBuf, f64, bool)>,
/// In full screen, as the compositor last said.
fullscreen: bool,
/// Counts the videos and songs opened, so MPRIS sees each as a new track.
track: u64,
/// The next and previous video or song for MPRIS, by (place, list length, list).
neighbours_cache: std::cell::Cell<Option<NeighboursCache>>,
}

impl App {
Expand Down Expand Up @@ -171,6 +178,8 @@ impl App {
toggle_fullscreen: false,
resume: None,
fullscreen: false,
track: 0,
neighbours_cache: std::cell::Cell::new(None),
}
}

Expand Down Expand Up @@ -286,14 +295,15 @@ impl App {
let mut m = Media::open(path, kind, player::gpu::open_node(wl.render_node_path().as_deref()), size, self.volume, self.muted);
// Paused before: paused from the start, so nothing plays before the seek.
if resume.is_some_and(|(_, play)| !play) {
m.send(player::gpu::Command::Pause);
m.pause();
}
m.resume = resume;
m
} else {
Media::failed(path, kind, "this desktop can't show video from another process (it lacks linux-dmabuf or viewporter)".into())
});
self.controls = Controls { focus, ..Controls::default() };
self.track += 1;
self.seek_said_at = None;
let opening = format!("Opening {}", self.name());
self.say(opening);
Expand Down
143 changes: 143 additions & 0 deletions src/app/player_ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,138 @@ impl App {
}
}

impl App {
/// What MPRIS would be told, cheaply: when this is unchanged, so is what it says.
pub fn mpris_key(&self) -> Option<(u64, u8, i64, i64, bool, bool, u64)> {
let m = self.media.as_ref()?;
let phase = match m.phase() {
Phase::Opening if m.opening_paused() => 5,
Phase::Opening => 0,
Phase::Playing => 1,
Phase::Paused => 2,
Phase::Ended => 3,
Phase::Failed(_) => 4,
};
let (next, previous) = self.media_neighbours();
// The tags themselves, as they arrive one by one: each one is news.
let tags = {
use std::hash::{Hash, Hasher};
let mut h = std::collections::hash_map::DefaultHasher::new();
m.meta.hash(&mut h);
h.finish()
};
Some((self.track, phase, (m.state.duration * 10.0) as i64, if m.state.muted { -1 } else { m.state.volume as i64 }, next.is_some(), previous.is_some(), tags))
}

/// The next and previous video or song in the list, going round, if any other. Kept
/// while the list and the place in it are the same, so a long folder isn't walked on
/// every wake.
fn media_neighbours(&self) -> (Option<usize>, Option<usize>) {
let key = (self.cur, self.files.len(), self.files.as_ptr() as usize);
if let Some((k, v)) = self.neighbours_cache.get()
&& k == key
{
return v;
}
let v = self.find_media_neighbours();
self.neighbours_cache.set(Some((key, v)));
v
}

fn find_media_neighbours(&self) -> (Option<usize>, Option<usize>) {
let n = self.files.len();
let is_media = |i: usize| crate::player::kind_of(&self.files[i]).is_some();
let next = (1..n).map(|d| (self.cur + d) % n).find(|i| is_media(*i));
let previous = (1..n).map(|d| (self.cur + n - d) % n).find(|i| is_media(*i));
(next, previous)
}

/// Where playback is, for MPRIS's Position.
pub fn mpris_position(&self) -> Option<f64> {
let m = self.media.as_ref()?;
Some(if m.state.ended { m.state.duration } else { m.state.position })
}

/// Where the last seek went, for MPRIS's Seeked signal.
pub fn take_seeked(&mut self) -> Option<f64> {
self.media.as_mut()?.take_seeked()
}

/// What's playing, for MPRIS.
pub fn mpris_now(&self) -> crate::mpris::Now {
let Some(m) = &self.media else { return crate::mpris::Now { status: "Stopped", ..Default::default() } };
let (next, previous) = self.media_neighbours();
let status = match m.phase() {
// Opening plays once loaded, unless paused meanwhile.
Phase::Opening if m.opening_paused() => "Paused",
Phase::Playing | Phase::Opening => "Playing",
Phase::Failed(_) => "Stopped",
Phase::Paused | Phase::Ended => "Paused",
};
crate::mpris::Now {
status,
track: self.track,
path: Some(m.path.clone()),
title: Some(m.title()),
artist: m.meta.artist.clone(),
album: m.meta.album.clone(),
length: m.state.duration.max(0.0),
position: if m.state.ended { m.state.duration } else { m.state.position },
volume: if m.state.muted { 0.0 } else { m.state.volume },
can_go_next: next.is_some(),
can_go_previous: previous.is_some(),
}
}

/// A media controller (the bar, playerctl, the screensaver) asked for something. Next
/// and Previous go to the next video or song, past any pictures between.
pub fn mpris_request(&mut self, r: crate::mpris::Request) {
use crate::mpris::Request;
if r == Request::Quit {
self.quit = true;
return;
}
if self.media.is_none() {
return;
}
match r {
Request::PlayPause => self.toggle_media(),
Request::Play => {
if let Some(m) = &mut self.media {
m.play();
}
}
Request::Pause => {
if let Some(m) = &mut self.media {
m.pause();
}
}
Request::Next | Request::Previous => {
let (next, previous) = self.media_neighbours();
if let Some(i) = if r == Request::Next { next } else { previous } {
self.go(i);
}
}
Request::SeekTo(s) => {
// Nothing to seek while it opens, so nothing to say either.
if let Some(m) = self.media.as_mut().filter(|m| m.heard) {
m.seek_to(s);
self.seek_said_at = Some(Instant::now() + motion::SEEK_ANNOUNCE);
}
}
Request::Volume(v) => {
let Some(m) = &mut self.media else { return };
m.set_volume(v);
let said = format!("Volume {:.0}%", m.state.volume);
self.say(said);
}
Request::Quit => {}
}
self.overlay_bar();
self.a11y_dirty = true;
}
}

#[cfg(test)]
mod tests {
use super::*;
Expand All @@ -622,6 +754,17 @@ mod tests {
assert!(!may_hide(Kind::Video, &Phase::Playing, None, Some(Control::Position)));
}

#[test]
fn media_controllers_skip_pictures_and_go_round() {
let files: Vec<std::path::PathBuf> = ["a.mp4", "b.jpg", "c.flac", "d.png"].iter().map(|f| std::path::PathBuf::from(format!("/m/{f}"))).collect();
let mut app = App::new(files, 2, crate::theme::builtin(true), crate::loader::Loader::new(1), 1);
assert_eq!(app.media_neighbours(), (Some(0), Some(0)), "from the song, the video either way");
app.cur = 0;
assert_eq!(app.media_neighbours(), (Some(2), Some(2)));
app.files = vec!["/m/only.mp4".into(), "/m/x.jpg".into()];
assert_eq!(app.media_neighbours(), (None, None), "no other video or song");
}

/// A viewer with `name` open in the player, as the helper said it: playing, paused or
/// ended. No helper runs: the file can't be opened, and then is told it was.
fn playing(name: &str, paused: bool, ended: bool) -> App {
Expand Down
48 changes: 48 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ mod clip;
mod decode;
mod exif;
mod loader;
mod mpris;
mod pixels;
mod player;
mod render;
Expand Down Expand Up @@ -247,6 +248,10 @@ fn run(o: Opening) -> i32 {
let mut folder: Option<Receiver<Vec<PathBuf>>> = None;
let mut folder_of = o.folder_of;
let mut a11y: Option<a11y::A11y> = None;
let mut mpris: Option<mpris::Mpris> = None;
let mut mpris_joining: Option<Receiver<Option<mpris::Mpris>>> = None;
let mut mpris_said = None;
let mut mpris_tried = false;
let mut first_frame = true;
let mut configured_at: Option<Instant> = None;
// Recolours when aliasOS's theme changes. Started after the first frame, as nothing
Expand Down Expand Up @@ -287,9 +292,52 @@ fn run(o: Opening) -> i32 {
app.set_files(files);
folder = None;
}
// The player follows the current file: once after input, and again after any media
// controller's requests, so both act on the file that's open and a Next opens the
// next file on this turn.
if wl.state.configured {
app.sync_media(&mut wl);
}
// MPRIS, from the first video or song on, when there's a session bus; joined on a
// thread, so a slow bus never holds up the window.
if !mpris_tried && app.media.is_some() {
mpris_tried = true;
mpris_joining = a11y::session_bus_exists().then(mpris::Mpris::spawn);
}
if let Some(rx) = &mpris_joining
&& let Ok(joined) = rx.try_recv()
{
mpris = joined;
mpris_joining = None;
}
if let Some(m) = &mpris {
let reqs: Vec<_> = m.requests.try_iter().collect();
if !reqs.is_empty() {
for r in reqs {
app.mpris_request(r);
}
if wl.state.configured {
app.sync_media(&mut wl);
}
}
}
// Taken every turn, so a seek made before the bus joined isn't sent late.
let seeked = app.take_seeked();
if let Some(m) = &mpris {
if let Some(at) = seeked {
// Stored first, so a controller that reads Position on Seeked gets the new one.
m.set_position(at);
m.seeked(at);
}
// Built only when something it says changed, not on every wake.
let key = app.mpris_key();
if key != mpris_said {
m.update(app.mpris_now());
mpris_said = key;
} else if let Some(at) = app.mpris_position() {
m.set_position(at);
}
}
if let Some(a) = &a11y {
let reqs: Vec<_> = a.actions.try_iter().collect();
for r in reqs {
Expand Down
Loading
Loading