用Photos框架代替。
其中:保存视频的代码:
ALAssetsLibrary *assetsLibrary=[[ALAssetsLibrary alloc]init];
[assetsLibrary writeVideoAtPathToSavedPhotosAlbum:mediaUrl completionBlock:^(NSURL *assetURL, NSError *error) {
if (!error) {
NSLog(@"视频保存成功");
}
else
{
NSLog(@"视频保存失败");
}
}];
ios9中得代码:(不确定正确性)
[[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{
// Request creating an asset from the image.
PHAssetChangeRequest *createAssetRequest = [PHAssetChangeRequest creationRequestForAssetFromVideoAtFileURL:mediaUrl];
PHFetchResult *result=[PHAsset fetchAssetsWithALAssetURLs:[NSArray arrayWithObject:mediaUrl] options:nil];
PHAssetCollection *assetColection=[[PHAssetCollection fetchAssetCollectionsContainingAsset:[result lastObject] withType:PHAssetCollectionTypeAlbum options:nil] lastObject];
// Request editing the album.
PHAssetCollectionChangeRequest *albumChangeRequest = [PHAssetCollectionChangeRequest changeRequestForAssetCollection:assetColection];
// Get a placeholder for the new asset and add it to the album editing request.
PHObjectPlaceholder *assetPlaceholder = [createAssetRequest placeholderForCreatedAsset];
[albumChangeRequest addAssets:@[ assetPlaceholder ]];
} completionHandler:^(BOOL success, NSError *error) {
NSLog(@"Finished adding asset. %@", (success ? @"Success" : error));
}];