ionic-native
Version:
Native plugin wrappers for Cordova and Ionic with TypeScript, ES6+, Promise and Observable support
137 lines • 5.05 kB
JavaScript
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
import { Cordova, Plugin } from './plugin';
/**
* @name Camera
* @description
* Take a photo or capture video.
*
* Requires {@link module:driftyco/ionic-native} and the Cordova plugin: `cordova-plugin-camera`. For more info, please see the [Cordova Camera Plugin Docs](https://github.com/apache/cordova-plugin-camera).
*
* @usage
* ```typescript
* import { Camera } from 'ionic-native';
*
*
* Camera.getPicture(options).then((imageData) => {
* // imageData is either a base64 encoded string or a file URI
* // If it's base64:
* let base64Image = 'data:image/jpeg;base64,' + imageData;
* }, (err) => {
* // Handle error
* });
* ```
* @interfaces
* CameraOptions
* CameraPopoverOptions
*/
export var Camera = (function () {
function Camera() {
}
/**
* Take a picture or video, or load one from the library.
* @param {CameraOptions?} options optional. Options that you want to pass to the camera. Encoding type, quality, etc. Platform-specific quirks are described in the [Cordova plugin docs](https://github.com/apache/cordova-plugin-camera#cameraoptions-errata-).
* @returns {Promise<any>} Returns a Promise that resolves with Base64 encoding of the image data, or the image file URI, depending on cameraOptions, otherwise rejects with an error.
*/
Camera.getPicture = function (options) { return; };
/**
* Remove intermediate image files that are kept in temporary storage after calling camera.getPicture.
* Applies only when the value of Camera.sourceType equals Camera.PictureSourceType.CAMERA and the Camera.destinationType equals Camera.DestinationType.FILE_URI.
* @returns {Promise<any>}
*/
Camera.cleanup = function () { return; };
;
/**
* @private
* @enum {number}
*/
Camera.DestinationType = {
/** Return base64 encoded string. DATA_URL can be very memory intensive and cause app crashes or out of memory errors. Use FILE_URI or NATIVE_URI if possible */
DATA_URL: 0,
/** Return file uri (content://media/external/images/media/2 for Android) */
FILE_URI: 1,
/** Return native uri (eg. asset-library://... for iOS) */
NATIVE_URI: 2
};
/**
* @private
* @enum {number}
*/
Camera.EncodingType = {
/** Return JPEG encoded image */
JPEG: 0,
/** Return PNG encoded image */
PNG: 1
};
/**
* @private
* @enum {number}
*/
Camera.MediaType = {
/** Allow selection of still pictures only. DEFAULT. Will return format specified via DestinationType */
PICTURE: 0,
/** Allow selection of video only, ONLY RETURNS URL */
VIDEO: 1,
/** Allow selection from all media types */
ALLMEDIA: 2
};
/**
* @private
* @enum {number}
*/
Camera.PictureSourceType = {
/** Choose image from picture library (same as SAVEDPHOTOALBUM for Android) */
PHOTOLIBRARY: 0,
/** Take picture from camera */
CAMERA: 1,
/** Choose image from picture library (same as PHOTOLIBRARY for Android) */
SAVEDPHOTOALBUM: 2
};
/**
* @private
* Matches iOS UIPopoverArrowDirection constants to specify arrow location on popover.
* @enum {number}
*/
Camera.PopoverArrowDirection = {
ARROW_UP: 1,
ARROW_DOWN: 2,
ARROW_LEFT: 4,
ARROW_RIGHT: 8,
ARROW_ANY: 15
};
/**
* @private
* @enum {number}
*/
Camera.Direction = {
/** Use the back-facing camera */
BACK: 0,
/** Use the front-facing camera */
FRONT: 1
};
__decorate([
Cordova({
callbackOrder: 'reverse'
})
], Camera, "getPicture", null);
__decorate([
Cordova({
platforms: ['iOS']
})
], Camera, "cleanup", null);
Camera = __decorate([
Plugin({
pluginName: 'Camera',
plugin: 'cordova-plugin-camera',
pluginRef: 'navigator.camera',
repo: 'https://github.com/apache/cordova-plugin-camera',
platforms: ['Android', 'BlackBerry', 'Browser', 'Firefox', 'FireOS', 'iOS', 'Windows', 'Windows Phone 8', 'Ubuntu']
})
], Camera);
return Camera;
}());
//# sourceMappingURL=camera.js.map