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
|
|
|
|
|
|
|
export interface CameraPreviewOptions {
|
2016-07-20 23:17:09 +08:00
|
|
|
x: number;
|
|
|
|
y: number;
|
|
|
|
width: number;
|
|
|
|
height: number;
|
|
|
|
/**
|
|
|
|
* Choose the camera to use (front- or back-facing).
|
|
|
|
* 'front' for front camera
|
|
|
|
* 'rear' for rear camera
|
|
|
|
*/
|
|
|
|
camera: string;
|
|
|
|
/** Take photo on tap */
|
|
|
|
tapPhoto: boolean;
|
|
|
|
/** */
|
|
|
|
previewDrag: boolean;
|
|
|
|
/** */
|
|
|
|
toBack: boolean;
|
|
|
|
/** Alpha use when toBack is set to true */
|
|
|
|
alpha: 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.
|
|
|
|
* @param {CameraPreviewOptions} options for the preview
|
|
|
|
*/
|
|
|
|
@Cordova({
|
|
|
|
sync: true
|
|
|
|
})
|
2016-07-20 23:17:09 +08:00
|
|
|
static startCamera(options: CameraPreviewOptions): void { };
|
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
|
|
|
|
*/
|
|
|
|
@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
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|