Improve resolution switching

This commit is contained in:
Arkadiusz Fal
2021-06-15 18:35:21 +02:00
parent 4535853ac3
commit da22b06cc1
9 changed files with 253 additions and 82 deletions

View File

@@ -23,6 +23,20 @@ class Stream: Equatable {
"\(resolution.height)p"
}
var assets: [AVURLAsset] {
[audioAsset, videoAsset]
}
var assetsLoaded: Bool {
assets.allSatisfy { $0.statusOfValue(forKey: "playable", error: nil) == .loaded }
}
func cancelLoadingAssets() {
assets.forEach { $0.cancelLoading() }
audioAsset = AVURLAsset(url: audioAsset.url)
videoAsset = AVURLAsset(url: videoAsset.url)
}
static func == (lhs: Stream, rhs: Stream) -> Bool {
lhs.resolution == rhs.resolution && lhs.type == rhs.type
}