if (asset.mediaType == PHAssetMediaTypeVideo) {
[[PHImageManagerdefaultManager]requestAVAssetForVideo:assetoptions:nilresultHandler:^(AVAsset*_Nullableasset,AVAudioMix*_NullableaudioMix,NSDictionary*_Nullableinfo) {
NSString* sandboxExtensionTokenKey = info[@"PHImageFileSandboxExtensionTokenKey"];
NSArray* arr = [sandboxExtensionTokenKeycomponentsSeparatedByString:@";"];
NSString* filePath = [arr.lastObjectsubstringFromIndex:9];
NSFileHandle*fh = [NSFileHandlefileHandleForReadingAtPath:filePath];
if(offset >0) {
[fhseekToFileOffset:offset];
}
NSData*data = [fhreadDataOfLength:length];
block(data);
[fhcloseFile];
}];
}
网友评论