photosframework

Delete in PhotoKit: can you skip “Recently Deleted”?

感情迁移 提交于 2019-12-01 06:22:24
问题 As of iOS8, when you delete a photo, it goes into a trashcan-analog called "Recently Deleted". This happens when you delete via Photos.app, or via the PhotoKit API (using PHAssetChangeRequest.deleteAssets() ). In Photos.app, you can then go into "Recently Deleted", and really delete that photo. Is there a way to do that in PhotoKit? 回答1: Nope. The only deletion API is deleteAssets . 来源: https://stackoverflow.com/questions/26934777/delete-in-photokit-can-you-skip-recently-deleted

iOS Photos Framework: is it possible to access photos from “People” smart folder?

旧巷老猫 提交于 2019-11-30 13:21:40
问题 I'm trying to access PHAssetCollection s from PHCollectionList . The main idea is to fetch all collections (and assets inside) from "People" smart folder on my iPhone (iOS 10.2). To fetch PHCollectionList I'm using current code: PHFetchResult *listFetchResult = [PHCollectionList fetchCollectionListsWithType:PHCollectionListTypeSmartFolder subtype:PHCollectionListSubtypeSmartFolderFaces options:nil]; PHCollectionList *list = listFetchResult[0]; NSLog(@"title: %@",list.localizedTitle); This

Convert PHAsset (video) to AVAsset, synchronously

≡放荡痞女 提交于 2019-11-30 12:02:30
I need to use the AVAsset object, in order to play it using AVPlayer and AVPlayerLayer. I started using the Photos framework since AssetsLibrary is deprecated. Now I got to the point where I have an array of PHAsset objects and I need to convert them to AVAsset. I tried enumerating through the PHFetchResult and allocation a new AVAsset using the PHAsset's localized description, but it does not seem to show any video when I play it. PHAssetCollection *assetColl = [self scaryVideosAlbum]; PHFetchResult *getVideos = [PHAsset fetchAssetsInAssetCollection:assetColl options:nil]; [getVideos

iOS Photos Framework: is it possible to access photos from “People” smart folder?

馋奶兔 提交于 2019-11-30 07:25:01
I'm trying to access PHAssetCollection s from PHCollectionList . The main idea is to fetch all collections (and assets inside) from "People" smart folder on my iPhone (iOS 10.2). To fetch PHCollectionList I'm using current code: PHFetchResult *listFetchResult = [PHCollectionList fetchCollectionListsWithType:PHCollectionListTypeSmartFolder subtype:PHCollectionListSubtypeSmartFolderFaces options:nil]; PHCollectionList *list = listFetchResult[0]; NSLog(@"title: %@",list.localizedTitle); This works as expected. Console output: "title: People". list.canContainAssets returns NO and list

Photos Framework requestImageDataForAsset occasionally fails

走远了吗. 提交于 2019-11-30 01:04:10
I'm using the photos framework on iOS8.1 and requesting the image data for the asset using requestImageDataForAsset... Most of the time it works and I get the image data and a dictionary containing what you see below. But sometimes the call completes, but the data is nil and the dictionary contains three generic looking entries. The calls are performed sequentially and on the same thread. It is not specific to any particular image. The error will happen on images I've successfully opened in the past. Has anyone encountered this? + (NSData *)retrieveAssetDataPhotosFramework:(NSURL *)urlMedia

Save video to a custom Album using Photos Framework in iOS

↘锁芯ラ 提交于 2019-11-29 23:19:07
问题 I want to save a video that is taken using a custom camera to a particular album say NewAlbum in the Photos Library using the Photos Framework . I have found some answers but they referred to use of ALAssetsLibrary which is deprecated now. Kindly let me know if you need any more details, also rectify me if I missed something. Thanks 回答1: I found a solution To create a PHAsset from an Video: Code Block 1: PhotoLibrary.shared().performChanges({ let createAssetRequest = PHAssetChangeRequest

Convert PHAsset (video) to AVAsset, synchronously

风格不统一 提交于 2019-11-29 17:55:47
问题 I need to use the AVAsset object, in order to play it using AVPlayer and AVPlayerLayer. I started using the Photos framework since AssetsLibrary is deprecated. Now I got to the point where I have an array of PHAsset objects and I need to convert them to AVAsset. I tried enumerating through the PHFetchResult and allocation a new AVAsset using the PHAsset's localized description, but it does not seem to show any video when I play it. PHAssetCollection *assetColl = [self scaryVideosAlbum];

Iterate through photo library on OS X?

回眸只為那壹抹淺笑 提交于 2019-11-29 12:06:52
I'm trying to iterate through a user's photo library on OS X. On iOS, I would use the Photos framework, but apparently that's not available on OS X , and we're supposed to use the Media Library framework instead. However, while I was able to use the code linked above to get access to a MLMediaSource object, I'm having a hard time figuring out how to iterate through the photo assets. The Media Library Framework documentation makes reference to a mediaObjectForIdentifier: method, which sounds promising, but doesn't indicate what sort of identifiers should be used. I'm fairly experienced with iOS

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

How to loop through a photo gallery in swift with photos framework

一个人想着一个人 提交于 2019-11-29 03:17:45
问题 I have an app that creates a unique photo gallery for each ticket on my app. I need to figure out how to loop through that gallery so I can upload the images to the server one at a time. I followed these tutorials on youtube. (Video) I am currently using Swift as my language. my ultimate goal would be to have something like the following pseudo code. //I need the following for loop example for photo in gallery { uploadToServer(photo) } //this function works already func uploadToServer(photo