Save a Video that I record in my app

后端 未结 1 1434
刺人心
刺人心 2021-02-08 23:24

I am succeeding in understanding how to make a camera app in my learning journey:-)

The only thing I am stuck with is saving a video that I have recorded. I am able to s

1条回答
  •  無奈伤痛
    2021-02-08 23:47

    Try this:

    UISaveVideoAtPathToSavedPhotosAlbum(moviepath,nil,nil,nil);
    

    Edit: Try this and modify your code to this method:

    // For responding to the user tapping Cancel.
    - (void) imagePickerControllerDidCancel: (UIImagePickerController *) picker {
    
        [[picker parentViewController] dismissModalViewControllerAnimated: YES];
        [picker release];
    }
    
    // For responding to the user accepting a newly-captured picture or movie
    - (void) imagePickerController: (UIImagePickerController *) picker
                didFinishPickingMediaWithInfo: (NSDictionary *) info {
    
        NSString *mediaType = [info objectForKey: UIImagePickerControllerMediaType];
        UIImage *originalImage, *editedImage, *imageToSave;
    
        // Handle a still image capture
        if (CFStringCompare ((CFStringRef) mediaType, kUTTypeImage, 0)
                == kCFCompareEqualTo) {
    
            editedImage = (UIImage *) [info objectForKey:
                        UIImagePickerControllerEditedImage];
            originalImage = (UIImage *) [info objectForKey:
                        UIImagePickerControllerOriginalImage];
    
            if (editedImage) {
                imageToSave = editedImage;
            } else {
                imageToSave = originalImage;
            }
    
        // Save the new image (original or edited) to the Camera Roll
            UIImageWriteToSavedPhotosAlbum (imageToSave, nil, nil , nil);
        }
    
        // Handle a movie capture
        if (CFStringCompare ((CFStringRef) mediaType, kUTTypeMovie, 0)
                == kCFCompareEqualTo) {
    
            NSString *moviePath = [[info objectForKey:
                        UIImagePickerControllerMediaURL] path];
    
            if (UIVideoAtPathIsCompatibleWithSavedPhotosAlbum (moviePath)) {
                UISaveVideoAtPathToSavedPhotosAlbum (
                        moviePath, nil, nil, nil);
            }
        }
    
        [[picker parentViewController] dismissModalViewControllerAnimated: YES];
        [picker release];
    }
    

    0 讨论(0)
提交回复
热议问题