kautaleksei / UzysAssetsPickerController

Alternative UIImagePickerController , You can take a picture with camera and pick multiple photos and videos

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

UzysAssetsPickerController

License MIT CocoaPods License MIT

Alternative UIImagePickerController , You can take a picture with camera and pick multiple photos and videos

Screenshot

ScreenshotScreenshot

Installation

  1. UzysAssetsPickerController in your app is via CocoaPods.
  2. Copy over the files libary folder to your project folder

Usage

###Import header.

#import "UzysAssetsPickerController.h"

open UzysAssetsPickerController

    UzysAssetsPickerController *picker = [[UzysAssetsPickerController alloc] init];
    picker.delegate = self;
    picker.maximumNumberOfSelectionMedia = 2;
    [self presentViewController:picker animated:YES completion:^{
        
    }]; 

UzysAssetPickerControllerDelegate

- (void)UzysAssetsPickerController:(UzysAssetsPickerController *)picker didFinishPickingAssets:(NSArray *)assets
{
    __weak typeof(self) weakSelf = self;
    if([[assets[0] valueForProperty:@"ALAssetPropertyType"] isEqualToString:@"ALAssetTypePhoto"]) //Photo
    {
            [assets enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
                ALAsset *representation = obj;
                
                    UIImage *img = [UIImage imageWithCGImage:representation.defaultRepresentation.fullResolutionImage
                                                       scale:representation.defaultRepresentation.scale
                                                 orientation:(UIImageOrientation)representation.defaultRepresentation.orientation];
                weakSelf.imageView.image = img;
                *stop = YES;
            }];
        
        
    }
    else //Video
    {
        ALAsset *alAsset = assets[0];
        
        UIImage *img = [UIImage imageWithCGImage:alAsset.defaultRepresentation.fullResolutionImage
                                           scale:alAsset.defaultRepresentation.scale
                                     orientation:(UIImageOrientation)alAsset.defaultRepresentation.orientation];
        weakSelf.imageView.image = img;

        
        
        ALAssetRepresentation *representation = alAsset.defaultRepresentation;
        NSURL *movieURL = representation.url;
        NSURL *uploadURL = [NSURL fileURLWithPath:[[NSTemporaryDirectory() stringByAppendingPathComponent:@"test"] stringByAppendingString:@".mp4"]];
        AVAsset *asset      = [AVURLAsset URLAssetWithURL:movieURL options:nil];
        AVAssetExportSession *session =
        [AVAssetExportSession exportSessionWithAsset:asset presetName:AVAssetExportPresetMediumQuality];
        
        session.outputFileType  = AVFileTypeQuickTimeMovie;
        session.outputURL       = uploadURL;
        
        [session exportAsynchronouslyWithCompletionHandler:^{
            
            if (session.status == AVAssetExportSessionStatusCompleted)
            {
                NSLog(@"output Video URL %@",uploadURL);
            }
            
        }];
        
    }
}

filter option

images only

  UzysAssetsPickerController *picker = [[UzysAssetsPickerController alloc] init];
  picker.delegate = self;
  picker.maximumNumberOfSelectionVideo = 0;
  picker.maximumNumberOfSelectionPhoto = 3;

videos only

  UzysAssetsPickerController *picker = [[UzysAssetsPickerController alloc] init];
  picker.delegate = self;
  picker.maximumNumberOfSelectionVideo = 3;
  picker.maximumNumberOfSelectionPhoto = 0;

images or videos

  UzysAssetsPickerController *picker = [[UzysAssetsPickerController alloc] init];
  picker.delegate = self;
  picker.maximumNumberOfSelectionVideo = 4;
  picker.maximumNumberOfSelectionPhoto = 3;

both images and videos

  UzysAssetsPickerController *picker = [[UzysAssetsPickerController alloc] init];
  picker.delegate = self;
  picker.maximumNumberOfSelectionMedia = 5;

Contact

License

About

Alternative UIImagePickerController , You can take a picture with camera and pick multiple photos and videos

License:MIT License