Background-audio handoff for video + repository/player refactor

Hand video playback off to a native audio-only stream when the app is
backgrounded or locked, with no on-device video decode (UR-040). Adds
player_enter/exit_background_audio commands, an audio-only stream URL
for video items across the repository layer, and the frontend handoff
state machine wired into VideoPlayer. Includes accompanying
repository/offline/player refactoring and regenerates the traceability
matrix.
This commit is contained in:
2026-07-22 21:52:07 +02:00
parent 4e6ab017d4
commit 3fbf6afdbc
72 changed files with 6728 additions and 2338 deletions
@@ -0,0 +1,43 @@
import { describe, it, expect, vi, beforeEach } from "vitest";
import { invoke } from "@tauri-apps/api/core";
import { commands } from "$lib/api/bindings";
vi.mock("@tauri-apps/api/core");
// TRACES: UR-040 | DR-052 | UT-061
//
// Guards the Tauri v2 camelCase param rule for the background-audio commands:
// the command NAME stays snake_case; params are camelCase.
describe("background-audio player commands (param naming)", () => {
beforeEach(() => {
vi.clearAllMocks();
});
it("player_enter_background_audio sends item + positionSeconds (camelCase)", async () => {
(invoke as any).mockResolvedValueOnce({});
const item = {
id: "vid-1",
title: "Episode 1",
streamUrl: "https://server/Audio/vid-1/universal?AudioStreamIndex=1",
videoCodec: "aac",
needsTranscoding: false,
};
await commands.playerEnterBackgroundAudio(item, 193);
expect(invoke).toHaveBeenCalledWith("player_enter_background_audio", {
item,
positionSeconds: 193,
});
});
it("player_exit_background_audio takes no params and returns a position", async () => {
(invoke as any).mockResolvedValueOnce(193.5);
const pos = await commands.playerExitBackgroundAudio();
expect(pos).toBe(193.5);
expect(invoke).toHaveBeenCalledWith("player_exit_background_audio");
});
});