2016-07-20 23:17:09 +08:00
|
|
|
import { Cordova, Plugin } from './plugin';
|
|
|
|
import { Observable } from 'rxjs/Observable';
|
|
|
|
|
2016-07-17 16:50:18 +08:00
|
|
|
|
2016-08-19 21:10:05 +08:00
|
|
|
export interface CameraPreviewRect {
|
2016-07-20 23:17:09 +08:00
|
|
|
x: number;
|
|
|
|
y: number;
|
|
|
|
width: number;
|
|
|
|
height: number;
|
2016-07-17 16:50:18 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface CameraPreviewSize {
|
2016-07-20 23:17:09 +08:00
|
|
|
maxWidth: number;
|
|
|
|
maxHeight: number;
|
2016-07-17 16:50:18 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @name CameraPreview
|
|
|
|
* @description
|
|
|
|
* Showing camera preview in HTML
|
|
|
|
*
|
2016-08-02 02:46:52 +08:00
|
|
|
* For more info, please see the [Cordova Camera Preview Plugin Docs](https://github.com/cordova-plugin-camera-preview/cordova-plugin-camera-preview).
|
2016-07-17 16:50:18 +08:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
@Plugin({
|
|
|
|
plugin: 'cordova-plugin-camera-preview',
|
|
|
|
pluginRef: 'cordova.plugins.camerapreview',
|
2016-07-23 02:08:11 +08:00
|
|
|
repo: 'https://github.com/cordova-plugin-camera-preview/cordova-plugin-camera-preview',
|
2016-07-17 16:50:18 +08:00
|
|
|
platforms: ['Android', 'iOS']
|
|
|
|
})
|
|
|
|
export class CameraPreview {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Starts the camera preview instance.
|
2016-08-19 21:10:05 +08:00
|
|
|
* @param {CameraPreviewRect} position and size of the preview window - {x: number, y: number, width: number, height: number}
|
|
|
|
* @param {string} which camera to use - 'front' | 'back'
|
|
|
|
* @param {boolean} enable tap to take picture
|
|
|
|
* @param {boolean} enable preview box drag across the screen
|
|
|
|
* @param {boolean} send preview box to the back of the webview
|
|
|
|
* @param {number} alpha of the preview box
|
2016-07-17 16:50:18 +08:00
|
|
|
*/
|
|
|
|
@Cordova({
|
|
|
|
sync: true
|
|
|
|
})
|
2016-08-23 06:19:43 +08:00
|
|
|
static startCamera(rect: CameraPreviewRect, defaultCamera: string, tapEnabled: boolean, dragEnabled: boolean, toBack: boolean, alpha: number): void {
|
2016-08-19 21:10:05 +08:00
|
|
|
|
|
|
|
};
|
2016-07-17 16:50:18 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Stops the camera preview instance.
|
|
|
|
*/
|
|
|
|
@Cordova({
|
|
|
|
sync: true
|
|
|
|
})
|
2016-07-20 23:17:09 +08:00
|
|
|
static stopCamera(): void { };
|
2016-07-17 16:50:18 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Take the picture, the parameter size is optional
|
2016-08-19 21:10:05 +08:00
|
|
|
* @param {CameraPreviewSize} optional - size of the picture to take
|
2016-07-17 16:50:18 +08:00
|
|
|
*/
|
|
|
|
@Cordova({
|
|
|
|
sync: true
|
|
|
|
})
|
2016-07-20 23:17:09 +08:00
|
|
|
static takePicture(size: CameraPreviewSize): void { };
|
2016-07-17 16:50:18 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Register a callback function that receives the original picture and the image captured from the preview box.
|
|
|
|
*/
|
|
|
|
@Cordova({
|
|
|
|
observable: true
|
|
|
|
})
|
|
|
|
static setOnPictureTakenHandler(): Observable<any> { return; };
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Switch from the rear camera and front camera, if available.
|
|
|
|
*/
|
|
|
|
@Cordova({
|
|
|
|
sync: true
|
|
|
|
})
|
2016-07-20 23:17:09 +08:00
|
|
|
static switchCamera(): void { };
|
2016-07-17 16:50:18 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Show the camera preview box.
|
|
|
|
*/
|
|
|
|
@Cordova({
|
|
|
|
sync: true
|
|
|
|
})
|
2016-07-20 23:17:09 +08:00
|
|
|
static show(): void { };
|
2016-07-17 16:50:18 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Hide the camera preview box.
|
|
|
|
*/
|
|
|
|
@Cordova({
|
|
|
|
sync: true
|
|
|
|
})
|
2016-07-22 00:40:51 +08:00
|
|
|
static hide(): void { };
|
2016-07-17 16:50:18 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the default mode for the Flash.
|
|
|
|
*/
|
2016-07-23 02:08:11 +08:00
|
|
|
// @Cordova({
|
|
|
|
// sync: true
|
|
|
|
// })
|
|
|
|
// static setFlashMode(mode: number): void { };
|
2016-07-17 16:50:18 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set camera color effect.
|
|
|
|
*/
|
|
|
|
@Cordova({
|
|
|
|
sync: true
|
|
|
|
})
|
2016-07-20 23:17:09 +08:00
|
|
|
static setColorEffect(effect: string): void { };
|
2016-07-17 16:50:18 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
* @enum {number}
|
|
|
|
*/
|
|
|
|
static FlashMode = {
|
|
|
|
OFF: 0,
|
|
|
|
ON: 1,
|
|
|
|
AUTO: 2
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|