API to capture Live Photos in iOS9

后端 未结 4 396
没有蜡笔的小新
没有蜡笔的小新 2021-02-02 11:46

I can\'t find any API to capture live photos. Did I miss something?

Apple release DOCs

Live Photos

Live Photos is a n

相关标签:
4条回答
  • 2021-02-02 12:20

    No love in iOS 9, but APIs for taking and editing Live Photos are available in iOS 10.

    Here's a talk from WWDC about it all.

    0 讨论(0)
  • 2021-02-02 12:27

    There is no API for manual capture of Live Photos (that is, nothing analogous to the AVCapture APIs that offer direct control for capturing regular photos or video).

    UIImagePickerController, which normally presents a UI allowing the user to capture a photo or video, can also capture Live Photos in iOS 9.1 or later. To allow Live Photo capture, set the image picker controller's mediaTypes property to include both kUTTypeImage and kUTTypeLivePhoto.

    0 讨论(0)
  • 2021-02-02 12:33

    UIImagePickerController looks like it will allow the capture of live photos.

    Working with Live Photos

    Live Photos is a Camera app feature on supported devices, enabling a picture to be not just a single moment in time but to include motion and sound from the moments just before and after its capture. A PHLivePhoto object represents a Live Photo, and the PHLivePhotoView class provides a system-standard, interactive user interface for displaying a Live Photo and playing back its content. Live Photos are still photos. When you use an image picker controller to capture or choose still images (by including only the kUTTypeImage type in the mediaTypes array), assets that were captured as Live Photos still appear in the picker. However, when the user chooses an asset, your delegate object receives only a UIImage object containing a still-image representation of the Live Photo. To obtain the full motion and sound content when the user captures or chooses a Live Photo with the image picker, you must include both the kUTTypeImage and kUTTypeLivePhoto types in the the mediaTypes array. For more information, see UIImagePickerControllerLivePhoto in UIImagePickerControllerDelegate Protocol Reference.

    https://developer.apple.com/library/prerelease/ios/documentation/UIKit/Reference/UIImagePickerController_Class/index.html#//apple_ref/occ/cl/UIImagePickerController

    0 讨论(0)
  • 2021-02-02 12:43

    As per Apple Doc:

    UIImagePickerControllerLivePhoto

    The Live Photo representation of the selected or captured photo.

    A Live Photo is a picture, that includes motion and sound from the moments just before and after its capture. On compatible devices, the Camera app captures all photos as Live Photos by default, but the imagePickerController:didFinishPickingImage:editingInfo: method’s image parameter contains only the still image representation.

    To obtain the motion and sound content of a live photo for display (using the PHLivePhotoView class), include the kUTTypeImage and kUTTypeLivePhoto identifiers in the allowed media types when configuring an image picker controller. When the user picks or captures a Live Photo, the editingInfo dictionary contains the UIImagePickerControllerLivePhoto key, with a PHLivePhoto representation of the photo as the corresponding value.

    Available in iOS 9.1 and later.

    // create an image picker controller instance
        UIImagePickerController *picker = [[UIImagePickerController alloc]init];
        picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
        picker.allowsEditing = NO;
        picker.delegate = self;
    
        // make sure we include Live Photos (otherwise we'll only get UIImages)
        NSArray *mediaTypes = @[(NSString *)kUTTypeImage, (NSString *)kUTTypeLivePhoto];
        picker.mediaTypes = mediaTypes;
    
        // bring up the picker
        [self presentViewController:picker animated:YES completion:nil];
    

    And then

    # pragma mark - UIImagePickerController Delegate
    
    - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
    
    // check if this is a Live Image, otherwise present a warning
        PHLivePhoto *photo = [info objectForKey:UIImagePickerControllerLivePhoto];
        if (!photo) {
            [self notLivePhotoWarning];
            return;
        }
    // create a Live Photo View
        PHLivePhotoView *photoView = [[PHLivePhotoView alloc]initWithFrame:rect];
        photoView.livePhoto =  [info objectForKey:UIImagePickerControllerLivePhoto]; 
    
    }
    
    0 讨论(0)
提交回复
热议问题