我想從設備庫的mp4文件中獲取NSData。從資產庫URL獲取NSData
這個鏈接看起來就像這樣:
assets-library://asset/asset.mp4?id=32515720-939A-456F-958F-0B2F397416EB&ext=mp4
我試過這段代碼:
ALAssetRepresentation *rep = [asset defaultRepresentation];
Byte *buffer = (Byte*)malloc((NSUInteger)rep.size);
NSUInteger buffered = [rep getBytes:buffer fromOffset:0.0 length:(NSUInteger)rep.size error:nil];
NSData *data = [NSData dataWithBytesNoCopy:buffer length:buffered freeWhenDone:YES];
但defaultRepresentation
在iOS版9
棄用我也試過[NSData dataWithContentsOfFile:url];
但它返回零。
棄用=不存在的! – Lefteris