gpt4 book ai didi

iphone - 如何获取NSdocument目录下保存的视频

转载 作者:行者123 更新时间:2023-12-03 20:51:48 27 4
gpt4 key购买 nike

目前,我正在开发一个应用程序,其中我已将录制的视频保存到文档目录和我的

代码在这里:

     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];

现在如何检查视频是否保存在文档目录中?

最佳答案

您可以使用此代码获取所有已保存的视频:-

-(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);

}

关于iphone - 如何获取NSdocument目录下保存的视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13305534/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com