Hi I\'m working On videos , i would like get the list of video files from library to Display and playing the Videos in my app. can any one help me.
Checkout the blog post to fetch all video assets using Photos Framework http://iavinashkashyap.blogspot.in/2016/11/get-list-of-all-videos.html
Code:
-(void) getAllVideoAssets{
NSMutableArray *assets = [[NSMutableArray alloc] init];
//Fetch all video assets from Photos
PHFetchResult *assetResults = [PHAsset fetchAssetsWithMediaType:PHAssetMediaTypeVideo options:nil];
//get all assets
for (PHAsset *asset in assetResults){
NSLog(@"asset type = %zd", asset.mediaType);
[assets addObject:asset];
}
self.allVideoslistArray = [[NSMutableArray alloc] init];
//create an instance of PHImageManager
PHImageManager *manager = [PHImageManager defaultManager];
for(PHAsset *asset in assets){
//block of code for represent video assets
[manager requestAVAssetForVideo:asset options:nil resultHandler:^(AVAsset * _Nullable asset, AVAudioMix * _Nullable audioMix, NSDictionary * _Nullable info) {
if ([asset isKindOfClass:[AVURLAsset class]]) {
NSURL *url = (NSURL *)[[(AVURLAsset *)asset URL] fileReferenceURL];
UIImage *thumbnail = [self createThunbnailImage:url];
[self.allVideoslistArray addObject:@{@"VideoUrl":url,@"ThumbnailImage":thumbnail, @"VideoAsset":asset}];
}
}];
}//end for loop
}