Up Next: a queue that plays on by itself (#473)

Playing was one episode at a time: when one ended nothing followed. Up Next
is a per-account queue on the server (table `queue`, GET and PUT
/api/queue), so the phone and the browser share it. The page adds to it from
a row or the reader, reorders it by drag or arrow keys, and plays the next
when one ends; what is playing leaves it as it starts, as Overcast's does. An
episode 90% played leaves it on the server too, which covers the phone
playing on while the page is frozen.

The iOS app is told what follows (`{t:'next'}`, gated on the app saying it
can) and starts it at the end of an episode; the page takes it up through
nowPlaying as it does the car's pick. The Swift is not compiled here.

The page stub answered every unknown address with [], whose `.entries` is
Array.prototype.entries, so the queue read a function as its list; it now
answers /api/queue as an entry list.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-17 14:31:40 +00:00
parent 2ebe77b21e
commit c65b80a06c
24 changed files with 445 additions and 41 deletions

View File

@@ -230,6 +230,21 @@ ctx.window.ipxNative.on({ t: 'nowPlaying', feedId: 'f', guid: 'g2', enc: 7, titl
playing: false, cur: 130 });
ok(audio.paused === true && audio.currentTime === 130, 'told again on coming forward, the bar did not follow');
// Up Next (#473): the app is told what follows, to play it with the screen locked, and taking it
// up from nowPlaying takes it out of Up Next.
const queued = { feed_id: 'f', guid: 'n1', title: 'Next One', position: 0, duration: 60, image: null,
enclosures: [{ id: 9, mime: 'audio/mpeg', path: '/n.mp3', url: 'http://x/n.mp3' }] };
since();
vm.runInContext(`upNext=[${JSON.stringify(queued)}]; hostNext()`, ctx);
ok(!last('next'), 'an app that never said it can was told what follows');
ctx.window.ipxNative.on({ t: 'host', can: ['next'] });
ok(last('next')?.guid === 'n1' && last('next')?.enc === 9 && last('next')?.url === '/media/9', 'the app was not told what plays next');
ctx.window.ipxNative.on({ t: 'nowPlaying', feedId: 'f', guid: 'n1', enc: 9, title: 'Next One', feedTitle: 'A Feed',
playing: true, cur: 0, dur: 60 });
ok(vm.runInContext('player.guid', ctx) === 'n1', 'the bar did not take up the next one');
ok(vm.runInContext('upNext.length', ctx) === 0, 'the one under way is still in Up Next');
ok(!!last('next') && !last('next')?.guid, 'the app was not told nothing follows');
if (failed) { console.error(`\n${failed} failed`); process.exit(1); }
console.log('OK: native-bridge: the host takes playback, keeping, the sleep timer and haptics, and the page follows it');
console.log('OK: native-bridge: the host takes playback, keeping, the sleep timer, haptics and Up Next, and the page follows it');
process.exit(0);