photokit

How to identify if a PHAsset is not completely downloaded from iCloud (so I need to request again with options.networkAccessAllowed)

萝らか妹 提交于 2019-11-29 20:44:23
The docs say: PHImageResultIsInCloudKey: A Boolean value indicating whether the photo asset data is stored on the local device or must be downloaded from iCloud. (NSNumber) If YES, no image was provided, because the asset data must be downloaded from iCloud. To download the data, submit another request, and specify YES for the networkAccessAllowed option. But this key is always YES when a asset is stored in the iCloud Photo Library, even when it is already completely downloaded to the device (downloaded it in my app, also opened it in the Photos app). If an image is not available I want to

Issue playing slow-mo AVAsset in AVPlayer

和自甴很熟 提交于 2019-11-29 08:13:40
I'm trying to play an slow motion video (filmed by the user's iPhone) in an AVPlayer . I am retrieving the AVAsset with a request on a PHAsset from a picker: [manager requestAVAssetForVideo:PHAsset options:videoRequestOptions resultHandler:^(AVAsset * avasset, AVAudioMix * audioMix, NSDictionary * info) {}]; The problem is once it plays, I get this error: -[AVComposition URL]: unrecognized selector sent to instance 0x138d17f40 However, if I set this option on the manager request, it will play as normal speed video at 120/240fps and no crashes: videoRequestOptions.version =

How can I determine file size on disk of a video PHAsset in iOS8

ⅰ亾dé卋堺 提交于 2019-11-29 04:08:30
I can request a video PHAsset using the Photos framework in iOS8. I'd like to know how big the file is on disk. There doesn't seem to be a property of PHAsset to determine that. Does anyone have a solution? (Using Photos framework not required) Edit As for iOS 9.3, using requestImageDataForAsset on a video type PHAsset will result in an image, which is the first frame of the video, so it doesn't work anymore. Use the following method instead, for normal video, request option can be nil , but for slow motion video, PHVideoRequestOptionsVersionOriginal needs to be set. PHVideoRequestOptions

Get URL of a newly created asset, iOS 9 style

為{幸葍}努か 提交于 2019-11-29 02:49:59
问题 ALAssetsLibrary is deprecated these days but practically all examples on SO are still making use of it. For my objective, I need to know the URL of the video that was added to the Photo Library so I could share a video to the Instagram app (that's the only way in which Instagram accepts videos). The URL should probably start with "assets-library://..." This is simple with ALAssetsLibrary : ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init]; [library writeVideoAtPathToSavedPhotosAlbum

Save image to photo library using photo framework

亡梦爱人 提交于 2019-11-29 01:57:56
My app crashes every time when I try to save image using photo framework. -(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{ _mChangeRequest = [PHAssetChangeRequest creationRequestForAssetFromImage:[info valueForKey:UIImagePickerControllerOriginalImage]]; [[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{ _mChangeRequest = [PHAssetChangeRequest creationRequestForAssetFromImage:[info valueForKey:UIImagePickerControllerOriginalImage]]; } completionHandler:^(BOOL success, NSError *error) { if (success) { PHObjectPlaceholder

How to access NSData/NSURL of slow motion videos using PhotoKit

三世轮回 提交于 2019-11-29 00:10:52
Working with new Photo framework, I can access the NSData of PHAssets using requestImageDataForAsset . I can also access the file URL using the PHImageFileURLKey of the returned info NSDictionary . [[PHImageManager defaultManager] requestImageDataForAsset:asset options:nil resultHandler:^(NSData *imageData, NSString *dataUTI, UIImageOrientation orientation, NSDictionary *info) { //imageData contains the correct data for images and videos NSLog(@"info - %@", info); NSURL* fileURL = [info objectForKey:@"PHImageFileURLKey"]; }]; This works fine for images and normal videos. However, when the

Retrieve ALAsset or PHAsset from file URL

人盡茶涼 提交于 2019-11-28 12:13:34
Selecting images in Photos.app to pass to an action extension seems to yield paths to images on disk (e.g.: file:///var/mobile/Media/DCIM/109APPLE/IMG_9417.JPG ). Is there a way to get the corresponding ALAsset or PHAsset? The URL looks like it corresponds to the PHImageFileURLKey entry you get from calling PHImageManager.requestImageDataForAsset . I'd hate to have to iterate through all PHAssets to find it. I did what I didn't want to do and threw this dumb search approach together. It works, although it's horrible, slow and gives me memory issues when the photo library is large. As a noob to

Programmatic access to the Photos Library on Mac OS X: PhotoKit / Photos Framework for Mac

不想你离开。 提交于 2019-11-28 09:24:22
In Objective-C, there's a Photos Framework a.k.a. PhotoKit which enables iOS developers to access the photos library on iPhone and iPad and to retrieve the pictures/videos along with their metadata. How would Mac developers perform a similar task? It seems PhotoKit is only available in iOS 8.0. Is there an equivalent of the Photos Framework for Mac OS X? The Media Library Framework is the place to go. Usage: @import MediaLibrary; - (void) awakeFromNib { NSDictionary *options = @{ MLMediaLoadSourceTypesKey: @(MLMediaSourceTypeImage), MLMediaLoadIncludeSourcesKey: @[MLMediaSourcePhotosIdentifier

Issue playing slow-mo AVAsset in AVPlayer

旧巷老猫 提交于 2019-11-28 01:37:48
问题 I'm trying to play an slow motion video (filmed by the user's iPhone) in an AVPlayer . I am retrieving the AVAsset with a request on a PHAsset from a picker: [manager requestAVAssetForVideo:PHAsset options:videoRequestOptions resultHandler:^(AVAsset * avasset, AVAudioMix * audioMix, NSDictionary * info) {}]; The problem is once it plays, I get this error: -[AVComposition URL]: unrecognized selector sent to instance 0x138d17f40 However, if I set this option on the manager request, it will play

Programmatic access to the Photos Library on Mac OS X: PhotoKit / Photos Framework for Mac

霸气de小男生 提交于 2019-11-27 21:23:38
问题 In Objective-C, there's a Photos Framework a.k.a. PhotoKit which enables iOS developers to access the photos library on iPhone and iPad and to retrieve the pictures/videos along with their metadata. How would Mac developers perform a similar task? It seems PhotoKit is only available in iOS 8.0. Is there an equivalent of the Photos Framework for Mac OS X? 回答1: The Media Library Framework is the place to go. Usage: @import MediaLibrary; - (void) awakeFromNib { NSDictionary *options = @{