How to save home-made live photos in album?
Asked Answered
E

0

6

I try to make live photos with a JPG file and a MOV file.Like this:

   CGSize targetSize = CGSizeZero;
    PHImageContentMode contentMode = PHImageContentModeDefault;


    __weak NSURL *videoUrl;
    __weak NSURL *photoUrl;

//         Call private API to create the live photo
            self.livePhotoView.livePhoto = nil;
            self.livePhoto = nil;
            self.livePhoto = [[PHLivePhoto alloc] init];
            SEL initWithImageURLvideoURL = NSSelectorFromString(@"_initWithImageURL:videoURL:targetSize:contentMode:");
            if ([self.livePhoto respondsToSelector:initWithImageURLvideoURL]) {
                NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[self.livePhoto methodSignatureForSelector:initWithImageURLvideoURL]];
                [invocation setSelector:initWithImageURLvideoURL];
                [invocation setTarget:self.livePhoto];
                [invocation setArgument:&(photoURL) atIndex:2];
                [invocation setArgument:&(videoUrl) atIndex:3];
                [invocation setArgument:&(targetSize) atIndex:4];
                [invocation setArgument:&(contentMode) atIndex:5];
                [invocation invoke];
            }

            // Set the live photo
            self.livePhotoView.livePhoto = self.livePhoto;

At last,I get the live photo and show it in the livePhotoView.Then I try to save it or share it.I use Class UIActivityViewController.Like this:

  if (self.livePhoto) {

    UIActivityViewController *activityViewController =
    [[UIActivityViewController alloc] initWithActivityItems:@[self.livePhotoView.livePhoto]
                                      applicationActivities:nil];
    [self presentViewController:activityViewController
                       animated:YES
                     completion:^{
                         // ...
                     }];


}

When I share live photo,what I share is just still image.When I choose to save live photo,I can't find anything in album.I search this in many places.I just find some informations in this https://github.com/genadyo/LivePhotoDemo/issues/3. But it didn't solve my problem.

I found an app can do it in AppStore.But I can't understand how it works.https://itunes.apple.com/cn/app/livemaker-free-for-live-photo/id1053967828?mt=8

Expressivity answered 9/11, 2015 at 6:0 Comment(4)
the metadata of image and movie are not match.Lowelllowenstein
the swift demo by genadyo is here: github.com/genadyo/LivePhotoDemo Please read his QuickTimeMov.swift and JPEG.swift. Please share the object c solution if you have.Lowelllowenstein
Yes,thank you.I have found this,too.Expressivity
Yes,just this demo above.we need to add metadataExpressivity

© 2022 - 2024 — McMap. All rights reserved.