feat: add Chromecast playback support

This commit is contained in:
2026-10-13 17:31:37 +02:00
parent 74b4bfe6c1
commit bb777b0ecd
22 changed files with 3299 additions and 115 deletions
+8 -4
View File
@@ -24,6 +24,13 @@ struct WebVTTDocument: Sendable {
}
static func load(url: String, headers: String) async throws -> WebVTTDocument {
let data = try await loadData(url: url, headers: headers)
// Providers sometimes disguise VTT resources as images: trust the explicit format and content.
guard let text = String(data: data, encoding: .utf8) else { throw SubtitleError.content }
return try parse(text)
}
static func loadData(url: String, headers: String) async throws -> Data {
let request = try request(url: url, headers: headers)
let configuration = URLSessionConfiguration.ephemeral
configuration.timeoutIntervalForRequest = 15
@@ -51,10 +58,7 @@ struct WebVTTDocument: Sendable {
if Task.isCancelled { throw CancellationError() }
throw SubtitleError.transport
}
// Providers sometimes disguise VTT resources as images: trust the explicit format and content,
// never the path extension or Content-Type.
guard let text = String(data: data, encoding: .utf8) else { throw SubtitleError.content }
return try parse(text)
return data
}
static func parse(_ text: String) throws -> WebVTTDocument {