Protocol 13: Up next preloads, so switching to it is instant
Every app gets the first Up next item ready itself (own Jellyfin plan, direct links, guests via /j when state.relayNext says the server's login can pass it on) and opens it in a hidden, muted, paused second player; the swap promotes that player instead of opening cold, so its buffer counts at once. Reports go out on open and when the buffer reaches the gate's need. SwitchTrace times each phase. Measured in the e2e harness: 1.5-3 s before, 35-103 ms with a preload. Relayed items still open cold for everyone but their source (ROADMAP). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4275abe470
commit
ddd7a21195
19 files changed
+1041
-142
No files matched your search
@@ -11,6 +11,7 @@ const _serverId = 'fakeserver01';
|
||||
const _item = '0123456789abcdef0123456789abcdef';
|
||||
const _source = 'fedcba9876543210fedcba9876543210';
|
||||
const _slowItem = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa';
|
||||
const _nextItem = 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb';
|
||||
const _token = 'JF-SECRET-TOKEN';
|
||||
|
||||
const _cred = JellyfinCredential(
|
||||
@@ -368,6 +369,28 @@ void main() {
|
||||
expect(jf.uris, isEmpty, reason: 'nothing reached Jellyfin');
|
||||
});
|
||||
|
||||
test('Up next first item on the login: relayNext, and /j serves it too', () async {
|
||||
await setUpRef(_item);
|
||||
final a = clients.first;
|
||||
expect(a.lastState!.containsKey('relayNext'), isFalse);
|
||||
expect((await relayGet(token, _nextItem)).statusCode, 403);
|
||||
a.send(const QueueIntent.add(QueueItem(
|
||||
media: HelloMedia(
|
||||
name: 'Next',
|
||||
size: 0,
|
||||
duration: 0,
|
||||
jellyfin: JellyfinRef(serverId: _serverId, itemId: _nextItem, mediaSourceId: _source)),
|
||||
how: QueueHow.jellyfin,
|
||||
title: 'Next'))
|
||||
.toJson());
|
||||
await _until(() => a.lastState?['relayNext'] == true, 'relayNext');
|
||||
final res = await relayGet(token, _nextItem, range: 'bytes=0-99');
|
||||
expect(res.statusCode, 206);
|
||||
expect(await readAll(res), bytes.sublist(0, 100));
|
||||
expect((await relayGet(token, _item, range: 'bytes=0-9')).statusCode, 206, reason: 'the current one still');
|
||||
expect((await relayGet(token, _slowItem)).statusCode, 403, reason: 'nothing else');
|
||||
});
|
||||
|
||||
test('non-Jellyfin media: 404', () async {
|
||||
await startServer(cred());
|
||||
final (a, w) = await join('alice');
|
||||
|
||||
Reference in new issue
Block a user