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:
@@ -32,6 +32,9 @@ final class Playback: NSObject {
|
||||
var onSlept: (() -> Void)?
|
||||
/// Something the page did not choose is loaded now: the car's pick (#420).
|
||||
var onChosen: (() -> Void)?
|
||||
/// What plays when this one ends: the first in Up Next (#473), and where in it to start, as
|
||||
/// the page last said. Here, not in the page, which is frozen while the screen is locked.
|
||||
var next: (item: Item, startAt: Double?)?
|
||||
|
||||
private let session: URLSession = {
|
||||
let cfg = URLSessionConfiguration.default
|
||||
@@ -306,6 +309,12 @@ final class Playback: NSObject {
|
||||
s.playing = false
|
||||
}
|
||||
markRead()
|
||||
// Up Next goes on, and the page takes it up from nowPlaying as it does the car's pick.
|
||||
if let n = next {
|
||||
next = nil
|
||||
playChosen(n.item, startAt: n.startAt)
|
||||
return
|
||||
}
|
||||
onState?(false)
|
||||
onEnded?()
|
||||
updateNowPlaying()
|
||||
|
||||
Reference in New Issue
Block a user