AVAsset is an abstract, immutable class providing a composite representation of a media resource, modeling the static attributes of the media as a whole, such as its title, duration, and metadata. AVAsset is not the media itself, but acts as a container for timed media. It is composed of one or more media tracks along with metadata describing its contents.

AVAsset confirms the AVAsynchronousKeyValueLoading protocol. We can querying an asset’s properties asynchronously.

1
2
3
4
// check for status for a key
- (AVKeyValueStatus)statusOfValueForKey:(NSString *)key error:(NSError * _Nullable * _Nullable)outError;
// asynchronously load properties by given keys
- (void)loadValuesAsynchronouslyForKeys:(NSArray<NSString *> *)keys completionHandler:(nullable void (^)(void))handler;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// example 
// Load the asset's "playable" key
[asset loadValuesAsynchronouslyForKeys:@[@"playable"] completionHandler:^{
NSError *error = nil;
AVKeyValueStatus status =
[asset statusOfValueForKey:@"playable" error:&error];
switch (status) {
case AVKeyValueStatusLoaded:
// Successfully loaded, continue processing
break;
case AVKeyValueStatusFailed:
// Examine NSError pointer to determine failure
break;
case AVKeyValueStatusCancelled:
// Loading cancelled
break;
default:
// Handle all other cases
break;
}
}];

Note that:
The completionHandler block will be called only once per invocation of loadValuesAsynchronouslyForKeys:completionHandler:, no matter how many keys you pass to this methods.
We need to call status statusOfValueForKey:error: on each property you requested.

https://developer.apple.com/documentation/avfoundation/avasset