|
| 1 | +import { Injectable } from '@angular/core'; |
| 2 | +import { Cordova, IonicNativePlugin, Plugin } from '@ionic-native/core'; |
| 3 | +import { Observable } from 'rxjs/Observable'; |
| 4 | + |
| 5 | +export interface LastCamStartupOptions { |
| 6 | + /** The left edge in pixels, default 0 */ |
| 7 | + x?: number; |
| 8 | + |
| 9 | + /** The top edge in pixels, default 0 */ |
| 10 | + y?: number; |
| 11 | + |
| 12 | + /** The width in pixels, default window.screen.width */ |
| 13 | + width?: number; |
| 14 | + |
| 15 | + /** The height in pixels, default window.screen.height */ |
| 16 | + height?: number; |
| 17 | + |
| 18 | + /** Choose the camera to use 'front' or 'back', default 'front' */ |
| 19 | + camera?: string; |
| 20 | +} |
| 21 | + |
| 22 | +/** |
| 23 | + * @name LastCam |
| 24 | + * @description |
| 25 | + * Last Cam is a Camera Preview plugin that allows you to take capture both Videos and images in a |
| 26 | + * custom html preview of your choice. |
| 27 | + * |
| 28 | + * @interfaces |
| 29 | + * LastCamStartupOptions |
| 30 | + */ |
| 31 | +@Plugin({ |
| 32 | + pluginName: 'LastCam', |
| 33 | + plugin: 'cordova-plugin-last-cam', |
| 34 | + pluginRef: 'LastCam', |
| 35 | + repo: 'https://github.com/bengejd/cordova-plugin-last-cam', |
| 36 | + platforms: ['iOS'] |
| 37 | +}) |
| 38 | +@Injectable() |
| 39 | +export class LastCam extends IonicNativePlugin { |
| 40 | + /** |
| 41 | + * Starts the camera preview instance. |
| 42 | + * @param {LastCamStartupOptions} options |
| 43 | + * @return {Promise<any>} |
| 44 | + */ |
| 45 | + @Cordova({ |
| 46 | + successIndex: 1, |
| 47 | + errorIndex: 2 |
| 48 | + }) |
| 49 | + startCamera(options: LastCamStartupOptions): Promise<any> { |
| 50 | + return; |
| 51 | + } |
| 52 | + |
| 53 | + /** |
| 54 | + * Stops the camera preview instance. (iOS) |
| 55 | + * @return {Promise<any>} |
| 56 | + */ |
| 57 | + @Cordova() |
| 58 | + stopCamera(): Promise<any> { |
| 59 | + return; |
| 60 | + } |
| 61 | + |
| 62 | + /** |
| 63 | + * Switch from the rear camera and front camera, if available. |
| 64 | + * @return {Promise<any>} |
| 65 | + */ |
| 66 | + @Cordova() |
| 67 | + switchCamera(): Promise<any> { |
| 68 | + return; |
| 69 | + } |
| 70 | + |
| 71 | + /** |
| 72 | + * Switch the flash mode. |
| 73 | + * @return {Promise<any>} |
| 74 | + */ |
| 75 | + @Cordova() |
| 76 | + switchFlash(): Promise<any> { |
| 77 | + return; |
| 78 | + } |
| 79 | + |
| 80 | + /** |
| 81 | + * Take the picture (base64) |
| 82 | + * @return {Promise<any>} |
| 83 | + */ |
| 84 | + @Cordova({ |
| 85 | + successIndex: 0, |
| 86 | + errorIndex: 1 |
| 87 | + }) |
| 88 | + takePicture(): Promise<any> { |
| 89 | + return; |
| 90 | + } |
| 91 | + |
| 92 | + /** |
| 93 | + * Start the video capture |
| 94 | + * @return {Promise<any>} |
| 95 | + */ |
| 96 | + @Cordova() |
| 97 | + startVideoCapture(): Promise<any> { |
| 98 | + return; |
| 99 | + } |
| 100 | + |
| 101 | + /** |
| 102 | + * Stops the video capture |
| 103 | + * @return {Promise<any>} |
| 104 | + */ |
| 105 | + @Cordova({ |
| 106 | + successIndex: 0, |
| 107 | + errorIndex: 1 |
| 108 | + }) |
| 109 | + stopVideoCapture(): Promise<any> { |
| 110 | + return; |
| 111 | + } |
| 112 | + |
| 113 | + /** |
| 114 | + * Promise of the recordingTimer. |
| 115 | + * @return {Promise<any>} |
| 116 | + */ |
| 117 | + @Cordova({ |
| 118 | + successIndex: 0, |
| 119 | + errorIndex: 1 |
| 120 | + }) |
| 121 | + recordingTimer(): Promise<any> { |
| 122 | + return; |
| 123 | + } |
| 124 | + |
| 125 | + /** |
| 126 | + * Observable of the recordingTimer. |
| 127 | + * @return {Observable<any>} |
| 128 | + */ |
| 129 | + @Cordova({ |
| 130 | + successIndex: 0, |
| 131 | + errorIndex: 1, |
| 132 | + observable: true |
| 133 | + }) |
| 134 | + watchRecordingTimer(): Observable<any> { |
| 135 | + return; |
| 136 | + } |
| 137 | +} |
0 commit comments