From 8904acb5f79c052fa72974835640bb0aad82c9fd Mon Sep 17 00:00:00 2001 From: Duncan Tourolle Date: Sat, 22 Aug 2026 21:23:39 +0200 Subject: [PATCH] feat(player): run the old backend through the new contract MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit DR-245, first half. `LegacyPlayer` implements `MediaPlayer` over the existing `PlayerBackend`, so engines not yet ported — ExoPlayer, the webview element, the null backend — keep working while `PlayerController` moves across. Without it the port would have to land all four engines at once. It also makes the two designs comparable on one engine and one file. `open` reproduces the old sequence faithfully: load, play, then seek for a start position, with the seek's failure ignored exactly as callers used to ignore it. Making it pass would defeat the point. Running both engines over the same media is more informative than expected: MpvPlayer 9/9 LegacyPlayer 8/9 - transport_settings_round_trip fails Two things fall out of that. The start-position case now passes on *both*, because DR-241 was fixed inside MpvBackend rather than only in the new engine — so the suite confirms that fix independently, on a path it was not written against. And the one genuine failure is a capability gap rather than a bug: the old trait has no mute and no playback rate, so `LegacyPlayer` reports them unsupported instead of folding mute into volume and losing the user's level. That is the abstraction earning its keep on the first run: a missing capability that was previously invisible is now a named, failing case. The runner takes an engine argument: player-conformance [mpv|legacy] --- docs/requirements.md | 2 + src-tauri/src/bin/player_conformance.rs | 26 ++++- src-tauri/src/conformance_runner.rs | 80 +++++++++---- src-tauri/src/player/legacy_player.rs | 146 ++++++++++++++++++++++++ src-tauri/src/player/mod.rs | 2 + 5 files changed, 232 insertions(+), 24 deletions(-) create mode 100644 src-tauri/src/player/legacy_player.rs diff --git a/docs/requirements.md b/docs/requirements.md index 96d76375..d4469f0f 100644 --- a/docs/requirements.md +++ b/docs/requirements.md @@ -439,6 +439,8 @@ Internal architecture, components, and application logic. | DR-241 | A seek issued before MPV has a file to seek in is honoured, not dropped. `loadfile` returns as soon as the command is queued, so `time-pos` — a live property of the *loaded* file — does not resolve yet and setting it fails. The two callers that always hit that window are the ones a viewer notices: resume, and a transcoded seek, both of which re-open the stream and then ask for a position. The failed seek was discarded and the stream played from zero, which reads as "resume is broken" and "I cannot skip". The position is now held and applied by the `FileLoaded` handler; a seek that lands normally clears any deferred one, so the newer intent wins | Player | UR-040, UR-005 | Done | | DR-242 | The player contract expresses intent, not device operations. `MediaPlayer::open` carries the start position, so no caller sequences load-then-seek and none can race an engine's asynchronous load; `seek` states a destination and leaves in-place-vs-re-open to the engine, which is the only layer that knows its own transport; `snapshot` is one coherent read; and `Phase::Opening` names the window a seek used to be lost in. Replaces `PlayerBackend`, which abstracted a device and required each of the three engines to re-derive the same rules | Player | UR-081 | In Progress | | DR-243 | Every engine passes one conformance suite, and a `FakePlayer` implements the contract deterministically. The suite is written before the second engine so it cannot encode whatever the first happened to do, and it drives readiness through a harness rather than sleeping. `FakePlayer` models the one behaviour that matters — opening is not instantaneous — so the load/seek race can be expressed on purpose, and lets the controller, queue, autoplay and session logic be tested with no engine at all | Player | UR-081 | In Progress | +| DR-244 | `MpvPlayer` implements `MediaPlayer` over libmpv, applying the start position at load time via mpv's own `start` option rather than seeking after an asynchronous `loadfile`, and holding a seek that arrives during `Opening` until the file loads. A standalone `player-conformance` binary runs the suite against it with audio and video routed to null, so a wrapper is verifiable without building or launching the app | Player | UR-081, UR-040 | Done | +| DR-245 | `LegacyPlayer` drives the old `PlayerBackend` through the `MediaPlayer` contract, so engines not yet ported keep working during the migration and the two designs can be compared on one engine and one file. It reproduces the old load-then-play-then-seek sequence faithfully rather than a fixed-up version, because making it pass would defeat its purpose | Player | UR-081 | In Progress | | DR-198 | The webview runs under a real Content-Security-Policy, and the asset protocol is scoped to the one directory it still serves. `csp` was `null`, which disables CSP entirely: any script that reached the web layer — through a future `{@html}`, a dependency, or a devtools paste — would have inherited the whole IPC surface, and with it the user's session. `script-src 'self'` (Tauri injects a nonce for SvelteKit's inline bootstrap script at build time, so no `'unsafe-inline'` is needed) plus `object-src`/`frame-src 'none'` and `base-uri 'self'` is the part that is genuinely restrictive. `img-src`/`media-src`/`connect-src` cannot be: the Jellyfin origin is typed in by the user at run time and is commonly plain `http` on a LAN, so they allow `http:`/`https:` — a wide grant for *data*, but one that still bars `file:`, `filesystem:` and scripting schemes, and leaves `script-src` untouched. `style-src` keeps `'unsafe-inline'` because Svelte compiles `style="…"` attributes (including `app.html`'s `display: contents` wrapper) into markup; this is safe only while no `