No, you cannot allow this. One of my methods looks at two keys, playability and duration, and I found that playable is often available, but duration has not yet been reached. I therefore moved loadValuesAsynchronouslyForKeys: code into a separate shouldSave: method. The shouldSave method: I call from the timer in the saveWithDuration: method. As soon as saveWithDuration: gets a nonzero duration, it goes ahead and saves the material. To avoid waiting too long, I use the counter of attempts at the moment - in the future, I will clarify this (you will notice that the error instance is not currently used)
- (void)shouldSave:(NSTimer*)theTimer { NSString * const TBDuration = @"duration"; NSString * const TBPlayable = @"playable"; __block float theDuration = TBZeroDuration; __block NSError *error = nil; NSArray *assetKeys = [NSArray arrayWithObjects:TBDuration, TBPlayable, nil]; [_audioAsset loadValuesAsynchronouslyForKeys:assetKeys completionHandler:^() { AVKeyValueStatus playableStatus = [_audioAsset statusOfValueForKey:TBPlayable error:&error]; switch (playableStatus) { case AVKeyValueStatusLoaded:
}
source share