mirror of
https://github.com/dirtydishes/dreamio.git
synced 2026-06-06 13:37:24 +00:00
add native player controls and captions
This commit is contained in:
parent
75e76e14d4
commit
419ffae415
9 changed files with 1096 additions and 4 deletions
|
|
@ -7,6 +7,9 @@ struct StreamResolverTests {
|
|||
testResolverSelectsUnsupportedDirectURLAndHeaders()
|
||||
testResolverRejectsHLSOnlyResponse()
|
||||
testRedactorHandlesPercentEncodedPath()
|
||||
testPlaybackTimeFormatting()
|
||||
testSubtitleCandidateParsing()
|
||||
testSubtitleOptionMappingIncludesOff()
|
||||
print("StreamResolverTests passed")
|
||||
}
|
||||
|
||||
|
|
@ -75,6 +78,48 @@ struct StreamResolverTests {
|
|||
assertEqual(redacted, "https://cdn.example.test/video/%5Bredacted%5D/%E2%9C%93.mp4")
|
||||
}
|
||||
|
||||
private static func testPlaybackTimeFormatting() {
|
||||
assertEqual(PlaybackTimeFormatter.label(for: 0), "0:00")
|
||||
assertEqual(PlaybackTimeFormatter.label(for: 65), "1:05")
|
||||
assertEqual(PlaybackTimeFormatter.label(for: 3_725), "1:02:05")
|
||||
}
|
||||
|
||||
private static func testSubtitleCandidateParsing() {
|
||||
let payload: [String: Any] = [
|
||||
"subtitles": [
|
||||
[
|
||||
"lang": "eng",
|
||||
"url": "https://opensubtitles.example.test/download/subtitle.srt?token=secret"
|
||||
],
|
||||
[
|
||||
"language": "Spanish",
|
||||
"file": "https://cdn.example.test/movie.es.vtt"
|
||||
],
|
||||
"https://cdn.example.test/ignored.txt"
|
||||
],
|
||||
"nested": [
|
||||
"body": "metadata https://cdn.example.test/movie.fr.ass?download=1"
|
||||
]
|
||||
]
|
||||
|
||||
let candidates = SubtitleCandidateParser.candidates(in: payload)
|
||||
|
||||
assertEqual(candidates.count, 3)
|
||||
assertEqual(candidates[0].language, "eng")
|
||||
assertEqual(candidates[1].label, "Spanish")
|
||||
assertEqual(candidates[2].url.absoluteString, "https://cdn.example.test/movie.fr.ass?download=1")
|
||||
}
|
||||
|
||||
private static func testSubtitleOptionMappingIncludesOff() {
|
||||
let options = SubtitleOptionMapper.options(from: [
|
||||
SubtitleTrack(id: 2, name: "English"),
|
||||
SubtitleTrack(id: 5, name: "Spanish")
|
||||
])
|
||||
|
||||
assertEqual(options.map(\.name), ["Off", "English", "Spanish"])
|
||||
assertEqual(options.first?.id, -1)
|
||||
}
|
||||
|
||||
private static func assertEqual<T: Equatable>(_ actual: T?, _ expected: T, file: StaticString = #file, line: UInt = #line) {
|
||||
assert(actual == expected, "Expected \(String(describing: expected)), got \(String(describing: actual))", file: file, line: line)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue