I'm making an iOS app where the user will be able to record a video and as soon as he finish such record, he can send that video to a server. So far so good! But to find the recorded video is being a headache! How can I find the proper URL for the recorded video? During my tests, I have saved a video in the Supporting Files folder and my code is the following
NSString *url = [[NSBundle mainBundle] pathForResource:@"trailer_iphone" ofType:@".m4v"];
NSData *data = [NSData dataWithContentsOfFile:url];
So what could I do to replace that URL for the one in the photo gallery?
In the Apple Developer web site is showing that we can use the AVAsset in order to access the photo gallery. so I copied into my code and I'm trying to figure this out!
//Copied from Apple website
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
// Enumerate just the photos and videos group by using ALAssetsGroupSavedPhotos.
[library enumerateGroupsWithTypes:ALAssetsGroupSavedPhotos usingBlock:^(ALAssetsGroup *group, BOOL *stop) {
// Within the group enumeration block, filter to enumerate just videos.
[group setAssetsFilter:[ALAssetsFilter allVideos]];
// For this example, we're only interested in the first item.
[group enumerateAssetsAtIndexes:[NSIndexSet indexSetWithIndex:0]
options:0
usingBlock:^(ALAsset *alAsset, NSUInteger index, BOOL *innerStop) {
// The end of the enumeration is signaled by asset == nil.
if (alAsset) {
ALAssetRepresentation *representation = [alAsset defaultRepresentation];
NSURL *url = [representation url];
AVAsset *avAsset = [AVURLAsset URLAssetWithURL:url options:nil];
// Do something interesting with the AV asset.
//My last code
//NSString *url = [[NSBundle mainBundle] pathForResource:@"trailer_iphone" ofType:@".m4v"];
NSData *data = [NSData dataWithContentsOfURL:url];