Centre the icon's play triangle; add a Quality menu for online videos
The triangle sat ~14 px right of the shape's centre. Online videos now list the heights yt-dlp found and switch quality in place, keeping the position. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.6 KiB |
|
Before Width: | Height: | Size: 412 B After Width: | Height: | Size: 405 B |
|
Before Width: | Height: | Size: 5.7 KiB After Width: | Height: | Size: 5.7 KiB |
|
Before Width: | Height: | Size: 626 B After Width: | Height: | Size: 656 B |
|
Before Width: | Height: | Size: 863 B After Width: | Height: | Size: 881 B |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.2 KiB |
|
|
@ -1,4 +1,4 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256">
|
||||
<path d="M203.3,128.0 L203.4,130.0 L203.5,132.0 L203.8,134.0 L204.1,136.0 L204.6,138.1 L205.1,140.2 L205.7,142.4 L206.3,144.6 L207.0,147.0 L207.7,149.3 L208.4,151.8 L209.1,154.3 L209.7,156.9 L210.3,159.6 L210.8,162.3 L211.3,165.1 L211.6,167.9 L211.8,170.7 L211.9,173.6 L211.9,176.4 L211.6,179.3 L211.2,182.1 L210.7,184.8 L209.9,187.5 L209.0,190.1 L207.9,192.7 L206.5,195.1 L205.1,197.4 L203.4,199.5 L201.5,201.5 L199.5,203.4 L197.4,205.1 L195.1,206.5 L192.7,207.9 L190.1,209.0 L187.5,209.9 L184.8,210.7 L182.1,211.2 L179.3,211.6 L176.4,211.9 L173.6,211.9 L170.7,211.8 L167.9,211.6 L165.1,211.3 L162.3,210.8 L159.6,210.3 L156.9,209.7 L154.3,209.1 L151.8,208.4 L149.3,207.7 L147.0,207.0 L144.6,206.3 L142.4,205.7 L140.2,205.1 L138.1,204.6 L136.0,204.1 L134.0,203.8 L132.0,203.5 L130.0,203.4 L128.0,203.3 L126.0,203.4 L124.0,203.5 L122.0,203.8 L120.0,204.1 L117.9,204.6 L115.8,205.1 L113.6,205.7 L111.4,206.3 L109.0,207.0 L106.7,207.7 L104.2,208.4 L101.7,209.1 L99.1,209.7 L96.4,210.3 L93.7,210.8 L90.9,211.3 L88.1,211.6 L85.3,211.8 L82.4,211.9 L79.6,211.9 L76.7,211.6 L73.9,211.2 L71.2,210.7 L68.5,209.9 L65.9,209.0 L63.3,207.9 L60.9,206.5 L58.6,205.1 L56.5,203.4 L54.5,201.5 L52.6,199.5 L50.9,197.4 L49.5,195.1 L48.1,192.7 L47.0,190.1 L46.1,187.5 L45.3,184.8 L44.8,182.1 L44.4,179.3 L44.1,176.4 L44.1,173.6 L44.2,170.7 L44.4,167.9 L44.7,165.1 L45.2,162.3 L45.7,159.6 L46.3,156.9 L46.9,154.3 L47.6,151.8 L48.3,149.3 L49.0,147.0 L49.7,144.6 L50.3,142.4 L50.9,140.2 L51.4,138.1 L51.9,136.0 L52.2,134.0 L52.5,132.0 L52.6,130.0 L52.7,128.0 L52.6,126.0 L52.5,124.0 L52.2,122.0 L51.9,120.0 L51.4,117.9 L50.9,115.8 L50.3,113.6 L49.7,111.4 L49.0,109.0 L48.3,106.7 L47.6,104.2 L46.9,101.7 L46.3,99.1 L45.7,96.4 L45.2,93.7 L44.7,90.9 L44.4,88.1 L44.2,85.3 L44.1,82.4 L44.1,79.6 L44.4,76.7 L44.8,73.9 L45.3,71.2 L46.1,68.5 L47.0,65.9 L48.1,63.3 L49.5,60.9 L50.9,58.6 L52.6,56.5 L54.5,54.5 L56.5,52.6 L58.6,50.9 L60.9,49.5 L63.3,48.1 L65.9,47.0 L68.5,46.1 L71.2,45.3 L73.9,44.8 L76.7,44.4 L79.6,44.1 L82.4,44.1 L85.3,44.2 L88.1,44.4 L90.9,44.7 L93.7,45.2 L96.4,45.7 L99.1,46.3 L101.7,46.9 L104.2,47.6 L106.7,48.3 L109.0,49.0 L111.4,49.7 L113.6,50.3 L115.8,50.9 L117.9,51.4 L120.0,51.9 L122.0,52.2 L124.0,52.5 L126.0,52.6 L128.0,52.7 L130.0,52.6 L132.0,52.5 L134.0,52.2 L136.0,51.9 L138.1,51.4 L140.2,50.9 L142.4,50.3 L144.6,49.7 L147.0,49.0 L149.3,48.3 L151.8,47.6 L154.3,46.9 L156.9,46.3 L159.6,45.7 L162.3,45.2 L165.1,44.7 L167.9,44.4 L170.7,44.2 L173.6,44.1 L176.4,44.1 L179.3,44.4 L182.1,44.8 L184.8,45.3 L187.5,46.1 L190.1,47.0 L192.7,48.1 L195.1,49.5 L197.4,50.9 L199.5,52.6 L201.5,54.5 L203.4,56.5 L205.1,58.6 L206.5,60.9 L207.9,63.3 L209.0,65.9 L209.9,68.5 L210.7,71.2 L211.2,73.9 L211.6,76.7 L211.9,79.6 L211.9,82.4 L211.8,85.3 L211.6,88.1 L211.3,90.9 L210.8,93.7 L210.3,96.4 L209.7,99.1 L209.1,101.7 L208.4,104.2 L207.7,106.7 L207.0,109.0 L206.3,111.4 L205.7,113.6 L205.1,115.8 L204.6,117.9 L204.1,120.0 L203.8,122.0 L203.5,124.0 L203.4,126.0 Z" fill="#94bb3b"/>
|
||||
<path d="M111.7,95.6 L171.6,128.0 L111.7,160.4 Z" fill="#2b390b" stroke="#2b390b" stroke-width="14" stroke-linejoin="round"/>
|
||||
<path d="M98.0,92.4 L164.0,128.0 L98.0,163.6 Z" fill="#2b390b" stroke="#2b390b" stroke-width="14" stroke-linejoin="round"/>
|
||||
</svg>
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 3.1 KiB |
|
|
@ -39,6 +39,14 @@ Version 0.1.0, first build (2026-11-26).
|
|||
- Smoke-tested: the AppImage plays the test clip with hardware decoding; the Windows build plays it under wine; the
|
||||
installer installs per user to `AppData\Local\Programs\Quince` with a Start menu entry.
|
||||
|
||||
## Icon and stream quality (2026-12-01)
|
||||
- Icon: the play triangle sat about 14 px right of the shape's centre; it is centred now (a small optical nudge
|
||||
right) and a little larger. PNGs in `assets/icons/` and `packaging/quince.ico` regenerated from the SVG.
|
||||
- Online videos get a Quality menu (right-click menu and the Video menu): Best, each height the stream offers
|
||||
(read from yt-dlp's answer that mpv keeps), and Sound only. Picking one remembers it (same setting as Settings >
|
||||
Playback > Links) and reloads the stream where it was. Checked in a hidden run on a YouTube link: 4K → 480p, and
|
||||
480p → 360p at 5:24 carried on from 5:24. Sizes not in Settings' list (1440p, 360p) show there as the next one down.
|
||||
|
||||
## Not done
|
||||
- No release published yet: the packages are in `dist/`, notes in `docs/releases/0.1.0.md`.
|
||||
- Windows: screensaver inhibit is D-Bus only, so it does nothing there; seek previews need ffmpeg on PATH. Not tried
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 361 KiB After Width: | Height: | Size: 361 KiB |
28
src/app.rs
|
|
@ -1,6 +1,6 @@
|
|||
//! The app: owns mpv, the settings and the theme, turns input and clicks into `Act`s and applies them.
|
||||
|
||||
use crate::config::{ColourFrom, Settings};
|
||||
use crate::config::{self, ColourFrom, Settings};
|
||||
use crate::inhibit::Inhibitor;
|
||||
use crate::motion::{self, spring};
|
||||
use crate::mpv::{self, Happened, Player};
|
||||
|
|
@ -60,6 +60,8 @@ pub enum Act {
|
|||
Cmd(Vec<String>),
|
||||
/// Set an mpv property (mpv parses the value).
|
||||
Set(String, String),
|
||||
/// Quality for online videos ("best", a height, "audio"): remembered, and the playing video reloads where it is.
|
||||
Quality(String),
|
||||
TogglePause,
|
||||
Seek(f64),
|
||||
SeekBy(f64),
|
||||
|
|
@ -122,6 +124,8 @@ pub struct App {
|
|||
pub dialog: Dialog,
|
||||
pub settings_page: usize,
|
||||
pub url_text: String,
|
||||
/// A quality switch set mpv's `start`; put it back when the file has loaded.
|
||||
restore_start: bool,
|
||||
last_move: f64,
|
||||
pending_click: Option<f64>,
|
||||
swallow_click: bool,
|
||||
|
|
@ -164,6 +168,7 @@ impl App {
|
|||
dialog: Dialog::None,
|
||||
settings_page: 0,
|
||||
url_text: String::new(),
|
||||
restore_start: false,
|
||||
last_move: 0.0,
|
||||
pending_click: None,
|
||||
swallow_click: false,
|
||||
|
|
@ -348,6 +353,22 @@ impl App {
|
|||
}
|
||||
}
|
||||
}
|
||||
Act::Quality(q) => {
|
||||
self.settings.ytdl_quality = q.clone();
|
||||
self.settings.save();
|
||||
if let Some(p) = &self.player {
|
||||
p.set("ytdl-format", self.settings.ytdl_format().as_str());
|
||||
if p.state.loaded() && p.state.path.contains("://") {
|
||||
// Play the same entry again from here; the start time is undone once it has loaded.
|
||||
// An older resume point for this link would win over `start`, so it goes first.
|
||||
p.set("start", format!("{:.3}", p.state.time.max(0.0)).as_str());
|
||||
p.cmd(&["delete-watch-later-config"]);
|
||||
p.cmd(&["playlist-play-index", "current"]);
|
||||
self.restore_start = true;
|
||||
}
|
||||
}
|
||||
self.osd(ctx, format!("Quality: {}", config::quality_label(&q)), None);
|
||||
}
|
||||
Act::TogglePause => {
|
||||
if let Some(p) = &self.player {
|
||||
if p.state.eof && !p.state.pause {
|
||||
|
|
@ -463,6 +484,9 @@ impl App {
|
|||
match h {
|
||||
Happened::StartFile => {}
|
||||
Happened::FileLoaded => {
|
||||
if std::mem::take(&mut self.restore_start) {
|
||||
self.player.as_ref().unwrap().set("start", "none");
|
||||
}
|
||||
self.loading = None;
|
||||
self.video_seed = None;
|
||||
self.sample_at = None;
|
||||
|
|
@ -752,7 +776,7 @@ impl App {
|
|||
"error": self.startup_error,
|
||||
"idle": s.idle, "pause": s.pause, "time": s.time, "duration": s.duration, "title": s.title,
|
||||
"width": s.width, "height": s.height, "tracks": s.tracks.len(), "chapters": s.chapters.len(),
|
||||
"playlist": s.playlist.len(), "hwdec": s.hwdec_current, "volume": s.volume,
|
||||
"playlist": s.playlist.len(), "stream_heights": s.stream_heights, "path": s.path, "hwdec": s.hwdec_current, "volume": s.volume,
|
||||
"sheet": format!("{:?}", self.sheet), "dialog": format!("{:?}", self.dialog), "menu": self.menu.as_ref().map(|m| format!("{:?}", m.1)),
|
||||
"toasts": self.toasts.iter().map(|t| t.text.clone()).collect::<Vec<_>>(),
|
||||
"dark": self.theme.dark, "primary": format!("{:?}", self.theme.primary),
|
||||
|
|
|
|||
|
|
@ -159,11 +159,11 @@ impl Settings {
|
|||
|
||||
pub fn ytdl_format(&self) -> String {
|
||||
match self.ytdl_quality.as_str() {
|
||||
"2160" | "1440" | "1080" | "720" | "480" => {
|
||||
format!("bestvideo[height<=?{0}]+bestaudio/best[height<=?{0}]", self.ytdl_quality)
|
||||
}
|
||||
"audio" => "bestaudio/best".into(),
|
||||
_ => String::new(),
|
||||
q => match q.parse::<u32>() {
|
||||
Ok(h) => format!("bestvideo[height<=?{h}]+bestaudio/best[height<=?{h}]"),
|
||||
Err(_) => String::new(),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -185,6 +185,24 @@ pub const MOTIONS: [&str; 4] = ["off", "reduced", "normal", "lively"];
|
|||
pub const QUALITIES: [(&str, &str); 6] =
|
||||
[("best", "Best"), ("2160", "4K"), ("1080", "1080p"), ("720", "720p"), ("480", "480p"), ("audio", "Sound only")];
|
||||
|
||||
/// Which of QUALITIES to show as chosen; a height picked from the Quality menu shows as the nearest one at or below it.
|
||||
pub fn quality_index(q: &str) -> usize {
|
||||
if let Some(i) = QUALITIES.iter().position(|x| x.0 == q) {
|
||||
return i;
|
||||
}
|
||||
let Ok(h) = q.parse::<u32>() else { return 0 };
|
||||
QUALITIES.iter().position(|x| x.0.parse::<u32>().is_ok_and(|v| v <= h)).unwrap_or(QUALITIES.len() - 2)
|
||||
}
|
||||
|
||||
/// How a quality setting reads in menus: "Best", "720p", "4K", "Sound only".
|
||||
pub fn quality_label(q: &str) -> String {
|
||||
match q.parse::<u32>() {
|
||||
Ok(2160) => "4K".into(),
|
||||
Ok(h) => format!("{h}p"),
|
||||
Err(_) => QUALITIES.iter().find(|x| x.0 == q).map_or("Best", |x| x.1).into(),
|
||||
}
|
||||
}
|
||||
|
||||
fn desktop_wants_less_motion() -> bool {
|
||||
static ASKED: std::sync::OnceLock<bool> = std::sync::OnceLock::new();
|
||||
*ASKED.get_or_init(ask_desktop_motion)
|
||||
|
|
|
|||
37
src/mpv.rs
|
|
@ -168,6 +168,24 @@ impl Entry {
|
|||
}
|
||||
}
|
||||
|
||||
/// The video heights in mpv's copy of yt-dlp's answer (`{"stdout": "<yt-dlp json>", ...}`), tallest first.
|
||||
pub fn stream_heights(result: &str) -> Vec<u32> {
|
||||
let Ok(outer) = serde_json::from_str::<serde_json::Value>(result) else { return vec![] };
|
||||
let Some(Ok(info)) = outer["stdout"].as_str().map(serde_json::from_str::<serde_json::Value>) else { return vec![] };
|
||||
let mut v: Vec<u32> = info["formats"]
|
||||
.as_array()
|
||||
.into_iter()
|
||||
.flatten()
|
||||
.filter(|f| f["vcodec"].as_str().is_some_and(|c| c != "none"))
|
||||
.filter_map(|f| f["height"].as_u64())
|
||||
.map(|h| h as u32)
|
||||
.filter(|&h| h >= 144)
|
||||
.collect();
|
||||
v.sort_unstable_by(|a, b| b.cmp(a));
|
||||
v.dedup();
|
||||
v
|
||||
}
|
||||
|
||||
/// The file name of a path or URL, without the folder.
|
||||
pub fn display_name(path: &str) -> String {
|
||||
if path.contains("://") {
|
||||
|
|
@ -239,6 +257,8 @@ pub struct State {
|
|||
pub panscan: f64,
|
||||
pub devices: Vec<Device>,
|
||||
pub audio_channels: String,
|
||||
/// Picture heights an online video offers (from yt-dlp), tallest first; empty for local files.
|
||||
pub stream_heights: Vec<u32>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default, Deserialize)]
|
||||
|
|
@ -511,7 +531,14 @@ impl Player {
|
|||
while let Some(ev) = self.mpv.wait_event(0.0) {
|
||||
match ev {
|
||||
Ok(Event::PropertyChange { name, change, .. }) => apply(&mut self.state, name, change),
|
||||
Ok(Event::FileLoaded) => out.push(Happened::FileLoaded),
|
||||
Ok(Event::FileLoaded) => {
|
||||
self.state.stream_heights = if self.state.path.contains("://") {
|
||||
self.get_str("user-data/mpv/ytdl/json-subprocess-result").map(|j| stream_heights(&j)).unwrap_or_default()
|
||||
} else {
|
||||
vec![]
|
||||
};
|
||||
out.push(Happened::FileLoaded)
|
||||
}
|
||||
Ok(Event::StartFile) => out.push(Happened::StartFile),
|
||||
Ok(Event::EndFile(_)) => out.push(Happened::EndFile),
|
||||
Err(e) => out.push(Happened::Error(err_words(&e))),
|
||||
|
|
@ -787,6 +814,14 @@ mod tests {
|
|||
fn names_and_tracks_read_well() {
|
||||
assert_eq!(display_name("/home/a/Films/The Film (2020).mkv"), "The Film (2020).mkv");
|
||||
assert_eq!(display_name("https://example.com/v/My%20clip.mp4?x=1"), "My clip.mp4");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn heights_from_ytdl() {
|
||||
let inner = r#"{"formats":[{"height":1080,"vcodec":"vp9"},{"height":720,"vcodec":"avc1"},{"height":1080,"vcodec":"av01"},{"vcodec":"none","acodec":"opus"},{"height":90,"vcodec":"none"},{"height":27,"vcodec":"images"}]}"#;
|
||||
let outer = serde_json::json!({ "stdout": inner, "status": 0 }).to_string();
|
||||
assert_eq!(stream_heights(&outer), vec![1080, 720]);
|
||||
assert!(stream_heights("{}").is_empty());
|
||||
assert_eq!(trim_num(23.976, 3), "23.976");
|
||||
assert_eq!(trim_num(48.0, 1), "48");
|
||||
let t: Vec<Track> = json(r#"[{"id":1,"type":"audio","lang":"jpn","codec":"aac","demux-channel-count":6,"demux-samplerate":48000,"selected":true}]"#);
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ pub fn build(kind: MenuKind, s: &State, cfg: &Settings) -> Vec<Item> {
|
|||
MenuKind::Subtitles => subtitles(s),
|
||||
MenuKind::Speed => speed(s),
|
||||
MenuKind::Chapters => chapters(s),
|
||||
MenuKind::Video => video(s),
|
||||
MenuKind::Video => video(s, cfg),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -40,7 +40,12 @@ fn context(s: &State, cfg: &Settings) -> Vec<Item> {
|
|||
]),
|
||||
Item::sub(g::BOOKMARKS, "Chapters", chapters(s)),
|
||||
Item::divider(),
|
||||
Item::sub(g::MOVIE, "Video", video(s)),
|
||||
]);
|
||||
if s.path.contains("://") {
|
||||
v.push(Item::sub(g::HD, "Quality", quality(s, cfg)).detail(quality_detail(s)));
|
||||
}
|
||||
v.extend([
|
||||
Item::sub(g::MOVIE, "Video", video(s, cfg)),
|
||||
Item::sub(g::MUSIC_NOTE, "Sound", audio(s)),
|
||||
Item::sub(g::SUBTITLES, "Subtitles", subtitles(s)),
|
||||
Item::new(g::TUNE, "Adjust picture and sound", Act::Sheet(Sheet::Adjust)).keys("Ctrl+E"),
|
||||
|
|
@ -158,8 +163,34 @@ fn chapters(s: &State) -> Vec<Item> {
|
|||
|
||||
pub const ASPECTS: [(&str, &str); 7] = [("-1", "Original"), ("16:9", "16:9"), ("4:3", "4:3"), ("2.35:1", "2.35:1"), ("1.85:1", "1.85:1"), ("21:9", "21:9"), ("1:1", "1:1")];
|
||||
|
||||
fn video(s: &State) -> Vec<Item> {
|
||||
let mut v = vec![Item::heading("Video track")];
|
||||
/// Online videos only: the heights the stream offers (a fixed list if yt-dlp's answer isn't there).
|
||||
fn quality(s: &State, cfg: &Settings) -> Vec<Item> {
|
||||
let q = cfg.ytdl_quality.as_str();
|
||||
let mut heights = s.stream_heights.clone();
|
||||
if heights.is_empty() {
|
||||
heights = vec![2160, 1440, 1080, 720, 480, 360];
|
||||
}
|
||||
let mut v = vec![Item::new("", "Best", Act::Quality("best".into())).check(q == "best" || q.is_empty())];
|
||||
v.extend(heights.iter().map(|h| {
|
||||
let it = Item::new("", crate::config::quality_label(&h.to_string()), Act::Quality(h.to_string())).check(q == h.to_string());
|
||||
if *h >= 720 { it.detail("HD") } else { it }
|
||||
}));
|
||||
v.push(Item::divider());
|
||||
v.push(Item::new(g::MUSIC_NOTE, "Sound only", Act::Quality("audio".into())).check(q == "audio"));
|
||||
v
|
||||
}
|
||||
|
||||
fn quality_detail(s: &State) -> String {
|
||||
if s.height > 0 { format!("{}p", s.height) } else { "Sound only".into() }
|
||||
}
|
||||
|
||||
fn video(s: &State, cfg: &Settings) -> Vec<Item> {
|
||||
let mut v = vec![];
|
||||
if s.path.contains("://") {
|
||||
v.push(Item::sub(g::HD, "Quality", quality(s, cfg)).detail(quality_detail(s)));
|
||||
v.push(Item::divider());
|
||||
}
|
||||
v.push(Item::heading("Video track"));
|
||||
v.extend(track_items(s, "video", "vid", &s.vid));
|
||||
let aspect = s.aspect_override.as_str();
|
||||
let aspects: Vec<Item> = ASPECTS
|
||||
|
|
|
|||
|
|
@ -433,7 +433,7 @@ fn playback(f: &mut Form, app: &mut App, ch: &mut Changed) {
|
|||
f.slider("seek-small", "Arrow keys skip", &mut s.seek_small, 1.0, 30.0, 1.0, &|v| format!("{v:.0} s"));
|
||||
f.slider("seek-large", "Shift and arrow keys skip", &mut s.seek_large, 10.0, 300.0, 5.0, &|v| format!("{v:.0} s"));
|
||||
f.heading("Links");
|
||||
let mut i = config::QUALITIES.iter().position(|q| q.0 == s.ytdl_quality).unwrap_or(0);
|
||||
let mut i = config::quality_index(&s.ytdl_quality);
|
||||
let labels: Vec<&str> = config::QUALITIES.iter().map(|q| q.1).collect();
|
||||
if f.segmented("quality", "Quality for online videos", &labels, &mut i) {
|
||||
s.ytdl_quality = config::QUALITIES[i].0.into();
|
||||
|
|
|
|||