siamakrostami / MediaPickerHelper

MediaPickerHelper allows you to create a simple media picker action sheet

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MediaPickerHelper

MediaPickerHelper allows you to create a simple media picker action sheet

Usage

create an instance of MediaPickerHelper with selected types:

Picker Types:

  Camera 
  Library(camera roll)
  Files 
  Remove 
        

Media Types:

Video 
Audio
Document 
Image 
Unsopported

Create a variable and initialize:

fileprivate var pickerViewModel : MediaPickerHelper!
    fileprivate func initializeData(){
        self.pickerViewModel = MediaPickerHelper(mediaTypes: [.Camera,.Library,.Files], viewController: self)
        self.pickerViewModel.mediaPickerDelegate = self
        self.pickerViewModel.filePickerDelegate = self
    }
    

Show picker :

    @IBAction func showPickerView(_ sender: Any) {
        self.pickerViewModel.ShowPickerActionSheet()
    }
    

Use Delegations:

extension YourPickerViewController : MediaPickerProtocols , FilePickerProtocols{

    func mediaUrl(media: URL?, type: MediaPickerExtensions?) {
        guard let fileUrl = media else{return}
        // do something with picked media
    }
    
    func fileUrl(file: URL?, type: MediaPickerExtensions?) {
        guard let fileUrl = file else{return}
        // do something with picked file
    }
    
}

Example

To run the example project, clone the repo and build it.

License

MediaPickerHelper is available under the MIT license. See the LICENSE file for more info.

About

MediaPickerHelper allows you to create a simple media picker action sheet

License:MIT License


Languages

Language:Swift 100.0%