문제

I have a video file stored in the tmp directory, the url is valid, and the video is valid. The problem is that i get null value in the resultBlock no matter what url i pass in.

ALAssetsLibrary *al = [[ALAssetsLibrary alloc] init];

[al assetForURL:url resultBlock:^(ALAsset *asset) {
   NSLog(@"%@", asset); //asset is null/nil 
} failureBlock:^(NSError *error) {
   NSLog(@"Failed creating asset from url with error: %@", [error description]);
}];
도움이 되었습니까?

해결책

If your video is in the tmp directory then it isn't in the asset store associated with the ALAssetsLibrary and you will need to access the video data using standard file loading APIs (like NSFileManager / NSData dataWithContentsOfURL:....

If you want the video to be managed by the ALAssetsLibrary, you need to call writeVideoAtPathToSavedPhotosAlbum:completionBlock: to import the video. The completionBlock will then provide you with an asset library URL (assetURL) which can be used to retrieve the video later (from ALAssetsLibrary).

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top