feat: enqueue streams in running player

This commit is contained in:
2026-10-22 16:03:56 +02:00
parent ac8e284d80
commit 6a4afc9f0e
17 changed files with 416 additions and 61 deletions
+20
View File
@@ -18,6 +18,26 @@ struct StreamQueue: Sendable {
private struct InvalidQueue: LocalizedError {
var errorDescription: String? { "Invalid stream queue: expected version 1, 1–4096 unique supported videos and new absolute report files in private owned directories." }
}
// Explicit-app URL delivery reaches both cold launches and already running players.
static func enqueueURL(for file: URL) -> URL {
var components = URLComponents()
components.scheme = "terebi-enqueue"
components.host = "queue"
components.queryItems = [URLQueryItem(name: "file", value: file.path)]
return components.url!
}
static func enqueueFile(from url: URL) throws -> URL {
guard let components = URLComponents(url: url, resolvingAgainstBaseURL: false),
components.scheme == "terebi-enqueue", components.host == "queue",
components.path.isEmpty, components.user == nil, components.password == nil,
components.port == nil, components.fragment == nil,
let query = components.queryItems, query.count == 1, query[0].name == "file",
let path = query[0].value, path.hasPrefix("/"), !path.contains("\0") else {
throw InvalidQueue()
}
return URL(fileURLWithPath: path).standardizedFileURL
}
static func load(from file: URL) throws -> StreamQueue {
do {