UNPKG

5.11 kBJavaScriptView Raw
1"use strict";
2var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4 if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5 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;
6 return c > 3 && r && Object.defineProperty(target, key, r), r;
7};
8var plugin_1 = require('./plugin');
9/**
10 * @name Camera
11 * @description
12 * Take a photo or capture video.
13 *
14 * 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).
15 *
16 * @usage
17 * ```typescript
18 * import { Camera } from 'ionic-native';
19 *
20 *
21 * Camera.getPicture(options).then((imageData) => {
22 * // imageData is either a base64 encoded string or a file URI
23 * // If it's base64:
24 * let base64Image = 'data:image/jpeg;base64,' + imageData;
25 * }, (err) => {
26 * // Handle error
27 * });
28 * ```
29 * @interfaces
30 * CameraOptions
31 * CameraPopoverOptions
32 */
33var Camera = (function () {
34 function Camera() {
35 }
36 /**
37 * Take a picture or video, or load one from the library.
38 * @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-).
39 * @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.
40 */
41 Camera.getPicture = function (options) { return; };
42 /**
43 * Remove intermediate image files that are kept in temporary storage after calling camera.getPicture.
44 * Applies only when the value of Camera.sourceType equals Camera.PictureSourceType.CAMERA and the Camera.destinationType equals Camera.DestinationType.FILE_URI.
45 * @returns {Promise<any>}
46 */
47 Camera.cleanup = function () { return; };
48 ;
49 /**
50 * @private
51 * @enum {number}
52 */
53 Camera.DestinationType = {
54 /** 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 */
55 DATA_URL: 0,
56 /** Return file uri (content://media/external/images/media/2 for Android) */
57 FILE_URI: 1,
58 /** Return native uri (eg. asset-library://... for iOS) */
59 NATIVE_URI: 2
60 };
61 /**
62 * @private
63 * @enum {number}
64 */
65 Camera.EncodingType = {
66 /** Return JPEG encoded image */
67 JPEG: 0,
68 /** Return PNG encoded image */
69 PNG: 1
70 };
71 /**
72 * @private
73 * @enum {number}
74 */
75 Camera.MediaType = {
76 /** Allow selection of still pictures only. DEFAULT. Will return format specified via DestinationType */
77 PICTURE: 0,
78 /** Allow selection of video only, ONLY RETURNS URL */
79 VIDEO: 1,
80 /** Allow selection from all media types */
81 ALLMEDIA: 2
82 };
83 /**
84 * @private
85 * @enum {number}
86 */
87 Camera.PictureSourceType = {
88 /** Choose image from picture library (same as SAVEDPHOTOALBUM for Android) */
89 PHOTOLIBRARY: 0,
90 /** Take picture from camera */
91 CAMERA: 1,
92 /** Choose image from picture library (same as PHOTOLIBRARY for Android) */
93 SAVEDPHOTOALBUM: 2
94 };
95 /**
96 * @private
97 * Matches iOS UIPopoverArrowDirection constants to specify arrow location on popover.
98 * @enum {number}
99 */
100 Camera.PopoverArrowDirection = {
101 ARROW_UP: 1,
102 ARROW_DOWN: 2,
103 ARROW_LEFT: 4,
104 ARROW_RIGHT: 8,
105 ARROW_ANY: 15
106 };
107 /**
108 * @private
109 * @enum {number}
110 */
111 Camera.Direction = {
112 /** Use the back-facing camera */
113 BACK: 0,
114 /** Use the front-facing camera */
115 FRONT: 1
116 };
117 __decorate([
118 plugin_1.Cordova({
119 callbackOrder: 'reverse'
120 })
121 ], Camera, "getPicture", null);
122 __decorate([
123 plugin_1.Cordova({
124 platforms: ['iOS']
125 })
126 ], Camera, "cleanup", null);
127 Camera = __decorate([
128 plugin_1.Plugin({
129 pluginName: 'Camera',
130 plugin: 'cordova-plugin-camera',
131 pluginRef: 'navigator.camera',
132 repo: 'https://github.com/apache/cordova-plugin-camera',
133 platforms: ['Android', 'BlackBerry', 'Browser', 'Firefox', 'FireOS', 'iOS', 'Windows', 'Windows Phone 8', 'Ubuntu']
134 })
135 ], Camera);
136 return Camera;
137}());
138exports.Camera = Camera;
139//# sourceMappingURL=camera.js.map
\No newline at end of file