nativescript-mediafilepicker
A complete file picker solution for NativeScript. You will be able to pickup any types of file. Capturing image, video & audio are supported. It's a combination features of nativescript-imagepicker and nativescript-camera plugin with some extended features using following native libaries:
- Android: MultiType-FilePicker
- iOS: IQMediaPickerController & DKImagePickerController
Old version (v1.X) can be found from this branch
Features:
- Image, Video, Audio & custom file picker.
- Capturing Image, Video and Audio from APP directly.
- Custom files like pdf, text etc support. For iOS I have used
UIDocumentPickerViewController
- Single or Multiple selections.
- More...
Limitations
- Anything those exists in Native Library. You can check the native libaries.
In iOS after selecting file you may not be able to use it directly. In this case you will need to copy that file in your app directory. After using it you can delete it for reducing storage memory usage. Please check the demo for more details.Only for iOS Audio picker.At present selecting iCloud file isn't supported for iOS because of Native Library limitation.
Note: I am not an expert of neigher iOS nor Android. So, please contribute if you think something you can do better :)
NativeScript Version Support
NS Version | nativescript-mediafilepicker version | Install command | Docs |
---|---|---|---|
^7.0.0 | ^4.0.0 | ns plugin add nativescript-mediafilepicker | This page |
^6.0.0 | ^3.0.0 | tns plugin add nativescript-mediafilepicker@^3.0.0 | Here |
Installation (NS 7)
ns plugin add nativescript-mediafilepicker
Usage (NS 7) (Please check demo project for details)
Import
JavaScript:
var mPicker = ;var mediafilepicker = ;
TS:
;
Image File Picker
let options: ImagePickerOptions = android: isCaptureMood: false // if true then camera will open directly. isNeedCamera: true maxNumberFiles: 10 isNeedFolderList: true ios: isCaptureMood: false // if true then camera will open directly. isNeedCamera: true maxNumberFiles: 10 ; let mediafilepicker = ;mediafilepicker; mediafilepicker; // for iOS iCloud downloading statusmediafilepicker; mediafilepicker; mediafilepicker;
Video File Picker
let allowedVideoQualities = ; if appios allowedVideoQualities = AVCaptureSessionPreset1920x1080 AVCaptureSessionPresetHigh; // get more from here: https://developer.apple.com/documentation/avfoundation/avcapturesessionpreset?language=objc let options: VideoPickerOptions = android: isCaptureMood: false // if true then camera will open directly. isNeedCamera: true maxNumberFiles: 2 isNeedFolderList: true maxDuration: 20 ios: isCaptureMood: false // if true then camera will open directly. videoMaximumDuration: 10 allowedVideoQualities: allowedVideoQualities ; let mediafilepicker = ; mediafilepicker; mediafilepicker; // for iOS iCloud downloading statusmediafilepicker; mediafilepicker; mediafilepicker;
Audio File Picker
let options: AudioPickerOptions = android: isCaptureMood: false // if true then voice recorder will open directly. isNeedRecorder: true maxNumberFiles: 2 isNeedFolderList: true maxSize: 102400 // Maximum size of recorded file in bytes. 5900 = ~ 1 second ios: isCaptureMood: false // if true then voice recorder will open directly. maxNumberFiles: 5 audioMaximumDuration: 10 ; let mediafilepicker = ; mediafilepicker; mediafilepicker; mediafilepicker; mediafilepicker;
Custom File Picker
let extensions = ; if appios extensions = kUTTypePDF kUTTypeText; // you can get more types from here: https://developer.apple.com/documentation/mobilecoreservices/uttype else extensions = 'txt' 'pdf'; let options: FilePickerOptions = android: extensions: extensions maxNumberFiles: 2 ios: extensions: extensions multipleSelection: true ; let mediafilepicker = ; mediafilepicker; mediafilepicker; mediafilepicker; mediafilepicker;
Usage in Angular
mediafilepicker;
All Methods
: void;: void;: void;: void; // iOS only: Promise<{}>;: Promise<{}>;: Promise<{}>;: Promise<{}>;: Promise<{}>;
All options
; ios?: isCaptureMood?: boolean; isNeedCamera?: boolean; maxNumberFiles?: number; hostView?: View; ;}; ios?: isCaptureMood?: boolean; maxNumberFiles?: number; videoMaximumDuration?: number; allowedVideoQualities?: Array<string>; // https://developer.apple.com/documentation/avfoundation/avcapturesessionpreset?language=objc hostView?: View; ;}; ios?: isCaptureMood?: boolean; maxNumberFiles?: number; audioMaximumDuration?: number; hostView?: View; ;}; ios?: extensions: Array<string>; // https://developer.apple.com/documentation/mobilecoreservices/uttype multipleSelection?: boolean; hostView?: View; ;}
Screenshots
Android
iOS
License
Apache License Version 2.0, January 2004