mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-19 03:32:21 +08:00
Camera docs
This commit is contained in:
@ -2,6 +2,21 @@ import * as util from 'ionic/util';
|
|||||||
|
|
||||||
import {NativePlugin} from '../plugin';
|
import {NativePlugin} from '../plugin';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Take a photo or capture video.
|
||||||
|
*
|
||||||
|
* Requires Cordova plugin: `cordova-plugin-camera`. For more info, please see the [Cordova Camera Plugin Docs](https://github.com/apache/cordova-plugin-camera).
|
||||||
|
*
|
||||||
|
* @usage
|
||||||
|
* ```js
|
||||||
|
* 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) => {
|
||||||
|
* });
|
||||||
|
* ```
|
||||||
|
*/
|
||||||
@NativePlugin({
|
@NativePlugin({
|
||||||
name: 'Camera',
|
name: 'Camera',
|
||||||
platforms: ['ios', 'android'],
|
platforms: ['ios', 'android'],
|
||||||
@ -13,6 +28,21 @@ import {NativePlugin} from '../plugin';
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
export class Camera {
|
export class Camera {
|
||||||
|
/**
|
||||||
|
* Let the user take a photo or capture video.
|
||||||
|
*
|
||||||
|
* @param options {object} options for the photo. Of the form (with defaults):
|
||||||
|
* {
|
||||||
|
* quality: 80,
|
||||||
|
* destinationType: window.Camera.DestinationType.DATA_URL,
|
||||||
|
* sourceType: window.Camera.PictureSourceType.CAMERA (VIDEO or ALLMEDIA for both),
|
||||||
|
* allowEdit: true,
|
||||||
|
* encodingType: window.Camera.EncodingType.JPEG,
|
||||||
|
* popoverOptions: window.CameraPopoverOptions,
|
||||||
|
* saveToPhotoAlbum: false
|
||||||
|
* }
|
||||||
|
* @return {Promise} resolving with data or rejecting on error
|
||||||
|
*/
|
||||||
static getPicture(options) {
|
static getPicture(options) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
if (!navigator.camera) {
|
if (!navigator.camera) {
|
||||||
@ -38,6 +68,12 @@ export class Camera {
|
|||||||
}, options);
|
}, options);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If using FILE_URI and taking photos, photos will be stored temporarily. To
|
||||||
|
* remove them, call cleanup when the camera session is finished.
|
||||||
|
* @return {Promise}
|
||||||
|
*/
|
||||||
static cleanup() {
|
static cleanup() {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
navigator.camera.cleanup(function () {
|
navigator.camera.cleanup(function () {
|
||||||
|
Reference in New Issue
Block a user