fix(player): make transport reach the player that is actually rendering
Play/pause did nothing on the Android native video path — from the on-screen tap, from the control bar, and from a direct player_toggle invocation — while seek and skip kept working. That asymmetry was the whole clue: seek decides in player_seek_video, transport decides in toggle_playback. DR-195 is the cause. `html5_playing` is Rust's record of "a webview <video> is active and in this state", and toggle_playback/play/pause all route transport to that element whenever it is set. The player route mirrored element state into it UNCONDITIONALLY — from handleReportStart and, fatally, from handleReportProgress, which VideoPlayer calls on a 10-second interval. So on the native path the frontend re-declared every ten seconds that an element was playing when none existed, and every transport intent was emitted into the void. It also explains the flashing: the control bar and the JRay overlay both key off isPlaying, which was being contradicted on every tick. The mirror now lives in mirrorElementStateToRust() in VideoPlayer, gated on useHtml5Element — the only place that knows whether an element renders at all. The route cannot tell the paths apart, which is exactly how it came to lie. DR-193 hands transport authority back to the native backend when an item loads into it. Necessary but insufficient alone: the progress interval put the flag straight back, which is why the first device test after it still failed. DR-192 presents native video through a TextureView instead of a SurfaceView. A SurfaceView renders on its own layer outside the app window and punches a transparent region through it, and everything drawn above that hole — here, the entire Svelte UI — depends on that composition path. The overlay dropped its incremental damage: the DOM advanced (slider 476 -> 479 across three seconds) behind a screen showing neither, so the progress bar froze, controls would not fade and rotation lost the transport UI, while structural DOM changes got through, which is why the play overlay always appeared to work. It supersedes DR-191, which forced redraws in a loop and treated the symptom. DR-194 hides the video view across a resize and reveals it two frames later. A TextureView retains its last frame, so between a rotation and the re-fit landing that frame is stretched across the old rect and the previous frame flashes in what should be the letterbox bars. Verified on device (Honor ROD2-W09, Android 16) by driving ADB and reading the live DOM over the devtools socket: surface tap pauses (position frozen across 12 seconds, overlay raised, transport flipped) and resumes; the control bar does both. UT-189 drives the real 10-second interval under fake timers — an earlier version asserted on a freshly mounted player, passed with the guard deleted, and guarded nothing. Still open, and deliberately not claimed: DR-192's effect on the overlay repaint is unverified on device, DR-194's letterbox reset is untested, and the native default (DR-188) stays off pending DR-190, the background-audio return.
This commit is contained in:
@@ -561,11 +561,11 @@
|
||||
if (id) {
|
||||
reportPlaybackStart(id, positionSeconds, context.type, context.id);
|
||||
}
|
||||
// Mirror HTML5 <video> state into the Rust PlayerController so it is the
|
||||
// single source of truth for video playback (see html5Adapter.ts). The
|
||||
// element lives in the webview and Rust cannot observe it directly.
|
||||
html5Adapter.reportState("playing", id ?? null);
|
||||
html5Adapter.reportPosition(positionSeconds, get(playbackDuration), { force: true });
|
||||
// The element's state is mirrored into Rust by VideoPlayer, which is the
|
||||
// only place that knows whether a webview element is rendering at all.
|
||||
// Doing it here mirrored unconditionally, so on the native path it told Rust
|
||||
// a `<video>` was playing when none existed and transport was then aimed at
|
||||
// it — see mirrorElementStateToRust in VideoPlayer.svelte (DR-195).
|
||||
}
|
||||
|
||||
function handleReportProgress(positionSeconds: number, isPaused: boolean, reportId?: string) {
|
||||
@@ -573,9 +573,7 @@
|
||||
if (id) {
|
||||
reportPlaybackProgress(id, positionSeconds, isPaused);
|
||||
}
|
||||
// Feed the Rust controller the current position and play/pause state.
|
||||
html5Adapter.reportState(isPaused ? "paused" : "playing", id ?? null);
|
||||
html5Adapter.reportPosition(positionSeconds, get(playbackDuration), { force: true });
|
||||
// Element state is mirrored by VideoPlayer (DR-195) — see handleReportStart.
|
||||
}
|
||||
|
||||
function handleReportStop(positionSeconds: number, reportId?: string) {
|
||||
|
||||
Reference in New Issue
Block a user