Keep fallback active while adding queued media
This commit is contained in:
@@ -5,6 +5,7 @@ const { MediaPlayer } = require("../build/MediaPlayer");
|
||||
const makePlayer = (url = "https://example.test/watch?v=abc", playlist = [{ id: 42, filename: url }]) => {
|
||||
const player = Object.create(MediaPlayer.prototype);
|
||||
const starts = [];
|
||||
const commands = [];
|
||||
let stops = 0;
|
||||
const state = {
|
||||
eventSubscribers: [],
|
||||
@@ -38,13 +39,14 @@ const makePlayer = (url = "https://example.test/watch?v=abc", playlist = [{ id:
|
||||
player.browserFallback.isRunning = false;
|
||||
},
|
||||
};
|
||||
player.writeCommand = async (command) => {
|
||||
player.writeCommand = async (command, args) => {
|
||||
commands.push([command, args]);
|
||||
if (command === "loadfile") return { error: "success" };
|
||||
if (command === "get_property") return { data: playlist };
|
||||
return { error: "success" };
|
||||
};
|
||||
player.fetchMetadataAndNotify = async () => undefined;
|
||||
return { player, starts, get stops() { return stops; }, set playlist(value) { playlist = value; } };
|
||||
return { player, starts, commands, get stops() { return stops; }, set playlist(value) { playlist = value; } };
|
||||
};
|
||||
|
||||
const begin = (player, entryId = 42) => player.receiveData(`${JSON.stringify({ event: "start-file", playlist_entry_id: entryId })}\n`);
|
||||
@@ -84,12 +86,13 @@ test("actual MPV error opens the exact original URL and mirrors indeterminate st
|
||||
test("queue append leaves active A eligible when queued B is added", async () => {
|
||||
const a = "https://example.test/a";
|
||||
const b = "https://example.test/b";
|
||||
const { player, starts } = makePlayer(a, [{ id: 42, filename: a }]);
|
||||
const { player, starts, commands } = makePlayer(a, [{ id: 42, filename: a }]);
|
||||
player.fallbackCandidates.add(a);
|
||||
player.entryCandidates.set(42, a);
|
||||
begin(player, 42);
|
||||
await player.append(b);
|
||||
await settle();
|
||||
assert.equal(commands.filter(([name]) => name === "loadfile").at(-1)[1][1], "append-play");
|
||||
send(player, { reason: "error", file_error: "failed A" }, 42);
|
||||
await settle();
|
||||
assert.deepEqual(starts, [a]);
|
||||
@@ -97,6 +100,22 @@ test("queue append leaves active A eligible when queued B is added", async () =>
|
||||
assert.equal(player.fallbackCandidates.has(b), true);
|
||||
});
|
||||
|
||||
test("queue append during fallback startup keeps browser A open without starting B", async () => {
|
||||
const a = "https://example.test/a";
|
||||
const b = "https://example.test/b";
|
||||
const { player, starts, commands } = makePlayer(a, [{ id: 42, filename: a }]);
|
||||
player.fallbackCandidates.add(a);
|
||||
player.entryCandidates.set(42, a);
|
||||
begin(player, 42);
|
||||
send(player, { reason: "error", file_error: "failed A" }, 42);
|
||||
await player.append(b);
|
||||
await settle();
|
||||
const load = commands.filter(([name]) => name === "loadfile").at(-1);
|
||||
assert.equal(load[1][1], "append");
|
||||
assert.deepEqual(starts, [a]);
|
||||
assert.equal(player.browserUrl, a);
|
||||
});
|
||||
|
||||
test("append then skipTo keeps the selected entry eligible for its actual MPV error", async () => {
|
||||
const url = "https://example.test/shared-original?x=1&y=2";
|
||||
const { player, starts } = makePlayer(url, [{ id: 42, filename: url }]);
|
||||
|
||||
Reference in New Issue
Block a user