As was stated, the keys
are properties on AVAsset. Apple says in its docs that you should always use this in iOS (but I doubt its needed for file based videos).
I struggled with this, in the end it didn't matter - but in any case maybe this will help someone in the future:
asset = AVAsset(url: videoURL)
let keys = ["duration", "playable", "preferredRate", "preferredVolume", "hasProtectedContent", "providesPreciseDurationAndTiming", "metadata"]
asset.loadValuesAsynchronously(forKeys: keys) {
for key in keys {
var error: NSError? = nil
let status = self.asset.statusOfValue(forKey: key, error: &error)
print("KEY:", key, terminator: "")
switch status {
case .loading:
print(" Loading")
case .loaded:
print(" Sucessfully loaded, continue processing")
case .failed:
print(" Failed with error \(error!)")
case .cancelled:
print(" CANCELLED")
case .unknown:
print(" Unknown")
default:
print(" DEFAULT")
}
}
print("WAIT A BIT...")
DispatchQueue.main.async {
print("...RUN IT")
self.runMovie()
}
}