[英]How to get NSdocument directory saved video
Currently, I am developing an app in which I have saved recorded video to document directory and my目前,我正在开发一个应用程序,其中我已将录制的视频保存到文档目录和我的
code is here:代码在这里:
NSURL * movieURL = [info valueForKey:UIImagePickerControllerMediaURL] ;
NSData * movieData = [NSData dataWithContentsOfURL:movieURL];
NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [documentPaths objectAtIndex:0];
NSString *fullPath = [documentsDirectory stringByAppendingPathComponent:[[self video]text]];
fullPath = [fullPath stringByAppendingFormat:@".MOV"];
[movieData writeToFile:fullPath atomically:YES];
Now how can I check that videos are save in document directory or not?现在如何检查视频是否保存在文档目录中?
you can get all saved video using this code:-您可以使用此代码获取所有保存的视频:-
-(IBAction)getallVideo
{
NSArray *path = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *library = [path objectAtIndex:0];
NSArray *fileArray = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:library error:nil];
videolist = [[NSMutableArray alloc]init];
for(int i = 0;i<fileArray.count;i++){
NSLog(@"table%d",fileArray.count);
id myArrayElement = [fileArray objectAtIndex:i];
if([myArrayElement rangeOfString:@".mp4" ].location !=NSNotFound)
{
[videolist addObject:myArrayElement];
}
else if([myArrayElement rangeOfString:@".mov"].location !=NSNotFound)
{
[videolist addObject:myArrayElement];
}
NSLog(@"Mu %@",videolist);
}
BOOL _isSaved = [movieData writeToFile:fullPath atomically:YES];
if(_isSaved == YES)}
NSLog(@"Saved Succesfully")
}
else{
NSLog(@"Error occured");
}
or或者
NSError* error;
[movieData writeToFile:storePath options:NSDataWritingAtomic error:&error];
if(error == nil){
NSLog(@"Saved Succesfully")
}
else{
NSLog(@"write error %@", error);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.