How to move video from application documents directory to camera roll?

落爺英雄遲暮 提交于 2019-12-21 03:01:39

问题


hallo,

i have found some iphone-camera-video-saving avfoundation code examples over the net (and also im tryin to write my own code but not finished it yet)

such examples process and do save the video (through AVAssetWriter) from the camera capture input to file located in documments directory (which i assume is the only option?)

but now - i do not even can see files in such directory to check if my video is there; i think i should move such video file to 'camera roll', how to do that??

tnx


回答1:


Transfer to Camera Roll - here's a link that should help.

To see what's in your Documents directory, here's a code snippet:

 -(void) dump {

    NSString *docsDir = [NSHomeDirectory() stringByAppendingPathComponent:  @"Documents"];
    NSFileManager *localFileManager = [NSFileManager defaultManager];
    NSDirectoryEnumerator *dirEnum =
        [localFileManager enumeratorAtPath:docsDir];
    NSError *error=nil;

    NSLog(@" Documents Directory: %@", docsDir);
    NSString *file;
    while (file = [dirEnum nextObject]) {
        NSString *fullPath = [NSString stringWithFormat:@"%@/%@", docsDir,file];
        NSDictionary *attrs = [localFileManager attributesOfItemAtPath:fullPath error:&error];
        if ( error ) {
            NSLog(@" error - %@", error);
        } else {
          //NSLog(@" file : %@", file);
          NSInteger fsiz = [attrs fileSize];
          NSString *ftyp = [attrs fileType];
          NSDate   *fmod = [attrs fileModificationDate];
          NSLog(@"  %9d : %@ : %@ : %@",  fsiz, file, ftyp, fmod );
         }
     }
    NSLog(@" ======  End Documents Directory ========");
   }


来源:https://stackoverflow.com/questions/5732074/how-to-move-video-from-application-documents-directory-to-camera-roll

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!