alasset

How to get a ALAssetRepresentation of a shared photostream ALAsset?

蓝咒 提交于 2019-11-28 17:40:47
问题 When I try to access pictures from a photo stream, sometimes the [asset defaultRepresentation] method returns nil. According to the documentation this can occur if the asset is not (yet) available locally. This method returns nil for assets from a shared photo stream that are not yet available locally. If the asset becomes available in the future, an ALAssetsLibraryChangedNotification notification is posted. Once I view the photo in the Photos.app it becomes available for my app too, but

Wait for assetForURL blocks to be completed

笑着哭i 提交于 2019-11-28 17:08:03
问题 I would like to wait this code to be executed before to continue but as these blocks are called assynchronously I don't know how to do??? NSURL *asseturl; NSMutableArray *tmpListAsset = [[NSMutableArray alloc] init]; ALAssetsLibrary *library = [[[ALAssetsLibrary alloc] init] autorelease]; NSMutableArray *objectsToRemove = [[NSMutableArray alloc] init]; for (NSDictionary *dico in assetsList) { asseturl = [NSURL URLWithString:[dico objectForKey:@"assetUrl"]]; NSLog(@"asset url %@", asseturl); /

ALAssetsLibrary delete ALAssetsGroup / ALAsset

烂漫一生 提交于 2019-11-28 09:26:45
I have created "photos album" from my App, using IOS AssetsLibrary. Reading ALAssetsLibrary,ALAssetsGroup and ALAsset documentations, i have seen methods to "addAsset","addAssetsGroupAlbumWithName". Is there a way to delete PROGRAMMATICALLY my ALAssetsGroup and ALAsset. (the property 'editable' suppose to be TRUE because i create this data). This is not possible using any documented API. Only the photos app can delete Albums. If you want this feature to be added to iOS, I would fill a feature request at http://radar.apple.com . You can only delete the ALAsset which is created by your app with

How to get a correctly rotated UIImage from an ALAssetRepresentation?

半城伤御伤魂 提交于 2019-11-28 04:37:54
问题 I’m trying to get a correctly rotated UIImage from an ALAssetRepresentation using the fullScreenImage method. I have several testing photos shot in various device orientations; the photos show up correctly in the Photos app. The documentation for fullScreenImage says: In iOS 5 and later, this method returns a fully cropped, rotated, and adjusted image—exactly as a user would see in Photos or in the image picker. To create a correctly-rotated UIImage object from the CGImage , you use

How to check if an ALAsset still exists using a URL

不问归期 提交于 2019-11-27 20:15:48
I've got an array containing ALAsset urls (not full ALAsset objects) So each time I start my application I want to check my array to see if it's still up to date... So I tried NSData *assetData = [[NSData alloc] initWithContentsOfFile:@"assets-library://asset/asset.PNG?id=1000000001&ext=PNG"]; but assetData is allways nil thx for the help Use assetForURL:resultBlock:failureBlock: method of ALAssetsLibrary instead to get the asset from its URL. // Create assets library ALAssetsLibrary *library = [[[ALAssetsLibrary alloc] init] autorelease]; // Try to load asset at mediaURL [library assetForURL

Get video NSData from ALAsset url iOS

柔情痞子 提交于 2019-11-27 11:03:50
I am not able to retrieve NSData from the url that I get from ALAsset Below is the code I tried:- I always get NSData as nil. NSData *webData = [NSData dataWithContentsOfURL:[asset defaultRepresentation].url]; I also tried something like this NSData *webData1 = [NSData dataWithContentsOfURL:[[asset valueForProperty:ALAssetPropertyURLs] valueForKey:[[[asset valueForProperty:ALAssetPropertyURLs] allKeys] objectAtIndex:0]]]; The url that I get from the ALAsset:- assets-library://asset/asset.MOV?id=1000000116&ext=MOV I have tried this below link which works but I need to unnecessary write to a

Getting video from ALAsset

*爱你&永不变心* 提交于 2019-11-27 06:56:10
Using the new asset library framework available in iOS 4 i see that I can get the url for a given video using the UIImagePickerControllerReferenceURL. The url returned is in the following format: assets-library://asset/asset.M4V?id=1000000004&ext=M4V I am trying to upload this video to a website so as a quick proof of concept I am trying the following NSData *data = [NSData dataWithContentsOfURL:videourl]; [data writeToFile:tmpfile atomically:NO]; Data is never initialized in this case. Has anyone managed to access the url directly via the new assets library? Thanks for your help. Here is a

Generating custom thumbnail from ALAssetRepresentation

心不动则不痛 提交于 2019-11-27 01:23:09
问题 My main problem is i need to obtain a thumbnail for an ALAsset object. I tried a lot of solutions and searched stack overflow for days, all the solutions i found are not working for me due to these constraint: I can't use the default thumbnail because it's too little; I can't use the fullScreen or fullResolution image because i have a lot of images on screen; I can't use UIImage or UIImageView for resizing because those loads the fullResolution image I can't load the image in memory, i'm

How to get an ALAsset URL from a PHAsset?

。_饼干妹妹 提交于 2019-11-26 18:58:37
You can do it sneakily† using the undocumented PHAsset.ALAssetURL property, but I'm looking for something documented. † In Objective-C, this will help @interface PHAsset (Sneaky) @property (nonatomic, readonly) NSURL *ALAssetURL; @end holtmann Create the assetURL by leveraging the localidentifier of the PHAsset . Example: PHAsset.localidentifier returns 91B1C271-C617-49CE-A074-E391BA7F843F/L0/001 Now take the 32 first characters to build the assetURL, like: assets-library://asset/asset.JPG?id=91B1C271-C617-49CE-A074-E391BA7F843F&ext=JPG You might change the extension JPG depending on the UTI

Get video NSData from ALAsset url iOS

孤街醉人 提交于 2019-11-26 17:59:00
问题 I am not able to retrieve NSData from the url that I get from ALAsset Below is the code I tried:- I always get NSData as nil. NSData *webData = [NSData dataWithContentsOfURL:[asset defaultRepresentation].url]; I also tried something like this NSData *webData1 = [NSData dataWithContentsOfURL:[[asset valueForProperty:ALAssetPropertyURLs] valueForKey:[[[asset valueForProperty:ALAssetPropertyURLs] allKeys] objectAtIndex:0]]]; The url that I get from the ALAsset:- assets-library://asset/asset.MOV