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.
44 lines
1.3 KiB
TypeScript
44 lines
1.3 KiB
TypeScript
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");
|
|
});
|
|
});
|