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:
@@ -6,6 +6,7 @@ The iOS app, `ios/`. Format: [Keep a Changelog](https://keepachangelog.com/en/1.
|
||||
|
||||
### Added
|
||||
|
||||
- Up Next plays on with the screen locked: the app is told what follows and starts it when an episode ends, without waiting for the page (#473).
|
||||
- iPX on the iPhone: the page in an app, playing through the phone's own player, so an episode plays on with the screen locked and the lock screen, Control Center and a car's buttons drive it (#418).
|
||||
- Player token (Settings, This device): an ipx API token, kept in the keychain, which the player, the badge and CarPlay send to `https://ipxapi.sdf1.net` instead of using the page's sign-in cookie, so playback does not stop when that cookie expires (#419).
|
||||
- The icon shows All Subscriptions' unread count, as the page's badge does: set when the app comes forward, after an item is marked read, and by a refresh iOS runs now and then while the app is closed, so it can be hours behind (#421). Reading in the app and new items arriving while it is open set it at once, and while an episode plays it is checked every quarter of an hour.
|
||||
|
||||
@@ -122,7 +122,7 @@ final class Bridge: NSObject, WKScriptMessageHandler {
|
||||
if let r = m["rate"] as? Double { playback.setRate(Float(r)) }
|
||||
if let v = m["volume"] as? Double { playback.setVolume(Float(v)) }
|
||||
// What this build can do, so a newer page offers nothing it would ask for in vain.
|
||||
send(["t": "host", "can": ["sleep", "route", "settings"]])
|
||||
send(["t": "host", "can": ["sleep", "route", "settings", "next"]])
|
||||
sendAppSettings()
|
||||
// A page reloaded while the timer runs is told how long is left.
|
||||
if let at = playback.sleepAt { send(["t": "sleep", "left": max(0, at.timeIntervalSinceNow)]) }
|
||||
@@ -139,6 +139,21 @@ final class Bridge: NSObject, WKScriptMessageHandler {
|
||||
feedTitle: m["feedTitle"] as? String ?? "",
|
||||
artwork: m["artwork"] as? String,
|
||||
duration: m["duration"] as? Int))
|
||||
case "next":
|
||||
// Without an episode it says nothing follows.
|
||||
guard let path = m["url"] as? String, let url = Server.resolveForPlayer(path),
|
||||
let enc = m["enc"] as? Int,
|
||||
let feedId = m["feedId"] as? String, let guid = m["guid"] as? String else {
|
||||
playback.next = nil
|
||||
return
|
||||
}
|
||||
let at = m["position"] as? Double ?? 0
|
||||
playback.next = (.init(
|
||||
url: url, enc: enc, feedId: feedId, guid: guid,
|
||||
title: m["title"] as? String ?? "",
|
||||
feedTitle: m["feedTitle"] as? String ?? "",
|
||||
artwork: m["artwork"] as? String,
|
||||
duration: m["duration"] as? Int), at > 5 ? at : nil)
|
||||
case "play": playback.play()
|
||||
case "pause": playback.pause()
|
||||
case "stop": playback.stop()
|
||||
|
||||
@@ -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