How to record a video clip in ipad app and store it in documents folder

后端 未结 3 1391
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-15 19:42

I have training app i want that when user click recordVideo button camera should launch to record video, is there any way to do this in ipad app.I have done audio recording

3条回答
  •  我在风中等你
    2021-01-15 19:51

    Just try it :

    -(void) imagePickerController: (UIImagePickerController *) picker didFinishPickingMediaWithInfo: (NSDictionary *) info 
    {
        NSString *mediaType = [info objectForKey: UIImagePickerControllerMediaType];
        [self dismissModalViewControllerAnimated:NO];
        NSString *moviePath = [[info objectForKey: UIImagePickerControllerMediaURL] path];
        if (UIVideoAtPathIsCompatibleWithSavedPhotosAlbum (moviePath)){
            UISaveVideoAtPathToSavedPhotosAlbum (moviePath,self, @selector(video:didFinishSavingWithError:contextInfo:), nil);
                    }
    } 
    
    -(void)video:(NSString*)videoPath didFinishSavingWithError:(NSError*)error contextInfo:(void*)contextInfo {
     if (error) {
            [AJNotificationView showNoticeInView:self.view type:AJNotificationTypeRed title:@"Video Saving Failed" linedBackground:AJLinedBackgroundTypeAnimated hideAfter:1.0];
        }
        else{        
            NSURL *videoURl = [NSURL fileURLWithPath:videoPath];
            AVURLAsset *asset = [[AVURLAsset alloc] initWithURL:videoURl options:nil];
            AVAssetImageGenerator *generate = [[AVAssetImageGenerator alloc]  initWithAsset:asset];
            generate.appliesPreferredTrackTransform = YES;
            NSError *err = NULL;
            CMTime time = CMTimeMake(1, 60);
            CGImageRef imgRef = [generate copyCGImageAtTime:time actualTime:NULL error:&err];
    
    
    
    
    
      self.strUploadVideoURL = videoPath;
            [imgPhoto setImage:[[[UIImage alloc] initWithCGImage:imgRef] autorelease]];
            intWhenPushView = 2;
            btnShare.enabled = YES;
            btnFacebookShare.enabled = YES;
    
    
    
    CGImageRelease(imgRef);
        [generate release];
        [asset release];
        }
    }
    

提交回复
热议问题