GithubHelp home page GithubHelp logo

iqmediapickercontroller's Introduction

Icon

IQMediaPickerController

GitHub license

IQMediaPickerController allows user to capture Videos, Images and Audio using AVFoundation framework. It also allows user to pick Videos, Images and Audio from the iPhone photo and media library. IQMediaPickerController contains 3 library IQMediaCaptureController, IQAssetsPickerController & IQAudioPickerController. All libraries are separate from the others, so if you want to integrate any one of them, you can copy only required library without copying others.

Key Features

  • Contains 3 library allows to pick video, photo, audio type of data
  • Can capture/record supported data and can pick from photo and audio library as well
  • Can record multiple type of data at one shoot
  • Can pick or capture/record multiple files at once
  • Can limit length of media while recording

IQMediaCaptureController

IQMediaCaptureController is used to capture multiple images, videos and audio.

Video Recorder Photo Capture Audio Recorder

IQAssetsPickerController

IQAssetsPickerController is used to pick multiple images & videos from the iPhone photo gallery.

[Photo Picker Picker]

IQAudioPickerController

IQAudioPickerController is used to pick multiple audio files from the iPhone music library.

[Audio Picker]

Installation

CocoaPods:-

CocoaPods

IQMediaPickerController:- IQMediaPickerController is available through CocoaPods, to install it simply add the following line to your Podfile:

pod 'IQMediaPickerController'

Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.

You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage

To integrate IQMediaPickerController into your Xcode project using Carthage, specify it in your Cartfile:

github "hackiftekhar/IQMediaPickerController"

Run carthage to build the frameworks and drag IQMediaPickerController.framework into your Xcode project.

Source Code:-

Github tag

Just drag and drop IQMediaPickerController directory to your project. That's it.

Example Usage

#import <IQMediaPickerController/IQMediaPickerController.h>

@interface ViewController ()<IQMediaPickerControllerDelegate>
@end

@implementation ViewController
{
    IQMediaPickerSelection *selectedMedias;
}

-(void)showMediaPicker
{
    IQMediaPickerController *controller = [[IQMediaPickerController alloc] init];
    controller.delegate = self;
    
    //Set additional settings if you would like to
    //[controller setSourceType:IQMediaPickerControllerSourceTypeCameraMicrophone];//or IQMediaPickerControllerSourceTypeLibrary
    //[controller setMediaTypes:@[@(PHAssetMediaTypeAudio),@(PHAssetMediaTypeVideo),@(PHAssetMediaTypeImage)]];
    //controller.captureDevice = AVCaptureDevicePositionBack;//or AVCaptureDevicePositionFront
    //controller.allowsPickingMultipleItems = YES;//or NO
    //controller.allowedVideoQualities = @[@(AVCaptureSessionPreset1920x1080),@(AVCaptureSessionPresetHigh)];

    [self presentViewController:controller animated:YES completion:nil];
}

-(void)mediaPickerController:(IQMediaPickerController *)controller didFinishMedias:(IQMediaPickerSelection *)selection
{
    NSLog(@"Info: %@",selection);   //Here you'll get the information about captured or picked assets

    selectedMedias = selection;

    [self.tableView reloadData];
}

- (void)mediaPickerControllerDidCancel:(IQMediaPickerController *)controller;
{
}

@end

LICENSE

Distributed under the MIT License.

Contributions

Any contribution is more than welcome! You can contribute through pull requests and issues on GitHub.

Author

If you wish to contact me, email at: [email protected]

iqmediapickercontroller's People

Contributors

hackiftekhar avatar jfmiguel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

iqmediapickercontroller's Issues

icons are not Visible: Xcode 9/ swift 3

Hii , i have install framework through pod install(pod "IQMediaPickerController") . app is build successfully and run but the IQMediaPickerController not showing assest icons of flash/front/rear camera icons etc, though these button are clickable.
screenshot

//presenting PhotoCamera
let mediaPickerGallery = IQMediaPickerController()
         mediaPickerGallery.delegate = self
        mediaPickerGallery.captureDevice = IQMediaPickerControllerCameraDevice.rear
        var qualityArr = [NSNumber]()
        qualityArr.append(NSNumber(value: IQMediaPickerControllerQualityType.typeHigh.rawValue))
        qualityArr.append(NSNumber(value: IQMediaPickerControllerQualityType.type1920x1080.rawValue))
        mediaPickerGallery.allowedVideoQualities = qualityArr
        mediaPickerGallery.allowsPickingMultipleItems = true
        mediaPickerGallery.maximumItemCount = 10
  mediaPickerGallery.sourceType = IQMediaPickerControllerSourceType.cameraMicrophone
        var mediaTypesArr = [NSNumber]()
        mediaTypesArr.append(NSNumber(value: IQMediaPickerControllerMediaType.photo.rawValue))
        mediaPickerGallery.mediaTypes = mediaTypesArr
        self.present(mediaPickerGallery, animated: true, completion: nil)

And "info" is also returing null even i select any media.

func mediaPickerController(_ controller: IQMediaPickerController, didFinishMediaWithInfo info: [AnyHashable : Any]) {
        NIDebug.printLogArg(value: "Info: %@",info)
        
    }

is there anything i missed ? please help in this

Separate All 3 Libraries(Project)

Hello,
Most of the user want only ImagePicker Library.
So, it is better if we separate all 3 Libraries i.e. projects.
because it takes too much time to remove code for other 2 libraries & that's why this library is not as popular as IQKeyboardManager.

I am sorry if I am wrong.

Thanks,

PHPhotoLibrary Support

I think the project could benefit from PHPhotoLibrary Support. I've forked a copy and will see if I can disambiguate the references to the ALAssetsLibrary. Wish Apple had provided a mediator or bridge object that did this already.

-[IQCaptureSession takePicture] issue

Fatal Exception: NSInternalInconsistencyException *** -[AVCaptureStillImageOutput captureStillImageAsynchronouslyFromConnection:completionHandler:] Inconsistent state

PHPhoto Library Support

Hi,
thanks for the fantastic tool you gave us....
really a very very nice work.I propose one thing only,
if you can add support for the new PHPhoto library this will be a fantastic enhancement!!

Any way,
I thank you again

George Gerardis

Validate button not showing when allowsPickingMultipleItems = YES

Hello @hackiftekhar ,

Thank you for this great library. But I'm facing an issue when I set allowsPickingMultipleItems to YES : the validate button (on top right of the screen) never appears... so I can't validate/end my selection...
This happens both on emulator and real device.

Deployment target : 9.0
iOS version : 11+
Xcode version : 9.2

simulator screen shot - iphone 8 plus - 2018-02-10 at 13 20 10

memory when selecting multiple images/videos

Hello and thanks for open sourcing this excellent lib.
I have one remark to make considering the memory when selecting multiple images from the camera roll.
Instead of getting the fullResolutionImage and adding it in the dictionary you can provide the ALAsset url and let the user decide what to do with it.
other than that excellent coding.

thanks

Subclassable.

I'm subclassing IQMediaCaptureController & building my own view layout from a xib. This means overriding loadView & not calling super.

IQMediaCaptureController isn't very nicely subclass-able. I wonder if this can be improved?
For example here what I'm exposing:

@interface IQMediaCaptureController () <IQMediaViewDelegate,IQCaptureSessionDelegate,IQAssetsPickerControllerDelegate>
@property (nonatomic,weak) IBOutlet IQMediaView * mediaView;
- (IQCaptureSession *)session;
- (void)updateDuration;
- (void)updateUI;
- (void)setCaptureDevice:(IQMediaCaptureControllerCameraDevice)captureDevice animated:(BOOL)animated;
/*
- (NSMutableArray *)videoURLs;
- (NSMutableArray *)arrayImagesAttribute;
*/
- (void)selectAction:(UIButton *)sender;
@end

It would be nice if it could subclassed better & allow for the view to be created/customised from a xib.

Rotate Image in iPad

Thanks for great help.
This work good with iPad Image gallery but with Camera it Rotate the images.

Second with Image preview is there any way to disable or a close menu ?

Thanks,
Mangesh

Carthage Support

Any chance you could add support for Carthage? Currently when trying to pull, one is confronted with the following message:

No tagged versions found for github "hackiftekhar/IQMediaPickerController"

Which implies it might be as easy as adding some sort of tag. I am not certain of the requirement to support Carthage but that initial message seems as though adding support might be trivial. I'd prefer Carthage because the overhead with cocoa pods is something I'd like to avoid and I am used to adding additional frameworks to the IDE (as others may be as well).

Found on SO that one can simply add the branch to the Cartfile. (http://stackoverflow.com/questions/31069315/carthage-errors-no-tagged-versions-found-for-github)

Cartfile

github "hackiftekhar/IQMediaPickerController" "master"

However this led to an error:
Dependency "IQMediaPickerController" has no shared framework schemes

Turns out that SO had this to say

Basically the shared scheme is not being added to the git repo.
(http://stackoverflow.com/questions/35054788/carthage-no-shared-framework-schemes-for-ios-platform-for-my-own-framework)

Framework Support

Medium actually has a nice article on making a Carthage framework (https://medium.com/@filippotosetto/how-to-create-a-carthage-framework-8d9d65f98ac2#.9ger2pyn9)

Shared Framework Scheme

Found an option to share Scheme on the Edit Scheme dialog box (Product > Edit Scheme)

Upload images & Videos to FTP-Server

Hi,

Can I use this API to upload all the images & videos in the gallery, without any user interaction? I just want the app to take all the pictures & videos and upload it to my FTP every midnight as an background service in my phone.

Crashing issue happens occasionally

Hi I am trying to use the lib directly not using pod and I am facing this issue.

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Application tried to present modally an active controller

Created a variable in a ViewController
let iqPickerController = IQMediaPickerController()

Then on a button press

        iqPickerController.delegate = self 
        iqPickerController.allowsPickingMultipleItems = true
        iqPickerController.mediaTypes = [0, 1, 2]
        iqPickerController.sourceType = .cameraMicrophone

I have added the necessary delegate functions also. This only happens some times, But when I press the button second time (after selecting media and dismissing) it crashes more often.

Also I am using the lib in a swift project

Too many forward slashes in media URL

All media url's are returning too many slashes before the filename:
file:///var/mobile/Containers/Data/Application/B680CAA8-3150-4D5B-8B97-E3EA3206ADC2/Documents/IQVideo//movie0.mov

NSString *nextMediaPath = [[[self class] temporaryVideoStoragePath] stringByAppendingFormat:@"/movie%lu.mov",(unsigned long)videoCounter++];

could be replaced with:

NSString *nextMediaPath = [[[self class] temporaryVideoStoragePath] stringByAppendingPathComponent:@"movie%lu.mov",(unsigned long)videoCounter++];

Photo Library

At photo library the default view show me the older images at the top and not the new one on the bottom,
How can i set the scroll to be at the bottom view so i can see my new photos as default?

Thank you

Improper preview rotation

When using IQMediaPickerController as follows:

        let picker = IQMediaPickerController()
        picker.delegate = self
        picker.allowsPickingMultipleItems = false
        picker.sourceType = .cameraMicrophone
        picker.mediaTypes = [PHAssetMediaType.image.rawValue] as [NSNumber]
        
        self.present(picker, animated: true, completion: nil)

The preview image is rotated -90 degrees, while the controls are oriented correctly. I can use picker.view.transform = CGAffineTransform(rotationAngle: CGFloat(-Double.pi/2.0)) to rotate the entire view, but then only the preview is rendered correctly. The controls are now rotated incorrectly. Is there a way to correctly orient the preview and the controls at the same time?

Exclude Cloud Media

Hi,
is there any way to exclude the picker from showing iCloud media items, e.g. items that are not stored locally on the device?
Thanks in advance.

iOS Swift version coding.

Hey congrats for such a beautiful piece of work. How can I get the image name?

I was thinking to try this code out -

NSURL *refURL = [info valueForKey:UIImagePickerControllerReferenceURL];

    // define the block to call when we get the asset based on the url (below)
    ALAssetsLibraryAssetForURLResultBlock resultblock = ^(ALAsset *imageAsset)
    {
        ALAssetRepresentation *imageRep = [imageAsset defaultRepresentation];
        NSLog(@"[imageRep filename] : %@", [imageRep filename]);
    };

    // get the asset library and fetch the asset based on the ref url (pass in block above)
    ALAssetsLibrary* assetslibrary = [[ALAssetsLibrary alloc] init];
    [assetslibrary assetForURL:refURL resultBlock:resultblock failureBlock:nil];

But I need the url for this.

Set media before opening the IQMediaPickerController

Hi thanks for the awesome lib, I have always been a fan of your work (IQKeyboradManger) Saved me 100's of hours

I am using this lib and was wondering if its possible to set media even before opening the controller. This will help if I am opening the IQMediaPicker for second time it will have the data which I selected first time.

Thanks again for the awesome lib.

Audio Playback

Hello,

I would firstly like to say thank you for this tremendous library, it was exactly what I was looking for.

However, I have encountered some trouble in regards to the audio playback. It is being executed in MPMoviePlayerViewController in an M4a file extension. Is there any other way in which I can use a proper Music Player instead of the movie player so I can show the audio files iTunes artwork and song title. Also, is it possible to change the M4a file extension to MP3? Is there any sort of conversion library?

Apologise if this sounds very stupid and perplexing, i'm fairly new to using AVFoundation.

Any comments are greatly appreciated.

Regards,
Christopher

Swift compatibility

Downloaded using pod, to my application. Not experienced with obj C and would like to use with Swift. If Swift compatible, would like Swift usage script.

Add Max count Media selected

I suggest add max media count to selected.
It is useful function

some problems

  • And When take photos they are over exposed.and they are out-of-focus;
  • When I take pictures I have Received memory warning.I use 6s test it

IQmediapickerController not supporting iCloud PHAssets (videos)

Some PHAssets returns url = nil (or assetIdentifier = nil)
I got notice about it from users using videos that backup on iCloud.
Is there any quick solution?

Those error codes might help:

FAILED - PHASSET NOT CONTAIN URL:

PHImageErrorKey = "Error Domain=NSCocoaErrorDomain Code=-1 \"(null)\"";
PHImageResultIsDegradedKey = 0;
PHImageResultIsInCloudKey = 1;
PHImageResultRequestIDKey = 483; (or 160)

WHEN SUCCESS - PHASSET CONTAIN URL:

PHImageFileSandboxExtensionTokenKey = "6fa17....00000000000001b;com.apple.avasset.read-only;01;/private/var/mobile/Media/DCIM/100APPLE/IMG_0386.MOV";
PHImageResultDeliveredImageFormatKey = 20000;
PHImageResultIsInCloudKey = 0;
PHImageResultWantedImageFormatKey = 20002;

When i capture image from camera, orientation of UIImage changed on server after uploading.

I have captured image from camera, it display properly in device but when i upload image to server then the image and thumbnail both images orientation are changed. I think this is an issue with image exif. there are several solutions available in swift and objective c both. I have implemented it like below but i am facing random memory issues, But i am not sure it's because of this changes. I have make some changes in my project to resolve protocol and closure based memory leaks, so now it's not crashing but i need to double check it.

In IQCaptureSession.m

-(UIImage *)fixOrientation:(UIImage *)image{
    // No-op if the orientation is already correct
    if (image.imageOrientation == UIImageOrientationUp) return image;

    // We need to calculate the proper transformation to make the image upright.
    // We do it in 2 steps: Rotate if Left/Right/Down, and then flip if Mirrored.
    CGAffineTransform transform = CGAffineTransformIdentity;

    switch (image.imageOrientation) {
        case UIImageOrientationDown:
        case UIImageOrientationDownMirrored:
            transform = CGAffineTransformTranslate(transform, image.size.width, image.size.height);
            transform = CGAffineTransformRotate(transform, M_PI);
            break;

        case UIImageOrientationLeft:
        case UIImageOrientationLeftMirrored:
            transform = CGAffineTransformTranslate(transform, image.size.width, 0);
            transform = CGAffineTransformRotate(transform, M_PI_2);
            break;

        case UIImageOrientationRight:
        case UIImageOrientationRightMirrored:
            transform = CGAffineTransformTranslate(transform, 0, image.size.height);
            transform = CGAffineTransformRotate(transform, -M_PI_2);
            break;
        case UIImageOrientationUp:
        case UIImageOrientationUpMirrored:
            break;
    }

    switch (image.imageOrientation) {
        case UIImageOrientationUpMirrored:
        case UIImageOrientationDownMirrored:
            transform = CGAffineTransformTranslate(transform, image.size.width, 0);
            transform = CGAffineTransformScale(transform, -1, 1);
            break;

        case UIImageOrientationLeftMirrored:
        case UIImageOrientationRightMirrored:
            transform = CGAffineTransformTranslate(transform, image.size.height, 0);
            transform = CGAffineTransformScale(transform, -1, 1);
            break;
        case UIImageOrientationUp:
        case UIImageOrientationDown:
        case UIImageOrientationLeft:
        case UIImageOrientationRight:
            break;
    }

    // Now we draw the underlying CGImage into a new context, applying the transform
    // calculated above.
    CGContextRef ctx = CGBitmapContextCreate(NULL, image.size.width, image.size.height,
                                             CGImageGetBitsPerComponent(image.CGImage), 0,
                                             CGImageGetColorSpace(image.CGImage),
                                             CGImageGetBitmapInfo(image.CGImage));
    CGContextConcatCTM(ctx, transform);
    switch (image.imageOrientation) {
        case UIImageOrientationLeft:
        case UIImageOrientationLeftMirrored:
        case UIImageOrientationRight:
        case UIImageOrientationRightMirrored:
            // Grr...
            CGContextDrawImage(ctx, CGRectMake(0,0,image.size.height,image.size.width), image.CGImage);
            break;

        default:
            CGContextDrawImage(ctx, CGRectMake(0,0,image.size.width,image.size.height), image.CGImage);
            break;
    }

    // And now we just create a new UIImage from the drawing context
    CGImageRef cgimg = CGBitmapContextCreateImage(ctx);
    UIImage *img = [UIImage imageWithCGImage:cgimg];
    CGContextRelease(ctx);
    CGImageRelease(cgimg);
    return img;
}

Method: - (void)takePicture
NSData *imageData = [AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:imageDataSampleBuffer];
                
                NSURL *outputImageURL = [[self class] defaultImageStorageURL];
                
                UIImage *capturedImage = [[UIImage alloc] initWithData:imageData];
                
                imageDataSampleBuffer = NULL;
                imageData = NULL;
                
                UIImage *image = [self fixOrientation:capturedImage];
                [UIImageJPEGRepresentation(image, 1.0) writeToURL:outputImageURL.filePathURL atomically:YES];

Require public object to setMaxVideoCaptureDuration

ENHANCEMENT..!!!! Feature request..!!!!

Currently, I'm using this control in my upcoming app. In which I've to set predefined maxVideoCaptureDuration. But unfortunately, this lib does not include this feature.

I go through the code and found that it can be set in your existing code, but the method is private and i'm using cocoapods.

please update your library and provide this feature asap.

Usage with Swift 3 and Xcode 8

I'm trying to use this library in swift 3. I have installed the pod, then written import IQMediaPickerController in necessary class. Delegate also given beside class name as , IQMediaPickerControllerDelegate

The problem is when I create a variable like var mediapicker = IQMediaPickerController() and then try to set mediapicker.delegate = self , then i get error saying

Cannot assign value of type 'CreateAnEventsViewController' to type '(IQMediaPickerControllerDelegate & UINavigationControllerDelegate)?' on mediapicker.delegate = self this line.

How do I go about this?
Without delegate being set, i'm able to present the media picker. But i need delegate method calls too.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.