Skip to content

Native iCloud apps for Windows and Linux, built in Rust. Notes, Reminders, Calendar, Contacts, Drive and Photos, offline and in sync with your iPhone.

Photos: every picture made the size it is shown at; Photos' own video player

Yashwanth Kamireddi3cda86f10fd3
diff --git a/.uiverify/photos-quality.mjs b/.uiverify/photos-quality.mjs
index 4ee66c7..1704942 100644
--- a/.uiverify/photos-quality.mjs
+++ b/.uiverify/photos-quality.mjs
@@ -1,6 +1,7 @@
-// A photo at full quality from the first frame: once its whole picture is decoded — as it is
-// fetched before it opens, and for the photos either side while one shows — the viewer shows
-// that alone, never a smaller copy first; stepping lands on a whole picture too.
+// A photo at full quality from the first frame: the picture made the size the stage shows it —
+// at least as many pixels as it is drawn with, so the engine never stretches or shrinks it —
+// decoded before it opens, and for the photos either side while one shows; alone, never a
+// smaller copy first; stepping lands on one too.
import { engine } from "./engine.mjs";
import { SERVICES, installStub, openScreen } from "./stub.mjs";
const b = await engine.launch();
@@ -19,9 +20,16 @@ const shown = () => page.locator(".px-stage .px-shown").getAttribute("src");
await page.locator(".px-tile").nth(0).dblclick();
await page.waitForTimeout(80);
-ok(/full/.test((await shown()) ?? "") && (await page.locator(".px-sharp").count()) === 0, `it opens on the whole picture, alone ${await shown()}`);
+const enough = () => page.evaluate(() => {
+ const img = document.querySelector(".px-stage .px-shown");
+ const step = Number(/fit(\d+)/.exec(decodeURIComponent(img.getAttribute("src")))?.[1] ?? 0);
+ // Its laid-out size, not its box on screen: that is still growing as the viewer opens.
+ const long = Math.max(img.offsetWidth, img.offsetHeight) * devicePixelRatio;
+ return step >= long - 1 && step < long * 2;
+});
+ok(/fit\d+/.test((await shown()) ?? "") && (await enough()) && (await page.locator(".px-sharp").count()) === 0, `it opens on the picture made its shown size, alone ${await shown()}`);
await page.keyboard.press("ArrowRight");
await page.waitForTimeout(30);
-ok(/p2.*full|full.*p2/.test(decodeURIComponent((await shown()) ?? "")), `a step lands on the next whole picture at once ${await shown()}`);
+ok(/p2.*fit\d+/.test(decodeURIComponent((await shown()) ?? "")) && (await enough()), `a step lands on the next one, made its shown size, at once ${await shown()}`);
await b.close();
process.exitCode = failures ? 1 : (process.exitCode ?? 0);
diff --git a/.uiverify/photos-video.mjs b/.uiverify/photos-video.mjs
index ac612ad..1e3bc36 100644
--- a/.uiverify/photos-video.mjs
+++ b/.uiverify/photos-video.mjs
@@ -36,7 +36,9 @@ await page.locator('.px-tile[data-id="p3"]').dblclick();
await page.waitForTimeout(600);
const video = page.locator(".px-stage video");
ok((await video.count()) === 1 && (await video.getAttribute("src")) === `${base}/p3/original`, `the video is in the viewer, from the loopback server ${await video.getAttribute("src").catch(() => "")}`);
-ok(await video.evaluate((v) => v.controls && v.autoplay), "with the player's own controls, playing at once");
+ok(await video.evaluate((v) => !v.controls && v.autoplay), "playing at once, with no engine controls over it");
+ok((await page.locator(".px-player-bar").count()) === 1 && (await page.getByRole("slider", { name: "Playback position" }).count()) === 1,
+ "Photos' own controls in a capsule: play, where it is, a scrubber, what is left, sound");
const played = await video.evaluate((v) => new Promise((r) => {
v.muted = true;
void v.play().catch(() => undefined);
@@ -52,6 +54,21 @@ if (played.err) {
ok(played.t > 0.5, `it plays (at ${played.t.toFixed(2)}s)`);
const sought = await video.evaluate((v) => new Promise((r) => { v.onseeked = () => r(v.currentTime); v.currentTime = 4; }));
ok(Math.abs(sought - 4) < 0.5, `and seeks (to ${sought.toFixed(2)}s)`);
+ // The scrubber: a press three quarters along seeks there; the clocks say where.
+ const bar = await page.getByRole("slider", { name: "Playback position" }).boundingBox();
+ await page.mouse.click(bar.x + bar.width * 0.75, bar.y + bar.height / 2);
+ await page.waitForTimeout(300);
+ const at = await video.evaluate((v) => v.currentTime / v.duration);
+ ok(at > 0.65 && at < 0.85, `a press on the scrubber seeks there (${(at * 100).toFixed(0)}%)`);
+ ok(/^\d+:\d\d$/.test(await page.locator(".px-player-time").first().innerText()) && /^−\d+:\d\d$/.test(await page.locator(".px-player-time").last().innerText()),
+ `the clocks say where it is and what is left ${await page.locator(".px-player-time").allInnerTexts()}`);
+ // Space pauses and plays; the pause button says which.
+ await page.keyboard.press(" ");
+ await page.waitForTimeout(150);
+ ok(await video.evaluate((v) => v.paused) && (await page.getByRole("button", { name: "Play" }).count()) === 1, "Space pauses it");
+ const was = await video.evaluate((v) => v.muted);
+ await page.getByRole("button", { name: was ? "Unmute" : "Mute" }).click();
+ ok((await video.evaluate((v) => v.muted)) === !was, "and the sound button turns sound off and on");
ok(asked.some((u) => u.startsWith("/s3cret/p3/original")), "fetched from the app's server");
}
// Stepping to a photo leaves no video behind.
diff --git a/.uiverify/photos-viewer-real.mjs b/.uiverify/photos-viewer-real.mjs
index 744647f..2d2c399 100644
--- a/.uiverify/photos-viewer-real.mjs
+++ b/.uiverify/photos-viewer-real.mjs
@@ -1,7 +1,7 @@
-// The viewer with pictures of real size: the screen-sized one and the whole one (4000×3000)
-// lie exactly on each other, inside the stage, however large the whole one is — before, its
-// own size stretched the frame: the photo tore into two and ran off the window. The same
-// after the window is resized, and after stepping to the next photo.
+// The viewer with pictures of real size: the one made for the screen inside the stage; zoomed
+// in, the whole one (4000×3000) laid exactly over it however large it is — before, its own
+// size stretched the frame: the photo tore into two and ran off the window. The same after
+// the window is resized, and after stepping to the next photo.
import { engine } from "./engine.mjs";
import { SERVICES, installStub, openScreen } from "./stub.mjs";
const b = await engine.launch();
@@ -32,32 +32,33 @@ const lies = (b) => b.sharp && b.shown && Math.abs(b.sharp.x - b.shown.x) <= 1 &
const inside = (b) => b.shown.x >= b.stage.x - 1 && b.shown.y >= b.stage.y - 1 &&
b.shown.x + b.shown.w <= b.stage.x + b.stage.w + 1 && b.shown.y + b.shown.h <= b.stage.y + b.stage.h + 1;
-// The whole picture already there (on disk) as a photo opens: it must grow with the frame,
-// never stand full size over the one still growing.
+// Opening fetches no whole picture: only the one made for the screen.
await page.locator(".px-tile").nth(1).dblclick();
await page.waitForTimeout(1200);
-await page.keyboard.press("Escape");
-await page.waitForTimeout(700);
-await page.locator(".px-tile").nth(1).dblclick();
-await page.waitForTimeout(120);
-const mid = await page.evaluate(() => {
- const a = document.querySelector(".px-shown")?.getBoundingClientRect(), s = document.querySelector(".px-sharp")?.getBoundingClientRect();
- return a && s ? { a: Math.round(a.width), s: Math.round(s.width) } : null;
-});
-ok(mid && Math.abs(mid.a - mid.s) <= 1, `while it opens, the whole picture grows with it ${JSON.stringify(mid)}`);
-await page.waitForTimeout(1200);
let b1 = await boxes();
-ok(lies(b1), `the whole picture lies exactly on the screen-sized one ${JSON.stringify(b1)}`);
-ok(inside(b1), "and both stay inside the stage");
+ok((await page.locator(".px-sharp").count()) === 0 && inside(b1), `a photo opens on the picture made for the screen, inside the stage ${JSON.stringify(b1)}`);
+// Zoomed in, the whole picture lies exactly on it.
+const zoomIn = async () => {
+ await page.locator(".px-pan").dblclick({ position: { x: 30, y: 30 } });
+ await page.waitForTimeout(900);
+};
+await zoomIn();
+b1 = await boxes();
+ok(lies(b1), `zoomed in, the whole picture lies exactly on it ${JSON.stringify(b1)}`);
+await page.keyboard.press("Escape");
+await page.waitForTimeout(500);
await page.setViewportSize({ width: 900, height: 620 });
await page.waitForTimeout(500);
+await zoomIn();
b1 = await boxes();
-ok(lies(b1) && inside(b1), `after a resize too ${JSON.stringify(b1)}`);
+ok(lies(b1), `after a resize too ${JSON.stringify(b1)}`);
+await page.keyboard.press("Escape");
+await page.waitForTimeout(500);
await page.setViewportSize({ width: 1280, height: 800 });
await page.keyboard.press("ArrowLeft");
await page.waitForTimeout(1200);
b1 = await boxes();
-ok(lies(b1) && inside(b1), `and on the next photo ${JSON.stringify(b1)}`);
+ok(inside(b1), `and on the next photo ${JSON.stringify(b1)}`);
await page.keyboard.press("Escape");
await page.waitForTimeout(700);
// A narrow window, a photo opened in it: inside, never wider than the window lets it be.
diff --git a/.uiverify/photos.mjs b/.uiverify/photos.mjs
index 5aaf5e2..ef95e7e 100644
--- a/.uiverify/photos.mjs
+++ b/.uiverify/photos.mjs
@@ -40,7 +40,7 @@ const first = await page.locator(".px-stage .px-shown").getAttribute("src");
await page.keyboard.press("ArrowRight");
await page.waitForTimeout(100);
const second = await page.locator(".px-stage .px-shown").getAttribute("src");
-ok(first && second && first !== second && /medium/.test(second), "the right arrow goes to the next photo, at screen size");
+ok(first && second && first !== second && /fit\d+/.test(second), "the right arrow goes to the next photo, made the size the screen shows it");
await page.getByRole("button", { name: "Download" }).click();
await page.waitForTimeout(200);
ok((await page.evaluate(() => window.__downloads?.at(-1)?.id)) === "p2", "Download saves that photo's original");
diff --git a/Cargo.lock b/Cargo.lock
index 56a5b48..6ba64a4 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1192,6 +1192,18 @@ version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7360491ce676a36bf9bb3c56c1aa791658183a54d2744120f27285738d90465a"
+[[package]]
+name = "fast_image_resize"
+version = "6.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e9c50201dc184ba6553da1695aac20a042efffbe2d84542cee31917c86c3ab1e"
+dependencies = [
+ "cfg-if",
+ "document-features",
+ "num-traits",
+ "thiserror 2.0.20",
+]
+
[[package]]
name = "fastrand"
version = "2.5.0"
@@ -3351,6 +3363,7 @@ dependencies = [
name = "quince-media"
version = "0.1.0"
dependencies = [
+ "fast_image_resize",
"image",
]
diff --git a/crates/quince-media/Cargo.toml b/crates/quince-media/Cargo.toml
index 4803a44..1f302bf 100644
--- a/crates/quince-media/Cargo.toml
+++ b/crates/quince-media/Cargo.toml
@@ -5,6 +5,7 @@ edition.workspace = true
license.workspace = true
[dependencies]
+fast_image_resize = "6.1.0"
# Only the formats Apple has been observed to serve. Every extra decoder is compile time and
# attack surface for no gain.
image = { version = "0.25", default-features = false, features = ["png", "jpeg"] }
diff --git a/crates/quince-media/src/lib.rs b/crates/quince-media/src/lib.rs
index 09284d8..ee220e1 100644
--- a/crates/quince-media/src/lib.rs
+++ b/crates/quince-media/src/lib.rs
@@ -91,6 +91,86 @@ fn cut(image: image::DynamicImage, crop: Option<Crop>) -> image::DynamicImage {
///
/// A photograph re-encoded as PNG is several times the size for no visible gain, and these are
/// read back on every scroll.
+/// A picture's longer side, read from its header alone (nothing decoded).
+#[must_use]
+pub fn long_side(bytes: &[u8]) -> Option<u32> {
+ image::ImageReader::new(std::io::Cursor::new(bytes))
+ .with_guessed_format()
+ .ok()?
+ .into_dimensions()
+ .ok()
+ .map(|(w, h)| w.max(h))
+}
+
+/// A photo made the size it is shown at: its longer side `long` pixels (never larger than it
+/// is), turned the way its camera said, resampled with Lanczos.
+///
+/// WebKitGTK shrinks a large picture by sampling it, with no smoothing first: a 4032-pixel
+/// photo drawn 1000 wide came out with broken letters and moiré (its own output, compared with
+/// an ideal resample). Drawn at its own size, a picture is exactly as sharp as it can be. This
+/// is what the viewer and the grid show; the whole picture only when zoomed in past it.
+///
+/// `None` when the picture is already no larger: then the original is the one to show.
+///
+/// # Errors
+/// When the bytes are not an image this can decode.
+pub fn fit(bytes: &[u8], long: u32) -> Result<Option<Vec<u8>>, image::ImageError> {
+ use fast_image_resize as fr;
+ use image::ImageDecoder;
+ let mut decoder = image::ImageReader::new(std::io::Cursor::new(bytes))
+ .with_guessed_format()?
+ .into_decoder()?;
+ let orientation = decoder
+ .orientation()
+ .unwrap_or(image::metadata::Orientation::NoTransforms);
+ let (w, h) = decoder.dimensions();
+ if w.max(h) <= long {
+ return Ok(None);
+ }
+ let mut picture = image::DynamicImage::from_decoder(decoder)?;
+ picture.apply_orientation(orientation);
+ let (w, h) = (picture.width(), picture.height());
+ let k = f64::from(long) / f64::from(w.max(h));
+ let (tw, th) = (
+ ((f64::from(w) * k).round() as u32).max(1),
+ ((f64::from(h) * k).round() as u32).max(1),
+ );
+ let alpha = transparent(&picture);
+ let (pixels, kind) = if alpha {
+ (picture.to_rgba8().into_raw(), fr::PixelType::U8x4)
+ } else {
+ (picture.to_rgb8().into_raw(), fr::PixelType::U8x3)
+ };
+ let to_err = |e: String| {
+ image::ImageError::Parameter(image::error::ParameterError::from_kind(
+ image::error::ParameterErrorKind::Generic(e),
+ ))
+ };
+ let src =
+ fr::images::Image::from_vec_u8(w, h, pixels, kind).map_err(|e| to_err(e.to_string()))?;
+ let mut dst = fr::images::Image::new(tw, th, kind);
+ fr::Resizer::new()
+ .resize(
+ &src,
+ &mut dst,
+ &fr::ResizeOptions::new()
+ .resize_alg(fr::ResizeAlg::Convolution(fr::FilterType::Lanczos3)),
+ )
+ .map_err(|e| to_err(e.to_string()))?;
+ let mut out = std::io::Cursor::new(Vec::new());
+ if alpha {
+ image::RgbaImage::from_raw(tw, th, dst.into_vec())
+ .ok_or_else(|| to_err("resized picture had the wrong size".into()))?
+ .write_to(&mut out, image::ImageFormat::Png)?;
+ } else {
+ let rgb = image::RgbImage::from_raw(tw, th, dst.into_vec())
+ .ok_or_else(|| to_err("resized picture had the wrong size".into()))?;
+ // High quality: this is the picture people look at, not a row's avatar.
+ image::codecs::jpeg::JpegEncoder::new_with_quality(&mut out, 92).encode_image(&rgb)?;
+ }
+ Ok(Some(out.into_inner()))
+}
+
fn encode(image: &image::DynamicImage) -> Result<Vec<u8>, image::ImageError> {
let mut out = std::io::Cursor::new(Vec::new());
if transparent(image) {
@@ -109,6 +189,29 @@ fn transparent(image: &image::DynamicImage) -> bool {
#[cfg(test)]
mod tests {
+ #[test]
+ fn a_photo_is_made_its_shown_size_turned_the_camera_s_way() {
+ // 400×300 with a red left half; JPEG.
+ let img = image::RgbImage::from_fn(400, 300, |x, _| {
+ if x < 200 {
+ image::Rgb([255, 0, 0])
+ } else {
+ image::Rgb([0, 0, 255])
+ }
+ });
+ let mut jpg = std::io::Cursor::new(Vec::new());
+ image::DynamicImage::ImageRgb8(img)
+ .write_to(&mut jpg, image::ImageFormat::Jpeg)
+ .unwrap();
+ let out = super::fit(jpg.get_ref(), 200).unwrap().unwrap();
+ let back = image::load_from_memory(&out).unwrap();
+ assert_eq!((back.width(), back.height()), (200, 150));
+ let left = back.to_rgb8().get_pixel(20, 75).0;
+ assert!(left[0] > 200 && left[2] < 60, "{left:?}");
+ // Never made larger than it is.
+ assert!(super::fit(jpg.get_ref(), 800).unwrap().is_none());
+ }
+
use super::*;
use image::{DynamicImage, GenericImageView, Rgba, RgbaImage};
diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs
index b350540..81e9c3e 100644
--- a/src-tauri/src/main.rs
+++ b/src-tauri/src/main.rs
@@ -3670,6 +3670,7 @@ fn main() {
let wanted = photo_guid(uri.host(), uri.path());
let attachment = note_part(uri.path());
let picture = photos::requested(uri.path());
+ let fit = photos::requested_fit(uri.path());
let queued = photos::requested_upload(uri.path());
tauri::async_runtime::spawn(async move {
// A file on its way into Photos, small, for the upload panel.
@@ -3686,6 +3687,21 @@ fn main() {
responder.respond(response.unwrap_or_default());
return;
}
+ // A photo's picture made the size it is shown at.
+ if let Some((id, long)) = fit {
+ let response = match photos::fitted(&app, &id, long).await {
+ Ok(bytes) => tauri::http::Response::builder()
+ .status(200)
+ .header("Content-Type", image_type(&bytes))
+ .header("Cache-Control", "private, max-age=86400")
+ .body(bytes),
+ Err(_) => tauri::http::Response::builder()
+ .status(404)
+ .body(Vec::new()),
+ };
+ responder.respond(response.unwrap_or_default());
+ return;
+ }
// A photo's picture: from the disk cache, or fetched from Apple once and kept.
if let Some((id, size)) = picture {
let response = match photos::picture(&app, &id, size).await {
diff --git a/src-tauri/src/photos.rs b/src-tauri/src/photos.rs
index c174c3e..99023a2 100644
--- a/src-tauri/src/photos.rs
+++ b/src-tauri/src/photos.rs
@@ -148,6 +148,80 @@ pub fn requested(path: &str) -> Option<(String, Size)> {
Some((id.to_string(), size))
}
+/// The widths a picture is made at for the screen (its longer side), in steps — so a photo
+/// is made a handful of times, not once per window size.
+pub const FITS: [u32; 11] = [128, 256, 384, 512, 768, 1024, 1536, 2048, 2560, 3072, 3840];
+
+/// A `quince://` request for a picture made the size it is shown at: `pic/<asset id>/fit<N>`,
+/// N one of [`FITS`].
+pub fn requested_fit(path: &str) -> Option<(String, u32)> {
+ let path = crate::percent_decode(path.trim_start_matches('/'));
+ let (id, size) = path.strip_prefix("pic/")?.rsplit_once('/')?;
+ let long: u32 = size.strip_prefix("fit")?.parse().ok()?;
+ if !FITS.contains(&long)
+ || id.is_empty()
+ || !id
+ .chars()
+ .all(|c| c.is_ascii_alphanumeric() || c == '-' || c == '_')
+ {
+ return None;
+ }
+ Some((id.to_string(), long))
+}
+
+/// Pictures being made at once: one per core, so a grid filling in never starves the window.
+static MAKING: tokio::sync::Semaphore = tokio::sync::Semaphore::const_new(0);
+static MAKING_READY: std::sync::Once = std::sync::Once::new();
+
+/// A photo's picture made the size it is shown at, longer side `long` (see
+/// `quince_media::fit`): from the smallest picture already kept that is at least that large —
+/// the thumbnail for the grid, the screen-sized one or the whole one for the viewer — made
+/// once and kept on disk.
+pub async fn fitted(app: &AppHandle, id: &str, long: u32) -> Result<Vec<u8>, String> {
+ let path = crate::state_dir(app)
+ .join("photos")
+ .join("fit")
+ .join(long.to_string())
+ .join(id);
+ if let Ok(bytes) = tokio::fs::read(&path).await {
+ return Ok(bytes);
+ }
+ MAKING_READY.call_once(|| {
+ let cores = std::thread::available_parallelism().map_or(4, std::num::NonZero::get);
+ MAKING.add_permits(cores);
+ });
+ let mut last = None;
+ for size in [Size::Thumb, Size::Medium, Size::Full] {
+ let source = picture(app, id, size).await?;
+ let src = source.clone();
+ let _turn = MAKING.acquire().await.map_err(|e| e.to_string())?;
+ let made = tokio::task::spawn_blocking(move || {
+ let big = quince_media::long_side(&src).is_some_and(|l| l >= long);
+ if !big && size != Size::Full {
+ return Ok(None);
+ }
+ // Large enough (or the largest there is): made the size it is shown at, or, when it
+ // is no larger already, shown as it is.
+ quince_media::fit(&src, long).map(|out| Some(out.unwrap_or(src)))
+ })
+ .await
+ .map_err(|e| e.to_string())?
+ .map_err(|e| e.to_string())?;
+ if let Some(bytes) = made {
+ if let Some(dir) = path.parent() {
+ let _ = tokio::fs::create_dir_all(dir).await;
+ }
+ let part = path.with_extension("part");
+ if tokio::fs::write(&part, &bytes).await.is_ok() {
+ let _ = tokio::fs::rename(&part, &path).await;
+ }
+ return Ok(bytes);
+ }
+ last = Some(source);
+ }
+ last.ok_or_else(|| "No picture of that photo could be made.".into())
+}
+
fn cache_path(app: &AppHandle, id: &str, size: Size) -> PathBuf {
crate::state_dir(app)
.join("photos")
@@ -1647,6 +1721,20 @@ mod tests {
assert_eq!(byte_range(None, 0, all), None);
}
+ #[test]
+ fn a_fitted_picture_is_asked_for_by_its_step_only() {
+ assert_eq!(
+ requested_fit("/pic/A1-b/fit1024"),
+ Some(("A1-b".into(), 1024))
+ );
+ assert_eq!(requested_fit("pic%2FA1%2Ffit256"), Some(("A1".into(), 256)));
+ // Not a step (the cache would grow without end), not a picture, not a path.
+ assert_eq!(requested_fit("/pic/A1/fit1000"), None);
+ assert_eq!(requested_fit("/pic/A1/full"), None);
+ assert_eq!(requested_fit("/pic/../x/fit256"), None);
+ assert_eq!(requested_fit("/pic/A1/fitx"), None);
+ }
+
#[test]
fn quicktime_or_mpeg4() {
assert_eq!(video_type(b"\0\0\0\x14ftypqt "), "video/quicktime");
diff --git a/src/lib/ipc.ts b/src/lib/ipc.ts
index b24848e..435c7dd 100644
--- a/src/lib/ipc.ts
+++ b/src/lib/ipc.ts
@@ -577,6 +577,19 @@ export function pictureSrc(id: string, size: "thumb" | "medium" | "full" | "orig
return convertFileSrc(`pic/${id}/${size}`, "quince");
}
+/** The longer sides a picture is made at for the screen (photos.rs FITS). */
+export const FITS = [128, 256, 384, 512, 768, 1024, 1536, 2048, 2560, 3072, 3840];
+
+/**
+ * A photo's picture made `long` device pixels on its longer side — the step at or above it —
+ * resampled with care by the app. The engine then draws it at its own size: shrunk by
+ * WebKitGTK instead, a large picture came out jagged.
+ */
+export function fitSrc(id: string, long: number): string {
+ const step = FITS.find((f) => f >= long) ?? FITS[FITS.length - 1];
+ return convertFileSrc(`pic/${id}/fit${step}`, "quince");
+}
+
export type PhotoAlbum = {
id: string;
name: string;
diff --git a/src/screens/PhotosView.tsx b/src/screens/PhotosView.tsx
index df32413..e7c0567 100644
--- a/src/screens/PhotosView.tsx
+++ b/src/screens/PhotosView.tsx
@@ -12,6 +12,7 @@ import {
api,
messageOf,
pictureSrc,
+ fitSrc,
PHOTO_UPLOAD,
type Photo,
type PhotoAlbum,
@@ -25,6 +26,7 @@ import { RowMenu, type MenuEntry } from "../components/RowMenu";
import { Portal } from "../components/Portal";
import { Slideshow } from "./photos/Slideshow";
import { useAsk } from "./photos/Ask";
+import { VideoPlayer } from "./photos/VideoPlayer";
import { tintFrom } from "../lib/tint";
import { DownloadOptions, type Want } from "./photos/DownloadOptions";
import { AdjustDate } from "./photos/AdjustDate";
@@ -145,7 +147,7 @@ function Filmstrip({ photos, at, onPick }: { photos: Photo[]; at: number; onPick
aria-current={i === at}
onClick={() => i !== at && onPick(i)}
>
- <img src={pictureSrc(p.id, "thumb")} alt="" loading="lazy" decoding="async" draggable={false} />
+ <img src={fitSrc(p.id, (i === at ? SHOWN : SLIP * 2) * (window.devicePixelRatio || 1))} alt="" loading="lazy" decoding="async" draggable={false} />
</button>,
);
}
@@ -159,53 +161,51 @@ function Filmstrip({ photos, at, onPick }: { photos: Photo[]; at: number; onPick
}
/**
- * Whole pictures already fetched and decoded, by photo. A photo in here opens and is stepped to
- * at full quality at once — never a blurry stand-in first. The bytes stay in the webview's
- * cache (and on disk); this is only which are known to be ready.
+ * The pictures the viewer shows — each made the size it is shown at (see fitSrc) — already
+ * fetched and decoded, by address. A photo whose picture is in here opens and is stepped to at
+ * full quality at once, never a smaller copy first.
*/
-const decodedFull = new Set<string>();
-/** The rest on a tile before its whole picture is fetched (see Tile). */
+const decoded = new Set<string>();
+/** The rest on a tile before its picture is fetched (see Tile). */
let resting: number | undefined;
const warming = new Map<string, Promise<boolean>>();
-function warm(id: string): Promise<boolean> {
- if (decodedFull.has(id)) return Promise.resolve(true);
- let ready = warming.get(id);
+/** The viewer's stage, in CSS pixels, as last measured (a guess from the window before). */
+let stageBox = { w: 0, h: 0 };
+/** The picture the viewer shows for a photo: the size its stage draws it at. */
+function viewSrc(p: Photo): string {
+ const box = stageBox.w ? stageBox : { w: Math.max(320, window.innerWidth - 400), h: Math.max(240, window.innerHeight - 140) };
+ const r = p.width && p.height ? p.width / p.height : 4 / 3;
+ const w = Math.min(box.w, box.h * r, (p.width || 4000) * 1.5);
+ return fitSrc(p.id, Math.max(w, w / r) * (window.devicePixelRatio || 1));
+}
+function warm(p: Photo): Promise<boolean> {
+ const url = viewSrc(p);
+ if (decoded.has(url)) return Promise.resolve(true);
+ let ready = warming.get(url);
if (!ready) {
const img = new Image();
img.decoding = "async";
- img.src = pictureSrc(id, "full");
+ img.src = url;
ready = img
.decode()
.then(
() => {
- decodedFull.add(id);
+ decoded.add(url);
return true;
},
() => false,
)
- .finally(() => warming.delete(id));
- warming.set(id, ready);
+ .finally(() => warming.delete(url));
+ warming.set(url, ready);
}
return ready;
}
-/**
- * Photos whose thumbnail is too small for their tile. Apple's thumbnails run from about 360 to
- * 560 pixels on the long side; a large tile on a dense screen needs more, and a thumbnail
- * stretched over it is soft. Such a tile asks for the screen-sized picture instead, once.
- */
-const finer = new Set<string>();
-function sharpen(img: HTMLImageElement, id: string) {
- if (finer.has(id) || !img.naturalWidth || !img.naturalHeight) return;
- const fit = img.closest("[data-fit]") !== null;
- const sx = (img.clientWidth * window.devicePixelRatio) / img.naturalWidth;
- const sy = (img.clientHeight * window.devicePixelRatio) / img.naturalHeight;
- // Cover crops to the larger stretch; a fitted tile shows the whole picture.
- const stretch = fit ? Math.min(sx, sy) : Math.max(sx, sy);
- if (stretch > 1.1) {
- finer.add(id);
- img.src = pictureSrc(id, "medium");
- }
+/** A tile's picture: the size it is drawn at — the whole cell when fitted, cropped to fill it
+ * as a square (so its longer side reaches past the cell). */
+function tileSrc(p: Photo, cell: number, fit: boolean): string {
+ const r = p.width && p.height ? Math.max(p.width, p.height) / Math.min(p.width, p.height) : 1;
+ return fitSrc(p.id, fit ? cell : cell * r);
}
/** What a tile can ask of the screen; one object, kept the same, so tiles need not redraw. */
@@ -229,6 +229,7 @@ const Tile = memo(function Tile({
left,
soon,
fit,
+ cell,
act,
}: {
photo: Photo;
@@ -238,6 +239,8 @@ const Tile = memo(function Tile({
left: string | null;
soon: boolean;
fit: boolean;
+ /** A cell's width in device pixels. */
+ cell: number;
act: Acts;
}) {
return (
@@ -263,11 +266,11 @@ const Tile = memo(function Tile({
onPointerEnter={() => {
if (photo.kind === "video") return;
window.clearTimeout(resting);
- resting = window.setTimeout(() => void warm(photo.id), 140);
+ resting = window.setTimeout(() => void warm(photo), 140);
}}
onPointerLeave={() => window.clearTimeout(resting)}
onPointerDown={() => {
- if (photo.kind !== "video") void warm(photo.id);
+ if (photo.kind !== "video") void warm(photo);
}}
draggable
onDragStart={(e) => act.drag(photo, e)}
@@ -279,16 +282,15 @@ const Tile = memo(function Tile({
>
{/* The picture's own frame: the whole tile when squares, the photo's own shape when
fitted — what the badges and the selection sit on. */}
- <span className="px-pic" style={fit && photo.width && photo.height ? fitFrame(photo) : undefined}>
+ <span
+ className="px-pic"
+ // The thumbnail underneath while the picture made for this tile's size comes.
+ style={{ ...(fit && photo.width && photo.height ? fitFrame(photo) : {}), backgroundImage: `url("${pictureSrc(photo.id, "thumb")}")` }}
+ >
{/* Fetched as soon as its month is built, well ahead of the screen — not left to the
- engine's own lazy margin, which a fast scroll outran. */}
- <img
- src={pictureSrc(photo.id, finer.has(photo.id) ? "medium" : "thumb")}
- alt=""
- decoding="async"
- draggable={false}
- onLoad={(e) => sharpen(e.currentTarget, photo.id)}
- />
+ engine's own lazy margin, which a fast scroll outran — and made the size it is
+ drawn at, so the engine never shrinks it. */}
+ <img src={tileSrc(photo, cell, fit)} alt="" decoding="async" draggable={false} />
{photo.kind === "video" && (
<span className="px-badge px-duration">
<Play size={10} strokeWidth={0} fill="currentColor" aria-hidden="true" />
@@ -317,6 +319,7 @@ const Month = memo(function Month({
eager,
across,
fit,
+ cell,
act,
}: {
label: string;
@@ -327,6 +330,7 @@ const Month = memo(function Month({
eager: boolean;
across: number;
fit: boolean;
+ cell: number;
act: Acts;
}) {
const ref = useRef<HTMLElement | null>(null);
@@ -367,6 +371,7 @@ const Month = memo(function Month({
left={t?.words ?? null}
soon={t?.soon ?? false}
fit={fit}
+ cell={cell}
act={act}
/>
);
@@ -715,7 +720,6 @@ export function PhotosView() {
}, glide ? 340 : 160);
});
};
- const [sharp, setSharp] = useState<string | null>(null);
/** Videos this computer's engine could not play; each opens in the system's player instead. */
const [unplayable, setUnplayable] = useState<Set<string>>(() => new Set());
// The window's player reads only http(s): videos come from the app's own loopback server.
@@ -751,13 +755,26 @@ export function PhotosView() {
};
useEffect(() => {
unzoom(false);
- setSharp(null);
}, [shown?.id]);
- // The whole picture, not the screen-sized one, as Photos shows a photo: fetched as soon as
- // it opens (once, then from disk) and laid over the quick one when it has arrived.
- useEffect(() => {
- if (shown && shown.kind !== "video") setSharp(shown.id);
- }, [shown?.id]); // eslint-disable-line react-hooks/exhaustive-deps
+ // The stage, measured as it opens and as the window is resized: the picture the viewer shows
+ // is made for its size (viewSrc), and asked for again only when that size crosses a step.
+ const [, setStep] = useState("");
+ useLayoutEffect(() => {
+ const el = stage.current;
+ if (!el) return undefined;
+ const measure = () => {
+ const cs = getComputedStyle(el);
+ stageBox = {
+ w: el.clientWidth - parseFloat(cs.paddingLeft) - parseFloat(cs.paddingRight),
+ h: el.clientHeight - parseFloat(cs.paddingTop) - parseFloat(cs.paddingBottom),
+ };
+ if (shown && shown.kind !== "video") setStep(viewSrc(shown));
+ };
+ measure();
+ const watch = new ResizeObserver(measure);
+ watch.observe(el);
+ return () => watch.disconnect();
+ }, [open !== null, shown?.id]); // eslint-disable-line react-hooks/exhaustive-deps
// A pinch or Ctrl + wheel: the page must not zoom too, so this listener is not passive.
useEffect(() => {
const el = stage.current;
@@ -778,7 +795,7 @@ export function PhotosView() {
if (open === null || !photos) return;
for (const by of [1, -1, 2, -2]) {
const p = photos[open + by];
- if (p && p.kind !== "video") void warm(p.id);
+ if (p && p.kind !== "video") void warm(p);
}
}, [open, photos]);
@@ -1020,7 +1037,7 @@ export function PhotosView() {
// Open at full quality: the whole picture decoded first — from disk, a moment — but never
// waited on for longer than a blink (a click must answer at once); past that it opens on
// its thumbnail and screen-sized picture, and the whole one follows.
- if (p.kind !== "video") await Promise.race([warm(p.id), new Promise((r) => window.setTimeout(r, 150))]);
+ if (p.kind !== "video") await Promise.race([warm(p), new Promise((r) => window.setTimeout(r, 150))]);
stopClosing();
const tile = document.querySelector<HTMLElement>(`.px-tile[data-id="${CSS.escape(p.id)}"]`);
origin.current = tile?.getBoundingClientRect() ?? null;
@@ -1616,6 +1633,19 @@ export function PhotosView() {
if (scroller.current) scroller.current.scrollTop = 0;
}, [drawn]);
const across = ACROSS[zoom];
+ // A cell's width in device pixels, for the size each tile's picture is made at; in steps of
+ // 32, so a window being resized does not redraw every tile on every frame.
+ const [gridWidth, setGridWidth] = useState(0);
+ useLayoutEffect(() => {
+ const el = scroller.current;
+ if (!el) return undefined;
+ const measure = () => setGridWidth(Math.ceil(el.clientWidth / 32) * 32);
+ measure();
+ const watch = new ResizeObserver(measure);
+ watch.observe(el);
+ return () => watch.disconnect();
+ }, []);
+ const cell = Math.round(((gridWidth || 1200) / across) * (window.devicePixelRatio || 1));
// A new album or folder, at the top or in a folder: named in place in the sidebar.
const startNew = (parent: string | null, folder: boolean) => {
@@ -2057,6 +2087,7 @@ export function PhotosView() {
eager={k < 3}
across={across}
fit={fit}
+ cell={cell}
act={act}
/>
))}
@@ -2150,16 +2181,11 @@ export function PhotosView() {
// Played here, as Photos plays one: from the disk cache, in the pieces the
// player asks for, so it starts at once and seeks anywhere.
<div className="px-video">
- <video
+ <VideoPlayer
key={shown.id}
- className="px-shown"
src={`${videoBase}/${shown.id}/original`}
- poster={pictureSrc(shown.id, "medium")}
- aria-label={shown.filename ?? "Video"}
- controls
- autoPlay
- playsInline
- preload="auto"
+ poster={viewSrc(shown)}
+ label={shown.filename ?? "Video"}
style={fitted(shown)}
onError={() => setUnplayable((was) => new Set(was).add(shown.id))}
/>
@@ -2191,13 +2217,11 @@ export function PhotosView() {
onPointerUp={() => (dragging.current = null)}
onPointerCancel={() => (dragging.current = null)}
>
- {decodedFull.has(shown.id) ? (
- // Already whole and decoded: drawn at once, at full quality, alone.
- <img key={`${shown.id}-whole`} className="px-shown" src={pictureSrc(shown.id, "full")} alt={shown.filename ?? ""} decoding="async" draggable={false} style={fitted(shown)} />
- ) : (
- <img key={shown.id} className="px-shown" src={pictureSrc(shown.id, "medium")} alt={shown.filename ?? ""} decoding="async" draggable={false} style={fitted(shown)} />
- )}
- {sharp === shown.id && !decodedFull.has(shown.id) && (
+ {/* The picture made the size the stage draws it at — every pixel used, none
+ thrown away by the engine — over the thumbnail until it is decoded. */}
+ <img key={shown.id} className="px-shown" src={viewSrc(shown)} alt={shown.filename ?? ""} decoding="async" draggable={false} style={fitted(shown)} />
+ {/* Zoomed in, the whole picture: only then are its own pixels the ones seen. */}
+ {zoomed && (
<img
key={`${shown.id}-full`}
className="px-sharp"
diff --git a/src/screens/photos/VideoPlayer.tsx b/src/screens/photos/VideoPlayer.tsx
new file mode 100644
index 0000000..6bf305c
--- /dev/null
+++ b/src/screens/photos/VideoPlayer.tsx
@@ -0,0 +1,194 @@
+/**
+ * A video as Photos plays one: the film alone on the stage, its controls in a glass capsule
+ * that floats over the bottom of it and fades away while the pointer rests — play and pause,
+ * where it is, a scrubber, what is left, and sound. A click on the film plays or pauses it;
+ * Space does too (the viewer's own keys still step through the photos).
+ *
+ * The scrubber follows the film every frame (the engine's own timeupdate comes four times a
+ * second, and a progress bar that jumps reads as a stutter), and dragging it seeks as it goes.
+ */
+import { useCallback, useEffect, useRef, useState } from "react";
+import { Pause, Play, Volume2, VolumeX } from "lucide-react";
+
+const clock = (s: number) => {
+ if (!Number.isFinite(s) || s < 0) s = 0;
+ const h = Math.floor(s / 3600);
+ const m = Math.floor((s % 3600) / 60);
+ const sec = Math.floor(s % 60);
+ return h ? `${h}:${String(m).padStart(2, "0")}:${String(sec).padStart(2, "0")}` : `${m}:${String(sec).padStart(2, "0")}`;
+};
+
+export function VideoPlayer({
+ src,
+ poster,
+ label,
+ style,
+ onError,
+}: {
+ src: string;
+ poster: string;
+ label: string;
+ style?: React.CSSProperties;
+ onError: () => void;
+}) {
+ const film = useRef<HTMLVideoElement | null>(null);
+ const fill = useRef<HTMLDivElement | null>(null);
+ const knob = useRef<HTMLDivElement | null>(null);
+ const said = useRef<HTMLSpanElement | null>(null);
+ const left = useRef<HTMLSpanElement | null>(null);
+ const [playing, setPlaying] = useState(false);
+ const [muted, setMuted] = useState(false);
+ const [awake, setAwake] = useState(true);
+ const [hover, setHover] = useState<{ x: number; t: number } | null>(null);
+ const dragging = useRef(false);
+
+ // Where it is, drawn straight to the scrubber and the clocks once a frame — never through
+ // React, so a playing film redraws nothing else.
+ const draw = useCallback(() => {
+ const v = film.current;
+ if (!v) return;
+ const d = v.duration || 0;
+ const k = d ? Math.min(1, v.currentTime / d) : 0;
+ if (fill.current) fill.current.style.transform = `scaleX(${k})`;
+ if (knob.current) knob.current.style.left = `${k * 100}%`;
+ if (said.current) said.current.textContent = clock(v.currentTime);
+ if (left.current) left.current.textContent = `−${clock(d - v.currentTime)}`;
+ }, []);
+ useEffect(() => {
+ if (!playing) return undefined;
+ let id = 0;
+ const tick = () => {
+ draw();
+ id = requestAnimationFrame(tick);
+ };
+ id = requestAnimationFrame(tick);
+ return () => cancelAnimationFrame(id);
+ }, [playing, draw]);
+
+ // The controls show when the pointer moves and go once it rests — but never while paused.
+ const idle = useRef<number | undefined>(undefined);
+ const wake = useCallback(() => {
+ setAwake(true);
+ window.clearTimeout(idle.current);
+ idle.current = window.setTimeout(() => setAwake(false), 2000);
+ }, []);
+ useEffect(() => () => window.clearTimeout(idle.current), []);
+
+ const toggle = useCallback(() => {
+ const v = film.current;
+ if (!v) return;
+ if (v.paused) void v.play().catch(() => {});
+ else v.pause();
+ }, []);
+ // Space plays and pauses, before the viewer's own keys.
+ useEffect(() => {
+ const key = (e: KeyboardEvent) => {
+ if (e.key !== " " || (e.target as HTMLElement | null)?.closest?.("input, textarea, [contenteditable]")) return;
+ e.preventDefault();
+ e.stopPropagation();
+ toggle();
+ wake();
+ };
+ window.addEventListener("keydown", key, true);
+ return () => window.removeEventListener("keydown", key, true);
+ }, [toggle, wake]);
+
+ const seekTo = (clientX: number, bar: HTMLElement) => {
+ const v = film.current;
+ if (!v || !v.duration) return;
+ const r = bar.getBoundingClientRect();
+ v.currentTime = Math.max(0, Math.min(1, (clientX - r.left) / r.width)) * v.duration;
+ draw();
+ };
+
+ return (
+ <div className={`px-player${awake || !playing ? " is-awake" : ""}`} style={style} onPointerMove={wake}>
+ <video
+ ref={film}
+ className="px-shown"
+ src={src}
+ poster={poster}
+ aria-label={label}
+ autoPlay
+ playsInline
+ preload="auto"
+ onClick={() => {
+ toggle();
+ wake();
+ }}
+ onPlay={() => {
+ setPlaying(true);
+ wake();
+ }}
+ onPause={() => {
+ setPlaying(false);
+ draw();
+ }}
+ onLoadedMetadata={draw}
+ onSeeked={draw}
+ onVolumeChange={(e) => setMuted(e.currentTarget.muted)}
+ onError={onError}
+ />
+ <div className="px-player-bar px-capsule" role="toolbar" aria-label="Video controls" onClick={(e) => e.stopPropagation()}>
+ <button className="px-cap" aria-label={playing ? "Pause" : "Play"} onClick={toggle}>
+ {playing ? <Pause size={17} strokeWidth={0} fill="currentColor" /> : <Play size={17} strokeWidth={0} fill="currentColor" />}
+ </button>
+ <span className="px-player-time" ref={said}>
+ 0:00
+ </span>
+ <div
+ className="px-scrub"
+ role="slider"
+ aria-label="Playback position"
+ aria-valuemin={0}
+ aria-valuemax={100}
+ tabIndex={0}
+ onPointerDown={(e) => {
+ e.currentTarget.setPointerCapture(e.pointerId);
+ dragging.current = true;
+ seekTo(e.clientX, e.currentTarget);
+ }}
+ onPointerMove={(e) => {
+ const r = e.currentTarget.getBoundingClientRect();
+ const v = film.current;
+ setHover({ x: e.clientX - r.left, t: v?.duration ? ((e.clientX - r.left) / r.width) * v.duration : 0 });
+ if (dragging.current) seekTo(e.clientX, e.currentTarget);
+ }}
+ onPointerUp={() => (dragging.current = false)}
+ onPointerCancel={() => (dragging.current = false)}
+ onPointerLeave={() => setHover(null)}
+ onKeyDown={(e) => {
+ const v = film.current;
+ if (!v || (e.key !== "ArrowLeft" && e.key !== "ArrowRight")) return;
+ e.preventDefault();
+ e.stopPropagation();
+ v.currentTime = Math.max(0, Math.min(v.duration || 0, v.currentTime + (e.key === "ArrowLeft" ? -5 : 5)));
+ }}
+ >
+ <div className="px-scrub-track">
+ <div className="px-scrub-fill" ref={fill} />
+ </div>
+ <div className="px-scrub-knob" ref={knob} />
+ {hover && (
+ <span className="px-scrub-tip" style={{ left: hover.x }}>
+ {clock(hover.t)}
+ </span>
+ )}
+ </div>
+ <span className="px-player-time" ref={left}>
+ −0:00
+ </span>
+ <button
+ className="px-cap"
+ aria-label={muted ? "Unmute" : "Mute"}
+ onClick={() => {
+ const v = film.current;
+ if (v) v.muted = !v.muted;
+ }}
+ >
+ {muted ? <VolumeX size={17} /> : <Volume2 size={17} />}
+ </button>
+ </div>
+ </div>
+ );
+}
diff --git a/src/styles/photos.css b/src/styles/photos.css
index b549790..9ac6b0f 100644
--- a/src/styles/photos.css
+++ b/src/styles/photos.css
@@ -903,3 +903,77 @@
.px-ask-actions button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.px-ask-actions .is-act { color: var(--accent); }
.px-ask-actions .is-act.danger { color: var(--danger); }
+
+/* ---- a video, as Photos plays one: the film alone, its controls in a capsule floating over
+ its foot that fades while the pointer rests (always there while paused) ----------------- */
+.px-player { position: relative; display: block; max-width: none; max-height: none; background: #000 center / 100% 100% no-repeat; }
+.px-player > video { display: block; width: 100%; height: 100%; object-fit: contain; outline: none; }
+.px-player-bar {
+ position: absolute;
+ left: 50%;
+ bottom: 14px;
+ width: min(560px, calc(100% - 28px));
+ translate: -50% 0;
+ align-items: center;
+ gap: 4px;
+ height: 40px;
+ padding: 0 6px;
+ border-radius: 20px;
+ opacity: 0;
+ transition: opacity 260ms ease;
+ pointer-events: none;
+}
+.px-player.is-awake .px-player-bar { opacity: 1; pointer-events: auto; }
+.px-player:not(.is-awake) { cursor: none; }
+.px-player-time {
+ flex: none;
+ min-width: 44px;
+ font-size: var(--t-12, 12px);
+ font-weight: 500;
+ font-variant-numeric: tabular-nums;
+ color: var(--text-2);
+ text-align: center;
+}
+.px-scrub { position: relative; flex: 1; height: 28px; display: flex; align-items: center; cursor: default; touch-action: none; }
+.px-scrub:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
+.px-scrub-track { position: relative; width: 100%; height: 4px; border-radius: 2px; overflow: hidden; background: color-mix(in srgb, var(--text) 20%, transparent); transition: height 160ms ease; }
+.px-scrub:hover .px-scrub-track { height: 6px; }
+.px-scrub-fill { position: absolute; inset: 0; transform-origin: left center; transform: scaleX(0); background: var(--text); }
+.px-scrub-knob {
+ position: absolute;
+ top: 50%;
+ left: 0;
+ width: 12px;
+ height: 12px;
+ margin: -6px 0 0 -6px;
+ border-radius: 50%;
+ background: var(--text);
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
+ scale: 0;
+ transition: scale 160ms ease;
+}
+.px-scrub:hover .px-scrub-knob, .px-scrub:active .px-scrub-knob { scale: 1; }
+.px-scrub-tip {
+ position: absolute;
+ bottom: 30px;
+ translate: -50% 0;
+ padding: 2px 7px;
+ border-radius: 6px;
+ font-size: var(--t-11, 11px);
+ font-variant-numeric: tabular-nums;
+ color: var(--text);
+ background: var(--sheet);
+ box-shadow: var(--glass-float);
+ pointer-events: none;
+ white-space: nowrap;
+}
+@media (prefers-reduced-motion: reduce) { .px-player-bar, .px-scrub-track, .px-scrub-knob { transition: none; } }
+/* Over the film the controls are dark glass in light and dark alike, as QuickTime and Photos
+ draw them: they sit on the picture, not on the page. */
+.px-player-bar { background: rgba(28, 28, 30, 0.74); box-shadow: inset 0 0.5px 0 rgba(255, 255, 255, 0.14), 0 8px 24px rgba(0, 0, 0, 0.35); }
+.px-player-bar .px-cap { color: #fff; }
+.px-player-bar .px-cap:hover { background: rgba(255, 255, 255, 0.14); }
+.px-player-bar .px-player-time { color: rgba(255, 255, 255, 0.78); }
+.px-player-bar .px-scrub-track { background: rgba(255, 255, 255, 0.24); }
+.px-player-bar .px-scrub-fill, .px-player-bar .px-scrub-knob { background: #fff; }
+.px-player-bar .px-scrub-tip { color: #fff; background: rgba(28, 28, 30, 0.9); }