// 保存视频到相册
//path为视频下载到本地之后的本地路径
- (void)saveVideo:(NSString *)path{
NSURL *url = [NSURL URLWithString:path];
BOOL compatible = UIVideoAtPathIsCompatibleWithSavedPhotosAlbum([url path]);
if (compatible) {
//保存相册核心代码
UISaveVideoAtPathToSavedPhotosAlbum([url path], self, @selector(video:didFinishSavingWithError:contextInfo:), nil);
}
}
//保存视频完成之后的回调
- (void)video:(NSString *)videoPath didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo {
if (error == NULL) {
NSLog(@"保存视频成功 %@",videoPath);
}else{
NSLog(@"保存视频失败 %@",videoPath);
}
}
// 保存图片到相册
-(void)takePicProcess:(UIImage*)img{
UIImage *image = img;
UIImageWriteToSavedPhotosAlbum(image, self, @selector(image:didFinishSavingWithError:contextInfo:), nil);
}
#pragma mark -- <保存到相册>
-(void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo {
NSString *msg = nil ;
if(error){
msg = @"保存图片失败" ;
}else{
msg = @"保存图片成功" ;
[self performSelectorOnMainThread:@selector(showTakePicResult) withObject:nil waitUntilDone:NO];
}
NSLog(@"保存图片====>%@",msg);
}
-(void)showTakePicResult{
NSLog(@"保存图片成功");
}