MediaPickerHelper allows you to create a simple media picker action sheet
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
}
}
To run the example project, clone the repo and build it.
MediaPickerHelper is available under the MIT license. See the LICENSE file for more info.