我正在尝试使用此代码在iPad上播放视频。对iOS 6来说没问题。但是,在iOS 7中,它的self.asset.duration.value为零。我想知道怎么做。
NSURL *url = [[NSURL alloc] initFileURLWithPath:path];
NSDictionary *options = [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:YES] forKey:AVURLAssetPreferPreciseDurationAndTimingKey];
AVURLAsset *assetToCombine = [AVURLAsset URLAssetWithURL:url options:options];//original
[assetToCombine retain];
NSArray *requestedKey=[NSArray arrayWithObjects:@"duration", nil];
[assetToCombine loadValuesAsynchronouslyForKeys:requestedKey completionHandler:^{
dispatch_async(dispatch_get_main_queue(), ^{
//do nth here
NSLog(@"dispatch_async assetToCombine.duration.value is %lld.",assetToCombine.duration.value);
});
}];
NSLog(@"assetToCombine.duration.value is %lld.",assetToCombine.duration.value);