js-apis-camera.md 82.1 KB
Newer Older
W
wusongqing 已提交
1
# Camera Management
N
nikhilraut 已提交
2

W
wusongqing 已提交
3
> **NOTE**<br/>
4
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
W
wusongqing 已提交
5

N
nikhilraut 已提交
6 7 8 9 10 11 12 13 14 15
## Modules to Import

```
import camera from '@ohos.multimedia.camera';
```

## Required Permissions

ohos.permission.CAMERA

W
wusongqing 已提交
16
## camera.getCameraManager
N
nikhilraut 已提交
17

W
wusongqing 已提交
18
getCameraManager(context: Context, callback: AsyncCallback<CameraManager\>): void
N
nikhilraut 已提交
19

W
wusongqing 已提交
20
Obtains a **CameraManager** instance. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
21

W
wusongqing 已提交
22
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
23 24 25

**Parameters**

W
wusongqing 已提交
26 27 28 29
| Name    | Type                                           | Mandatory| Description                              |
| -------- | ----------------------------------------------- | ---- | ---------------------------------- |
| context  | Context                                         | Yes  | Application context.                      |
| callback | AsyncCallback<[CameraManager](#cameramanager)\> | Yes  | Callback used to return the **CameraManager** instance.|
N
nikhilraut 已提交
30 31 32 33 34 35 36 37 38 39 40 41 42

**Example**

```
camera.getCameraManager(context, (err, cameraManager) => {
    if (err) {
        console.error('Failed to get the CameraManager instance ${err.message}');
        return;
    }
    console.log('Callback returned with the CameraManager instance');
});
```

W
wusongqing 已提交
43
## camera.getCameraManager
N
nikhilraut 已提交
44

W
wusongqing 已提交
45
getCameraManager(context: Context): Promise<CameraManager\>
N
nikhilraut 已提交
46

W
wusongqing 已提交
47
Obtains a **CameraManager** instance. This API uses a promise to return the result.
N
nikhilraut 已提交
48

W
wusongqing 已提交
49
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
50 51 52

**Parameters**

W
wusongqing 已提交
53 54 55
| Name   | Type   | Mandatory| Description        |
| ------- | ------- | ---- | ------------ |
| context | Context | Yes  | Application context.|
N
nikhilraut 已提交
56

W
wusongqing 已提交
57
**Return value**
N
nikhilraut 已提交
58

W
wusongqing 已提交
59 60 61
| Type                                     | Description                                     |
| ----------------------------------------- | ----------------------------------------- |
| Promise<[CameraManager](#cameramanager)\> | Promise used to return the **CameraManager** instance.|
N
nikhilraut 已提交
62 63 64 65

**Example**

```
W
wusongqing 已提交
66
camera.getCameraManager(context).then((cameraManager) => {
N
nikhilraut 已提交
67 68 69 70
    console.log('Promise returned with the CameraManager instance.');
})
```

W
wusongqing 已提交
71
## CameraStatus
N
nikhilraut 已提交
72

W
wusongqing 已提交
73
Enumerates the camera statuses.
N
nikhilraut 已提交
74

W
wusongqing 已提交
75
**System capability**: SystemCapability.Multimedia.Camera.Core
76

W
wusongqing 已提交
77 78 79 80 81 82
| Name                     | Default Value| Description        |
| ------------------------- | ------ | ------------ |
| CAMERA_STATUS_APPEAR      | 0      | The camera exists.  |
| CAMERA_STATUS_DISAPPEAR   | 1      | The camera does not exist.|
| CAMERA_STATUS_AVAILABLE   | 2      | The camera is ready.  |
| CAMERA_STATUS_UNAVAILABLE | 3      | The camera is not ready.|
83

N
nikhilraut 已提交
84

W
wusongqing 已提交
85
## CameraPosition
N
nikhilraut 已提交
86 87 88

Enumerates the camera positions.

W
wusongqing 已提交
89
**System capability**: SystemCapability.Multimedia.Camera.Core
90

W
wusongqing 已提交
91 92 93 94 95
| Name                       | Default Value| Description            |
| --------------------------- | ------ | ---------------- |
| CAMERA_POSITION_UNSPECIFIED | 0      | Unspecified position.|
| CAMERA_POSITION_BACK        | 1      | Rear camera.      |
| CAMERA_POSITION_FRONT       | 2      | Front camera.      |
N
nikhilraut 已提交
96

W
wusongqing 已提交
97
## CameraType
N
nikhilraut 已提交
98 99 100

Enumerates the camera types.

W
wusongqing 已提交
101
**System capability**: SystemCapability.Multimedia.Camera.Core
102

W
wusongqing 已提交
103 104 105 106 107 108 109
| Name                   | Default Value| Description            |
| ----------------------- | ------ | ---------------- |
| CAMERA_TYPE_UNSPECIFIED | 0      | Unspecified camera type.|
| CAMERA_TYPE_WIDE_ANGLE  | 1      | Wide camera.      |
| CAMERA_TYPE_ULTRA_WIDE  | 2      | Ultra wide camera.  |
| CAMERA_TYPE_TELEPHOTO   | 3      | Telephoto camera.      |
| CAMERA_TYPE_TRUE_DEPTH  | 4      | True depth camera.      |
110

N
nikhilraut 已提交
111

W
wusongqing 已提交
112
## ConnectionType
N
nikhilraut 已提交
113

W
wusongqing 已提交
114
Enumerates the camera connection types.
N
nikhilraut 已提交
115

W
wusongqing 已提交
116
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
117

W
wusongqing 已提交
118 119 120 121 122
| Name                        | Default Value| Description         |
| ---------------------------- | ------ | ------------- |
| CAMERA_CONNECTION_BUILT_IN   | 0      | Built-in camera.   |
| CAMERA_CONNECTION_USB_PLUGIN | 1      | Camera connected using USB.|
| CAMERA_CONNECTION_REMOTE     | 2      | Remote camera. |
N
nikhilraut 已提交
123 124


W
wusongqing 已提交
125
## CameraManager
N
nikhilraut 已提交
126

W
wusongqing 已提交
127
Implements camera management. Before calling any API in **CameraManager**, you must use **getCameraManager** to obtain a **CameraManager** instance.
N
nikhilraut 已提交
128

W
wusongqing 已提交
129
### getCameras
N
nikhilraut 已提交
130

W
wusongqing 已提交
131
getCameras(callback: AsyncCallback<Array<Camera\>\>): void
N
nikhilraut 已提交
132

W
wusongqing 已提交
133
Obtains all cameras supported by the device. This API uses an asynchronous callback to return the array of supported cameras.
N
nikhilraut 已提交
134

W
wusongqing 已提交
135
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
136 137 138

**Parameters**

W
wusongqing 已提交
139 140 141
| Name    | Type                                     | Mandatory| Description                                |
| -------- | ----------------------------------------- | ---- | ------------------------------------ |
| callback | AsyncCallback<Array<[Camera](#camera)\>\> | Yes  | Callback used to return the array of supported cameras.|
N
nikhilraut 已提交
142 143 144 145 146 147 148 149 150 151 152 153 154

**Example**

```
cameraManager.getCameras((err, cameras) => {
    if (err) {
        console.error('Failed to get the cameras. ${err.message}');
        return;
    }
    console.log('Callback returned with an array of supported cameras: ' + cameras.length);
})
```

W
wusongqing 已提交
155
### getCameras
N
nikhilraut 已提交
156

W
wusongqing 已提交
157
getCameras(): Promise<Array<Camera\>\>
N
nikhilraut 已提交
158

W
wusongqing 已提交
159
Obtains all cameras supported by the device. This API uses a promise to return the array of supported cameras.
N
nikhilraut 已提交
160

W
wusongqing 已提交
161
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
162

W
wusongqing 已提交
163
**Return value**
N
nikhilraut 已提交
164

W
wusongqing 已提交
165 166 167
| Type                               | Description                         |
| ----------------------------------- | ----------------------------- |
| Promise<Array<[Camera](#camera)\>\> | Promise used to return the array of supported cameras.|
N
nikhilraut 已提交
168 169 170 171 172 173 174 175 176 177


**Example**

```
cameraManager.getCameras().then((cameraArray) => {
    console.log('Promise returned with an array of supported cameras: ' + cameraArray.length);
})
```

W
wusongqing 已提交
178
### createCameraInput
N
nikhilraut 已提交
179

W
wusongqing 已提交
180
createCameraInput(cameraId: string, callback: AsyncCallback<CameraInput\>): void
N
nikhilraut 已提交
181

W
wusongqing 已提交
182
Creates a **CameraInput** instance with the specified camera ID. This API uses an asynchronous callback to return the instance.
N
nikhilraut 已提交
183

W
wusongqing 已提交
184
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
185 186 187

**Parameters**

W
wusongqing 已提交
188 189 190 191
| Name    | Default Value                                     | Mandatory| Description                               |
| -------- | ------------------------------------------- | ---- | ----------------------------------- |
| cameraId | string                                      | Yes  | Camera ID used to create the instance.                       |
| callback | AsyncCallback<[CameraInput](#camerainput)\> | Yes  | Callback used to return the **CameraInput** instance.|
N
nikhilraut 已提交
192 193 194 195 196 197 198 199 200 201 202 203 204

**Example**

```
cameraManager.createCameraInput(cameraId, (err, cameraInput) => {
    if (err) {
        console.error('Failed to create the CameraInput instance. ${err.message}');
        return;
    }
    console.log('Callback returned with the CameraInput instance.');
})
```

W
wusongqing 已提交
205
### createCameraInput
N
nikhilraut 已提交
206

W
wusongqing 已提交
207
createCameraInput(cameraId: string): Promise<CameraInput\>
N
nikhilraut 已提交
208

W
wusongqing 已提交
209
Creates a **CameraInput** instance with the specified camera ID. This API uses a promise to return the instance.
N
nikhilraut 已提交
210

W
wusongqing 已提交
211
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
212 213 214

**Parameters**

W
wusongqing 已提交
215 216 217
| Name    | Default Value| Mandatory| Description        |
| -------- | ------ | ---- | ------------ |
| cameraId | string | Yes  | Camera ID used to create the instance.|
N
nikhilraut 已提交
218

W
wusongqing 已提交
219
**Return value**
N
nikhilraut 已提交
220

W
wusongqing 已提交
221 222 223
| Type                                 | Description                                    |
| ------------------------------------- | ---------------------------------------- |
| Promise<[CameraInput](#camerainput)\> | Promise used to return the **CameraInput** instance.|
N
nikhilraut 已提交
224 225 226 227 228 229 230 231 232

**Example**

```
cameraManager.createCameraInput(cameraId).then((cameraInput) => {
    console.log('Promise returned with the CameraInput instance');
})
```

W
wusongqing 已提交
233
### createCameraInput
N
nikhilraut 已提交
234

W
wusongqing 已提交
235
createCameraInput(position: CameraPosition, type: CameraType, callback: AsyncCallback<CameraInput\>): void
N
nikhilraut 已提交
236

W
wusongqing 已提交
237
Creates a **CameraInput** instance with the specified camera position and camera type. This API uses an asynchronous callback to return the instance.
N
nikhilraut 已提交
238

W
wusongqing 已提交
239
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
240 241 242

**Parameters**

W
wusongqing 已提交
243 244 245 246 247
| Name    | Type                                       | Mandatory| Description                               |
| -------- | ------------------------------------------- | ---- | ----------------------------------- |
| position | [CameraPosition](#cameraposition)           | Yes  | Camera position.                         |
| type     | [CameraType](#cameratype)                   | Yes  | Camera type.                         |
| callback | AsyncCallback<[CameraInput](#camerainput)\> | Yes  | Callback used to return the **CameraInput** instance.|
N
nikhilraut 已提交
248 249 250 251 252 253 254 255 256 257 258 259 260

**Example**

```
cameraManager.createCameraInput(cameraPosition, cameraType, (err, cameraInput) => {
    if (err) {
        console.error('Failed to create the CameraInput instance. ${err.message}');
        return;
    }
    console.log('Callback returned with the CameraInput instance');
})
```

W
wusongqing 已提交
261
### createCameraInput
N
nikhilraut 已提交
262

W
wusongqing 已提交
263
createCameraInput(position: CameraPosition, type: CameraType): Promise<CameraInput\>
N
nikhilraut 已提交
264

W
wusongqing 已提交
265
Creates a **CameraInput** instance with the specified camera position and camera type. This API uses a promise to return the instance.
N
nikhilraut 已提交
266

W
wusongqing 已提交
267
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
268 269 270

**Parameters**

W
wusongqing 已提交
271 272 273 274
| Name    | Type                             | Mandatory| Description      |
| -------- | --------------------------------- | ---- | ---------- |
| position | [CameraPosition](#cameraposition) | Yes  | Camera position.|
| type     | [CameraType](#cameratype)         | Yes  | Camera type.|
N
nikhilraut 已提交
275

W
wusongqing 已提交
276
**Return value**
N
nikhilraut 已提交
277

W
wusongqing 已提交
278 279 280
| Type                                 | Description                                    |
| ------------------------------------- | ---------------------------------------- |
| Promise<[CameraInput](#camerainput)\> | Promise used to return the **CameraInput** instance.|
N
nikhilraut 已提交
281 282 283 284 285 286 287 288 289

**Example**

```
cameraManager.createCameraInput(cameraPosition, cameraType).then((cameraInput) => {
    console.log('Promise returned with the CameraInput instance.');
})
```

W
wusongqing 已提交
290
### on('cameraStatus')
N
nikhilraut 已提交
291

W
wusongqing 已提交
292
on(type: 'cameraStatus', callback: AsyncCallback<CameraStatusInfo\>): void
N
nikhilraut 已提交
293

W
wusongqing 已提交
294
Listens for camera status changes. This API uses a callback to return the camera status changes.
N
nikhilraut 已提交
295

W
wusongqing 已提交
296
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
297 298 299

**Parameters**

W
wusongqing 已提交
300 301 302 303
| Name    | Type                                                 | Mandatory| Description                                                |
| :------- | :---------------------------------------------------- | :--- | :--------------------------------------------------- |
| type     | string                                                | Yes  | Type of event to listen for. The value is fixed at **cameraStatus**, indicating the camera status change event.|
| callback | AsyncCallback<[CameraStatusInfo](#camerastatusinfo)\> | Yes  | Callback used to return the camera status change.                |
N
nikhilraut 已提交
304 305 306 307 308 309 310 311 312 313

**Example**

```
cameraManager.on('cameraStatus', (cameraStatusInfo) => {
    console.log('camera : ' + cameraStatusInfo.camera.cameraId);
    console.log('status: ' + cameraStatusInfo.status);
})
```

W
wusongqing 已提交
314
## Camera
315

W
wusongqing 已提交
316
After **[camera.getCameraManager](#cameragetcameramanager)** is called, a camera instance is returned, including camera-related metadata such as **cameraId**, **cameraPosition**, **cameraType**, and **connectionType**.
317

W
wusongqing 已提交
318
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
319

W
wusongqing 已提交
320 321 322 323 324 325
| Name          | Type                             | Read only| Description          |
| -------------- | --------------------------------- | ---- | -------------- |
| cameraId       | string                            | Yes  | Camera ID.      |
| cameraPosition | [CameraPosition](#cameraposition) | Yes  | Camera position.    |
| cameraType     | [CameraType](#cameratype)         | Yes  | Camera type.    |
| connectionType | [ConnectionType](#connectiontype) | Yes  | Camera connection type.|
N
nikhilraut 已提交
326

W
wusongqing 已提交
327
**Example**
N
nikhilraut 已提交
328 329

```
330 331 332 333 334 335 336 337 338
async function getCameraInfo() {
    var cameraManager = await camera.getCameraManager();
    var cameras = await cameraManager.getCameras();
    var cameraObj = cameras[0];
    var cameraId = cameraObj.cameraId;
    var cameraPosition = cameraObj.cameraPosition;
    var cameraType = cameraObj.cameraType;
    var cameraId = cameraObj.connectionType;
}
N
nikhilraut 已提交
339 340 341

```

W
wusongqing 已提交
342
## CameraStatusInfo
N
nikhilraut 已提交
343

W
wusongqing 已提交
344
Describes the camera status information.
N
nikhilraut 已提交
345

W
wusongqing 已提交
346
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
347

W
wusongqing 已提交
348 349 350 351
| Name  | Type                         | Description      |
| ------ | ----------------------------- | ---------- |
| camera | [Camera](#camera)             | Camera object.|
| status | [CameraStatus](#camerastatus) | Camera status.|
N
nikhilraut 已提交
352

N
nikhilraut 已提交
353

W
wusongqing 已提交
354
## CameraInput
N
nikhilraut 已提交
355

W
wusongqing 已提交
356
Implements a **CameraInput** instance. Before calling any API in **CameraInput**, you must create a **CameraInput** instance.
N
nikhilraut 已提交
357

W
wusongqing 已提交
358
### getCameraId
N
nikhilraut 已提交
359

W
wusongqing 已提交
360
getCameraId(callback: AsyncCallback<string\>\): void
N
nikhilraut 已提交
361

W
wusongqing 已提交
362
Obtains the camera ID based on which this **CameraInput** instance is created. This API uses an asynchronous callback to return the camera ID.
N
nikhilraut 已提交
363

W
wusongqing 已提交
364
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
365 366 367

**Parameters**

W
wusongqing 已提交
368 369 370 371 372
| Name    | Type                  | Mandatory| Description                      |
| -------- | ---------------------- | ---- | -------------------------- |
| callback | AsyncCallback<string\> | Yes  | Callback used to return the camera ID.|

**Example**
N
nikhilraut 已提交
373 374 375 376 377 378 379 380 381 382 383

```
cameraInput.getCameraId((err, cameraId) => {
    if (err) {
        console.error('Failed to get the camera ID. ${err.message}');
        return;
    }
    console.log('Callback returned with the camera ID: ' + cameraId);
})
```

W
wusongqing 已提交
384
### getCameraId
N
nikhilraut 已提交
385

W
wusongqing 已提交
386
getCameraId(): Promise<string\>
N
nikhilraut 已提交
387

W
wusongqing 已提交
388
Obtains the camera ID based on which this **CameraInput** instance is created. This API uses a promise to return the camera ID.
N
nikhilraut 已提交
389

W
wusongqing 已提交
390
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
391

W
wusongqing 已提交
392
**Return value**
N
nikhilraut 已提交
393

W
wusongqing 已提交
394 395 396
| Type            | Description                         |
| ---------------- | ----------------------------- |
| Promise<string\> | Promise used to return the camera ID.|
N
nikhilraut 已提交
397 398 399 400 401 402 403 404 405 406

**Example**

```
cameraInput.getCameraId().then((cameraId) => {
    console.log('Promise returned with the camera ID:' + cameraId);
})
```


W
wusongqing 已提交
407
### hasFlash
N
nikhilraut 已提交
408

W
wusongqing 已提交
409
hasFlash(callback: AsyncCallback<boolean\>): void
N
nikhilraut 已提交
410

W
wusongqing 已提交
411
Checks whether the device has flash light. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
412

W
wusongqing 已提交
413
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
414 415 416

**Parameters**

W
wusongqing 已提交
417 418 419
| Name    | Type                   | Mandatory| Description                                  |
| -------- | ----------------------- | ---- | -------------------------------------- |
| callback | AsyncCallback<boolean\> | Yes  | Callback used to return the flash light support status. The value **true** means that the device has flash light.|
N
nikhilraut 已提交
420 421 422 423 424 425 426 427 428 429 430 431 432

**Example**

```
cameraInput.hasFlash((err, status) => {
    if (err) {
        console.error('Failed to check whether the device has flash light. ${err.message}');
        return;
    }
    console.log('Callback returned with flash light support status: ' + status);
})
```

W
wusongqing 已提交
433
### hasFlash
N
nikhilraut 已提交
434

W
wusongqing 已提交
435
hasFlash(): Promise<boolean\>
N
nikhilraut 已提交
436

W
wusongqing 已提交
437
Checks whether the device has flash light. This API uses a promise to return the result.
N
nikhilraut 已提交
438

W
wusongqing 已提交
439
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
440

W
wusongqing 已提交
441
**Return value**
N
nikhilraut 已提交
442

W
wusongqing 已提交
443 444 445
| Type             | Description                                                   |
| ----------------- | ------------------------------------------------------- |
| Promise<boolean\> | Promise used to return the flash light support status. The value **true** means that the device has flash light.|
N
nikhilraut 已提交
446 447 448 449 450 451 452 453 454

**Example**

```
cameraInput.hasFlash().then((status) => {
    console.log('Promise returned with the flash light support status:' + status);
})
```

W
wusongqing 已提交
455
### isFlashModeSupported
N
nikhilraut 已提交
456

W
wusongqing 已提交
457
isFlashModeSupported(flashMode: FlashMode, callback: AsyncCallback<boolean\>): void
N
nikhilraut 已提交
458

W
wusongqing 已提交
459
Checks whether a specified flash mode is supported. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
460

W
wusongqing 已提交
461
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
462 463 464

**Parameters**

W
wusongqing 已提交
465 466 467 468
| Name     | Type                   | Mandatory| Description                                    |
| --------- | ----------------------- | ---- | ---------------------------------------- |
| flashMode | [FlashMode](#flashmode) | Yes  | Flash mode.                        |
| callback  | AsyncCallback<boolean\> | Yes  | Callback used to return the flash mode support status. The value **true** means that the specified flash mode is supported.|
N
nikhilraut 已提交
469 470 471 472 473 474 475 476 477 478 479 480 481

**Example**

```
cameraInput.isFlashModeSupported(flashMode, (err, status) => {
    if (err) {
        console.error('Failed to check whether the flash mode is supported. ${err.message}');
        return;
    }
    console.log('Callback returned with the flash mode support status: ' + status);
})
```

W
wusongqing 已提交
482
### isFlashModeSupported
N
nikhilraut 已提交
483

W
wusongqing 已提交
484
isFlashModeSupported(flashMode: FlashMode): Promise<boolean\>
N
nikhilraut 已提交
485

W
wusongqing 已提交
486
Checks whether a specified flash mode is supported. This API uses a promise to return the result.
N
nikhilraut 已提交
487

W
wusongqing 已提交
488
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
489 490 491

**Parameters**

W
wusongqing 已提交
492 493 494
| Name     | Type                   | Mandatory| Description            |
| --------- | ----------------------- | ---- | ---------------- |
| flashMode | [FlashMode](#flashmode) | Yes  | Flash mode.|
N
nikhilraut 已提交
495

W
wusongqing 已提交
496
**Return value**
N
nikhilraut 已提交
497

W
wusongqing 已提交
498 499 500
| Type             | Description                                                        |
| ----------------- | ------------------------------------------------------------ |
| Promise<boolean\> | Promise used to return the flash mode support status. The value **true** means that the specified flash mode is supported.|
N
nikhilraut 已提交
501 502 503 504 505 506 507 508 509

**Example**

```
cameraInput.isFlashModeSupported(flashMode).then((status) => {
    console.log('Promise returned with flash mode support status.' + status);
})
```

W
wusongqing 已提交
510
### setFlashMode
N
nikhilraut 已提交
511

W
wusongqing 已提交
512
setFlashMode(flashMode: FlashMode, callback: AsyncCallback<void\>): void
N
nikhilraut 已提交
513

W
wusongqing 已提交
514
Sets the flash mode. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
515

W
wusongqing 已提交
516
Before setting the parameters, do the following checks:
N
nikhilraut 已提交
517

W
wusongqing 已提交
518 519
1. Use [hasFlash](#hasflash) to check whether the device has flash light.
2. Use [isFlashModeSupported](#isflashmodesupported) to check whether the device supports a specified flash mode.
N
nikhilraut 已提交
520

W
wusongqing 已提交
521
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
522 523 524

**Parameters**

W
wusongqing 已提交
525 526 527 528
| Name     | Type                   | Mandatory| Description                    |
| --------- | ----------------------- | ---- | ------------------------ |
| flashMode | [FlashMode](#flashmode) | Yes  | Flash mode.        |
| callback  | AsyncCallback<void\>    | Yes  | Callback used to return the result.|
N
nikhilraut 已提交
529 530 531 532 533 534 535 536 537 538 539 540 541

**Example**

```
cameraInput.setFlashMode(flashMode, (err) => {
    if (err) {
        console.error('Failed to set the flash mode  ${err.message}');
        return;
    }
    console.log('Callback returned with the successful execution of setFlashMode.');
})
```

W
wusongqing 已提交
542
### setFlashMode
N
nikhilraut 已提交
543

W
wusongqing 已提交
544
setFlashMode(flashMode: FlashMode): Promise<void\>
N
nikhilraut 已提交
545

W
wusongqing 已提交
546
Sets the flash mode. This API uses a promise to return the result.
N
nikhilraut 已提交
547

W
wusongqing 已提交
548
Before setting the parameters, do the following checks:
N
nikhilraut 已提交
549

W
wusongqing 已提交
550 551
1. Use [hasFlash](#hasflash) to check whether the device has flash light.
2. Use [isFlashModeSupported](#isflashmodesupported) to check whether the device supports a specified flash mode.
N
nikhilraut 已提交
552

W
wusongqing 已提交
553
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
554 555 556

**Parameters**

W
wusongqing 已提交
557 558 559
| Name     | Type                   | Mandatory| Description            |
| --------- | ----------------------- | ---- | ---------------- |
| flashMode | [FlashMode](#flashmode) | Yes  | Flash mode.|
N
nikhilraut 已提交
560

W
wusongqing 已提交
561
**Return value**
N
nikhilraut 已提交
562

W
wusongqing 已提交
563 564 565
| Type          | Description                       |
| -------------- | --------------------------- |
| Promise<void\> | Promise used to return the result.|
N
nikhilraut 已提交
566 567 568 569

**Example**

```
570
cameraInput.setFlashMode(flashMode).then(() => {
N
nikhilraut 已提交
571 572 573 574
    console.log('Promise returned with the successful execution of setFlashMode.');
})
```

W
wusongqing 已提交
575
### getFlashMode
N
nikhilraut 已提交
576

W
wusongqing 已提交
577
getFlashMode(callback: AsyncCallback<FlashMode\>): void
N
nikhilraut 已提交
578

W
wusongqing 已提交
579
Obtains the current flash mode. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
580

W
wusongqing 已提交
581
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
582 583 584

**Parameters**

W
wusongqing 已提交
585 586 587
| Name    | Type                                   | Mandatory| Description                                    |
| -------- | --------------------------------------- | ---- | ---------------------------------------- |
| callback | AsyncCallback<[FlashMode](#flashmode)\> | Yes  | Callback used to return the current flash mode.|
N
nikhilraut 已提交
588 589 590 591 592 593 594 595 596 597 598 599 600

**Example**

```
cameraInput.getFlashMode((err, flashMode) => {
    if (err) {
        console.error('Failed to get the flash mode  ${err.message}');
        return;
    }
    console.log('Callback returned with current flash mode: ' + flashMode);
})
```

W
wusongqing 已提交
601
### getFlashMode
N
nikhilraut 已提交
602

W
wusongqing 已提交
603
getFlashMode(): Promise<FlashMode\>
N
nikhilraut 已提交
604

W
wusongqing 已提交
605
Obtains the current flash mode. This API uses a promise to return the result.
N
nikhilraut 已提交
606

W
wusongqing 已提交
607
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
608

W
wusongqing 已提交
609
**Return value**
N
nikhilraut 已提交
610

W
wusongqing 已提交
611 612 613
| Type                             | Description                                   |
| --------------------------------- | --------------------------------------- |
| Promise<[FlashMode](#flashmode)\> | Promise used to return the current flash mode.|
N
nikhilraut 已提交
614 615 616 617

**Example**

```
618
cameraInput.getFlashMode().then((flashMode) => {
N
nikhilraut 已提交
619 620 621 622
    console.log('Promise returned with current flash mode : ' + flashMode);
})
```

W
wusongqing 已提交
623
### isFocusModeSupported
N
nikhilraut 已提交
624

W
wusongqing 已提交
625
isFocusModeSupported(afMode: FocusMode, callback: AsyncCallback<boolean\>): void
N
nikhilraut 已提交
626

W
wusongqing 已提交
627
Checks whether a specified focus mode is supported. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
628

W
wusongqing 已提交
629
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
630 631 632

**Parameters**

W
wusongqing 已提交
633 634 635 636
| Name    | Type                   | Mandatory| Description                                  |
| -------- | ----------------------- | ---- | -------------------------------------- |
| afMode   | [FocusMode](#focusmode) | Yes  | Focus mode.                      |
| callback | AsyncCallback<boolean\> | Yes  | Callback used to return the focus mode support status. The value **true** means that the specified focus mode is supported.|
N
nikhilraut 已提交
637 638 639 640

**Example**

```
N
nikhilraut 已提交
641
cameraInput.isFocusModeSupported(afMode, (err, status) => {
N
nikhilraut 已提交
642
    if (err) {
N
nikhilraut 已提交
643
        console.error('Failed to check whether the focus mode is supported. ${err.message}');
N
nikhilraut 已提交
644 645
        return;
    }
N
nikhilraut 已提交
646 647
    console.log('Callback returned with the focus mode support status: ' + status);
})
N
nikhilraut 已提交
648 649
```

W
wusongqing 已提交
650
### isFocusModeSupported
N
nikhilraut 已提交
651

W
wusongqing 已提交
652
isFocusModeSupported(afMode: FocusMode): Promise<boolean\>
N
nikhilraut 已提交
653

W
wusongqing 已提交
654
Checks whether a specified focus mode is supported. This API uses a promise to return the result.
N
nikhilraut 已提交
655

W
wusongqing 已提交
656
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
657 658 659

**Parameters**

W
wusongqing 已提交
660 661 662
| Name  | Type                   | Mandatory| Description            |
| ------ | ----------------------- | ---- | ---------------- |
| afMode | [FocusMode](#focusmode) | Yes  | Focus mode.|
N
nikhilraut 已提交
663

W
wusongqing 已提交
664
**Return value**
N
nikhilraut 已提交
665

W
wusongqing 已提交
666 667 668
| Type             | Description                                                       |
| ----------------- | ----------------------------------------------------------- |
| Promise<boolean\> | Promise used to return the flash mode support status. The value **true** means that the specified focus mode is supported.|
N
nikhilraut 已提交
669 670 671 672

**Example**

```
N
nikhilraut 已提交
673 674
cameraInput.isFocusModeSupported(afMode).then((status) => {
    console.log('Promise returned with focus mode support status.' + status);
N
nikhilraut 已提交
675 676 677
})
```

W
wusongqing 已提交
678
### setFocusMode
N
nikhilraut 已提交
679

W
wusongqing 已提交
680
setFocusMode(afMode: FocusMode, callback: AsyncCallback<void\>): void
N
nikhilraut 已提交
681

W
wusongqing 已提交
682
Sets the focus mode. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
683

W
wusongqing 已提交
684
Before setting the focus mode, use **[isFocusModeSupported](#isfocusmodesupported)** to check whether the focus mode is supported.
N
nikhilraut 已提交
685

W
wusongqing 已提交
686
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
687

N
nikhilraut 已提交
688 689
**Parameters**

W
wusongqing 已提交
690 691 692 693
| Name    | Type                   | Mandatory| Description                    |
| -------- | ----------------------- | ---- | ------------------------ |
| afMode   | [FocusMode](#focusmode) | Yes  | Focus mode.        |
| callback | AsyncCallback<void\>    | Yes  | Callback used to return the result.|
N
nikhilraut 已提交
694 695 696 697

**Example**

```
N
nikhilraut 已提交
698
cameraInput.setFocusMode(afMode, (err) => {
N
nikhilraut 已提交
699
    if (err) {
N
nikhilraut 已提交
700
        console.error('Failed to set the focus mode  ${err.message}');
N
nikhilraut 已提交
701 702
        return;
    }
N
nikhilraut 已提交
703 704
    console.log('Callback returned with the successful execution of setFocusMode.');
})
N
nikhilraut 已提交
705 706
```

W
wusongqing 已提交
707
### setFocusMode
N
nikhilraut 已提交
708

W
wusongqing 已提交
709
setFocusMode(afMode: FocusMode): Promise<void\>
N
nikhilraut 已提交
710

W
wusongqing 已提交
711
Sets the focus mode. This API uses a promise to return the result.
N
nikhilraut 已提交
712

W
wusongqing 已提交
713
Before setting the focus mode, use **[isFocusModeSupported](#isfocusmodesupported)** to check whether the focus mode is supported.
N
nikhilraut 已提交
714

W
wusongqing 已提交
715
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
716 717 718

**Parameters**

W
wusongqing 已提交
719 720 721
| Name  | Type                   | Mandatory| Description            |
| ------ | ----------------------- | ---- | ---------------- |
| afMode | [FocusMode](#focusmode) | Yes  | Focus mode.|
N
nikhilraut 已提交
722

W
wusongqing 已提交
723
**Return value**
N
nikhilraut 已提交
724

W
wusongqing 已提交
725 726 727
| Type          | Description                       |
| -------------- | --------------------------- |
| Promise<void\> | Promise used to return the result.|
N
nikhilraut 已提交
728 729 730 731

**Example**

```
732
cameraInput.setFocusMode(afMode).then(() => {
N
nikhilraut 已提交
733
    console.log('Promise returned with the successful execution of setFocusMode.');
N
nikhilraut 已提交
734 735 736
})
```

W
wusongqing 已提交
737
### getFocusMode
N
nikhilraut 已提交
738

W
wusongqing 已提交
739
getFocusMode(callback: AsyncCallback<FocusMode\>): void
N
nikhilraut 已提交
740

W
wusongqing 已提交
741
Obtains the current focus mode. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
742

W
wusongqing 已提交
743
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
744 745 746

**Parameters**

W
wusongqing 已提交
747 748 749
| Name    | Type                                   | Mandatory| Description                                  |
| -------- | --------------------------------------- | ---- | -------------------------------------- |
| callback | AsyncCallback<[FocusMode](#focusmode)\> | Yes  | Callback used to return the current focus mode.|
N
nikhilraut 已提交
750 751 752 753

**Example**

```
N
nikhilraut 已提交
754
cameraInput.getFocusMode((err, afMode) => {
N
nikhilraut 已提交
755
    if (err) {
N
nikhilraut 已提交
756
        console.error('Failed to get the focus mode  ${err.message}');
N
nikhilraut 已提交
757 758
        return;
    }
N
nikhilraut 已提交
759 760
    console.log('Callback returned with current focus mode: ' + afMode);
})
N
nikhilraut 已提交
761 762
```

W
wusongqing 已提交
763
### getFocusMode
N
nikhilraut 已提交
764

W
wusongqing 已提交
765
getFocusMode(): Promise<FocusMode\>
N
nikhilraut 已提交
766

W
wusongqing 已提交
767
Obtains the current focus mode. This API uses a promise to return the result.
N
nikhilraut 已提交
768

W
wusongqing 已提交
769
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
770

W
wusongqing 已提交
771
**Return value**
N
nikhilraut 已提交
772

W
wusongqing 已提交
773 774 775
| Type               | Description                                 |
| ------------------- | ------------------------------------- |
| Promise<FocusMode\> | Promise used to return the current focus mode.|
N
nikhilraut 已提交
776 777 778 779

**Example**

```
780
cameraInput.getFocusMode().then((afMode) => {
N
nikhilraut 已提交
781
    console.log('Promise returned with current focus mode : ' + afMode);
N
nikhilraut 已提交
782 783 784
})
```

W
wusongqing 已提交
785
### getZoomRatioRange
N
nikhilraut 已提交
786

W
wusongqing 已提交
787
getZoomRatioRange\(callback: AsyncCallback<Array<number\>\>\): void
N
nikhilraut 已提交
788

W
wusongqing 已提交
789
Obtains the zoom ratio range. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
790

W
wusongqing 已提交
791
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
792 793 794

**Parameters**

W
wusongqing 已提交
795 796 797
| Name    | Type                          | Mandatory| Description                    |
| -------- | ------------------------------ | ---- | ------------------------ |
| callback | AsyncCallback<Array<number\>\> | Yes  | Callback used to return the zoom ratio range.|
N
nikhilraut 已提交
798 799 800 801

**Example**

```
802
cameraInput.getZoomRatioRange((err, zoomRatioRange) => {
N
nikhilraut 已提交
803
    if (err) {
N
nikhilraut 已提交
804
        console.error('Failed to get the zoom ratio range. ${err.message}');
N
nikhilraut 已提交
805 806
        return;
    }
N
nikhilraut 已提交
807 808
    console.log('Callback returned with zoom ratio range: ' + zoomRatioRange.length);
})
N
nikhilraut 已提交
809 810
```

W
wusongqing 已提交
811
### getZoomRatioRange
N
nikhilraut 已提交
812

W
wusongqing 已提交
813
getZoomRatioRange\(\): Promise<Array<number\>\>
N
nikhilraut 已提交
814

W
wusongqing 已提交
815
Obtains the zoom ratio range. This API uses a promise to return the result.
N
nikhilraut 已提交
816

W
wusongqing 已提交
817
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
818

W
wusongqing 已提交
819
**Return value**
N
nikhilraut 已提交
820

W
wusongqing 已提交
821 822 823
| Type                    | Description                                       |
| ------------------------ | ------------------------------------------- |
| Promise<Array<number\>\> | Promise used to return the zoom ratio range.|
N
nikhilraut 已提交
824 825 826 827

**Example**

```
N
nikhilraut 已提交
828 829
cameraInput.getZoomRatioRange().then((zoomRatioRange) => {
    console.log('Promise returned with zoom ratio range: ' + zoomRatioRange.length);
N
nikhilraut 已提交
830 831 832
})
```

W
wusongqing 已提交
833
### setZoomRatio
N
nikhilraut 已提交
834

W
wusongqing 已提交
835
setZoomRatio(zoomRatio: number, callback: AsyncCallback<void\>): void
N
nikhilraut 已提交
836

W
wusongqing 已提交
837
Sets a zoom ratio. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
838

W
wusongqing 已提交
839
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
840 841 842

**Parameters**

W
wusongqing 已提交
843 844 845 846
| Name     | Type                | Mandatory| Description                    |
| --------- | -------------------- | ---- | ------------------------ |
| zoomRatio | number               | Yes  | Zoom ratio to set.            |
| callback  | AsyncCallback<void\> | Yes  | Callback used to return the result.|
N
nikhilraut 已提交
847 848 849 850

**Example**

```
N
nikhilraut 已提交
851
cameraInput.setZoomRatio(zoomRatio, (err) => {
N
nikhilraut 已提交
852
    if (err) {
N
nikhilraut 已提交
853
        console.error('Failed to set the zoom ratio value ${err.message}');
N
nikhilraut 已提交
854 855
        return;
    }
N
nikhilraut 已提交
856 857
    console.log('Callback returned with the successful execution of setZoomRatio.');
})
N
nikhilraut 已提交
858 859
```

W
wusongqing 已提交
860
### setZoomRatio
N
nikhilraut 已提交
861

W
wusongqing 已提交
862
setZoomRatio(zoomRatio: number): Promise<void\>
N
nikhilraut 已提交
863

W
wusongqing 已提交
864
Sets a zoom ratio. This API uses a promise to return the result.
N
nikhilraut 已提交
865

W
wusongqing 已提交
866
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
867 868 869

**Parameters**

W
wusongqing 已提交
870 871 872
| Name     | Type  | Mandatory| Description        |
| --------- | ------ | ---- | ------------ |
| zoomRatio | number | Yes  | Zoom ratio to set.|
N
nikhilraut 已提交
873

W
wusongqing 已提交
874
**Return value**
N
nikhilraut 已提交
875

W
wusongqing 已提交
876 877 878
| Type          | Description                       |
| -------------- | --------------------------- |
| Promise<void\> | Promise used to return the result.|
N
nikhilraut 已提交
879 880 881 882

**Example**

```
883
cameraInput.setZoomRatio(zoomRatio).then(() => {
N
nikhilraut 已提交
884
    console.log('Promise returned with the successful execution of setZoomRatio.');
N
nikhilraut 已提交
885 886 887
})
```

W
wusongqing 已提交
888
### getZoomRatio
N
nikhilraut 已提交
889

W
wusongqing 已提交
890
getZoomRatio(callback: AsyncCallback<number\>): void
N
nikhilraut 已提交
891

W
wusongqing 已提交
892
Obtains the current zoom ratio. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
893

W
wusongqing 已提交
894
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
895 896 897

**Parameters**

W
wusongqing 已提交
898 899 900
| Name    | Type                  | Mandatory| Description                    |
| -------- | ---------------------- | ---- | ------------------------ |
| callback | AsyncCallback<number\> | Yes  | Callback used to return the current zoom ratio.|
N
nikhilraut 已提交
901 902 903 904

**Example**

```
N
nikhilraut 已提交
905
cameraInput.getZoomRatio((err, zoomRatio) => {
N
nikhilraut 已提交
906
    if (err) {
N
nikhilraut 已提交
907
        console.error('Failed to get the zoom ratio ${err.message}');
N
nikhilraut 已提交
908 909
        return;
    }
N
nikhilraut 已提交
910 911
    console.log('Callback returned with current zoom ratio: ' + zoomRatio);
})
N
nikhilraut 已提交
912 913
```

W
wusongqing 已提交
914
### getZoomRatio
N
nikhilraut 已提交
915

W
wusongqing 已提交
916
getZoomRatio(): Promise<number\>
N
nikhilraut 已提交
917

W
wusongqing 已提交
918
Obtains the current zoom ratio. This API uses a promise to return the result.
N
nikhilraut 已提交
919

W
wusongqing 已提交
920
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
921

W
wusongqing 已提交
922
**Return value**
N
nikhilraut 已提交
923

W
wusongqing 已提交
924 925 926
| Type            | Description                       |
| ---------------- | --------------------------- |
| Promise<number\> | Promise used to return the current zoom ratio.|
N
nikhilraut 已提交
927 928 929 930

**Example**

```
931
cameraInput.getZoomRatio().then((zoomRatio) => {
N
nikhilraut 已提交
932 933 934 935
    console.log('Promise returned with current zoom ratio : ' + zoomRatio);
})
```

W
wusongqing 已提交
936
### release
N
nikhilraut 已提交
937

W
wusongqing 已提交
938
release\(callback: AsyncCallback<void\>\): void
N
nikhilraut 已提交
939

W
wusongqing 已提交
940
Releases this **CameraInput** instance. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
941

W
wusongqing 已提交
942
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
943 944 945

**Parameters**

W
wusongqing 已提交
946 947 948
| Name    | Type                | Mandatory| Description                    |
| -------- | -------------------- | ---- | ------------------------ |
| callback | AsyncCallback<void\> | Yes  | Callback used to return the result.|
N
nikhilraut 已提交
949 950 951 952

**Example**

```
W
wusongqing 已提交
953
camera.release((err) => {
N
nikhilraut 已提交
954 955 956 957 958 959 960 961
    if (err) {
        console.error('Failed to release the CameraInput instance ${err.message}');
        return;
    }
    console.log('Callback invoked to indicate that the CameraInput instance is released successfully.');
});
```

W
wusongqing 已提交
962
### release
N
nikhilraut 已提交
963

W
wusongqing 已提交
964
release(): Promise<void\>
N
nikhilraut 已提交
965

W
wusongqing 已提交
966
Releases this **CameraInput** instance. This API uses a promise to return the result.
N
nikhilraut 已提交
967

W
wusongqing 已提交
968
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
969

W
wusongqing 已提交
970
**Return value**
N
nikhilraut 已提交
971

W
wusongqing 已提交
972 973 974
| Type          | Description                       |
| -------------- | --------------------------- |
| Promise<void\> | Promise used to return the result.|
N
nikhilraut 已提交
975 976 977 978 979 980 981 982 983

**Example**

```
cameraInput.release().then(() => {
    console.log('Promise returned to indicate that the CameraInput instance is released successfully.');
})
```

W
wusongqing 已提交
984
### on('focusStateChange')
N
nikhilraut 已提交
985

W
wusongqing 已提交
986
on(type: 'focusStateChange', callback: AsyncCallback<FocusState\>): void
N
nikhilraut 已提交
987

W
wusongqing 已提交
988
Listens for focus state changes. This API uses a callback to return the focus state changes.
N
nikhilraut 已提交
989

W
wusongqing 已提交
990
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
991 992 993

**Parameters**

W
wusongqing 已提交
994 995 996 997
| Name    | Type                                     | Mandatory| Description                                                    |
| :------- | :---------------------------------------- | :--- | :------------------------------------------------------- |
| type     | string                                    | Yes  | Type of event to listen for. The value is fixed at **focusStateChange**, indicating the focus state change event.|
| callback | AsyncCallback<[FocusState](#focusstate)\> | Yes  | Callback used to return the focus state change.                            |
N
nikhilraut 已提交
998 999 1000 1001 1002 1003 1004 1005 1006

**Example**

```
cameraInput.on('focusStateChange', (focusState) => {
    console.log('Focus state  : ' + focusState);
})
```

W
wusongqing 已提交
1007
### on('error')
N
nikhilraut 已提交
1008

W
wusongqing 已提交
1009
on(type: 'error', callback: ErrorCallback<CameraInputError\>): void
N
nikhilraut 已提交
1010

W
wusongqing 已提交
1011
Listens for **CameraInput** errors. This API uses a callback to return the errors.
N
nikhilraut 已提交
1012

W
wusongqing 已提交
1013
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1014 1015 1016

**Parameters**

W
wusongqing 已提交
1017 1018 1019 1020
| Name    | Type                            | Mandatory| Description                                           |
| :------- | :------------------------------- | :--- | :---------------------------------------------- |
| type     | string                           | Yes  | Type of event to listen for. The value is fixed at **error**, indicating the camera input error event.|
| callback | ErrorCallback<CameraInputError\> | Yes  | Callback used to return the capture input errors.                       |
N
nikhilraut 已提交
1021 1022 1023 1024 1025 1026 1027 1028 1029 1030

**Example**

```
cameraInput.on('error', (cameraInputError) => {
    console.log('Camera input error code: ' + cameraInputError.code);
})
```


W
wusongqing 已提交
1031
## FlashMode
N
nikhilraut 已提交
1032

W
wusongqing 已提交
1033
Enumerates the flash modes.
1034

W
wusongqing 已提交
1035
**System capability**: SystemCapability.Multimedia.Camera.Core
1036

W
wusongqing 已提交
1037 1038 1039 1040 1041 1042
| Name                  | Default Value| Description        |
| ---------------------- | ------ | ------------ |
| FLASH_MODE_CLOSE       | 0      | The flash is off.|
| FLASH_MODE_OPEN        | 1      | The flash is on.|
| FLASH_MODE_AUTO        | 2      | The flash mode is auto, indicating that the flash fires automatically depending on the shooting conditions.|
| FLASH_MODE_ALWAYS_OPEN | 3      | The flash is steady on.|
N
nikhilraut 已提交
1043

W
wusongqing 已提交
1044
## FocusMode
N
nikhilraut 已提交
1045 1046 1047

Enumerates the focus modes.

W
wusongqing 已提交
1048 1049 1050 1051 1052 1053 1054 1055
**System capability**: SystemCapability.Multimedia.Camera.Core

| Name                      | Default Value| Description              |
| -------------------------- | ------ | ------------------ |
| FOCUS_MODE_MANUAL          | 0      | Manual focus.    |
| FOCUS_MODE_CONTINUOUS_AUTO | 1      | Continuous auto focus.|
| FOCUS_MODE_AUTO            | 2      | Auto focus.    |
| FOCUS_MODE_LOCKED          | 3      | Locked focus.        |
1056

W
wusongqing 已提交
1057
## FocusState
1058

W
wusongqing 已提交
1059
Enumerates the focus states.
N
nikhilraut 已提交
1060

W
wusongqing 已提交
1061
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1062

W
wusongqing 已提交
1063 1064 1065 1066 1067
| Name                 | Default Value| Description        |
| --------------------- | ------ | ------------ |
| FOCUS_STATE_SCAN      | 0      | Scanning.  |
| FOCUS_STATE_FOCUSED   | 1      | Focused.|
| FOCUS_STATE_UNFOCUSED | 2      | Unfocused.|
N
nikhilraut 已提交
1068

W
wusongqing 已提交
1069
## camera.createCaptureSession
N
nikhilraut 已提交
1070

W
wusongqing 已提交
1071
createCaptureSession\(context: Context, callback: AsyncCallback<CaptureSession\>\): void
N
nikhilraut 已提交
1072

W
wusongqing 已提交
1073 1074 1075
Creates a **CaptureSession** instance. This API uses an asynchronous callback to return the instance.

**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1076 1077 1078

**Parameters**

W
wusongqing 已提交
1079 1080 1081 1082
| Name    | Type                                             | Mandatory| Description                                  |
| -------- | ------------------------------------------------- | ---- | -------------------------------------- |
| context  | Context                                           | Yes  | Application context.                          |
| callback | AsyncCallback<[CaptureSession](#capturesession)\> | Yes  | Callback used to return the **CaptureSession** instance.|
N
nikhilraut 已提交
1083 1084 1085 1086

**Example**

```
W
wusongqing 已提交
1087
camera.createCaptureSession((context), (err, captureSession) => {
N
nikhilraut 已提交
1088 1089 1090 1091 1092 1093 1094 1095
    if (err) {
        console.error('Failed to create the CaptureSession instance. ${err.message}');
        return;
    }
    console.log('Callback returned with the CaptureSession instance.' + captureSession);
});
```

W
wusongqing 已提交
1096
## camera.createCaptureSession
N
nikhilraut 已提交
1097

W
wusongqing 已提交
1098
createCaptureSession(context: Context\): Promise<CaptureSession\>;
N
nikhilraut 已提交
1099

W
wusongqing 已提交
1100
Creates a **CaptureSession** instance. This API uses a promise to return the instance.
N
nikhilraut 已提交
1101

W
wusongqing 已提交
1102
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1103 1104 1105

**Parameters**

W
wusongqing 已提交
1106 1107 1108
| Name   | Type   | Mandatory| Description        |
| ------- | ------- | ---- | ------------ |
| context | Context | Yes  | Application context.|
N
nikhilraut 已提交
1109

W
wusongqing 已提交
1110
**Return value**
N
nikhilraut 已提交
1111

W
wusongqing 已提交
1112 1113 1114
| Type                                       | Description                                     |
| ------------------------------------------- | ----------------------------------------- |
| Promise<[CaptureSession](#capturesession)\> | Promise used to return the **CaptureSession** instance.|
N
nikhilraut 已提交
1115 1116 1117 1118

**Example**

```
W
wusongqing 已提交
1119
camera.createCaptureSession(context).then((captureSession) => {
N
nikhilraut 已提交
1120 1121 1122 1123
    console.log('Promise returned with the CaptureSession instance');
})
```

W
wusongqing 已提交
1124
## CaptureSession
N
nikhilraut 已提交
1125 1126 1127

Implements session capture.

W
wusongqing 已提交
1128
### beginConfig
N
nikhilraut 已提交
1129

W
wusongqing 已提交
1130
beginConfig\(callback: AsyncCallback<void\>\): void
N
nikhilraut 已提交
1131

W
wusongqing 已提交
1132
Starts configuration for this **CaptureSession** instance. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
1133

W
wusongqing 已提交
1134
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1135 1136 1137

**Parameters**

W
wusongqing 已提交
1138 1139 1140
| Name    | Type                | Mandatory| Description                    |
| -------- | -------------------- | ---- | ------------------------ |
| callback | AsyncCallback<void\> | Yes  | Callback used to return the result.|
N
nikhilraut 已提交
1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153

**Example**

```
captureSession.beginConfig((err) => {
    if (err) {
        console.error('Failed to start the configuration. ${err.message}');
        return;
    }
    console.log('Callback invoked to indicate the begin config success.');
});
```

W
wusongqing 已提交
1154
### beginConfig
N
nikhilraut 已提交
1155

W
wusongqing 已提交
1156
beginConfig\(\): Promise<void\>
N
nikhilraut 已提交
1157

W
wusongqing 已提交
1158
Starts configuration for this **CaptureSession** instance. This API uses a promise to return the result.
N
nikhilraut 已提交
1159

W
wusongqing 已提交
1160
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1161

W
wusongqing 已提交
1162
**Return value**
N
nikhilraut 已提交
1163

W
wusongqing 已提交
1164 1165 1166
| Type          | Description                       |
| -------------- | --------------------------- |
| Promise<void\> | Promise used to return the result.|
N
nikhilraut 已提交
1167 1168 1169 1170 1171 1172 1173 1174 1175 1176


**Example**

```
captureSession.beginConfig().then(() => {
    console.log('Promise returned to indicate the begin config success.');
})
```

W
wusongqing 已提交
1177
### commitConfig
N
nikhilraut 已提交
1178

W
wusongqing 已提交
1179
commitConfig\(callback: AsyncCallback<void\>\): void
N
nikhilraut 已提交
1180

W
wusongqing 已提交
1181
Commits the configuration for this **CaptureSession** instance. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
1182

W
wusongqing 已提交
1183
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1184 1185 1186

**Parameters**

W
wusongqing 已提交
1187 1188 1189
| Name    | Type                | Mandatory| Description                    |
| -------- | -------------------- | ---- | ------------------------ |
| callback | AsyncCallback<void\> | Yes  | Callback used to return the result.|
N
nikhilraut 已提交
1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202

**Example**

```
captureSession.commitConfig((err) => {
    if (err) {
        console.error('Failed to commit the configuration. ${err.message}');
        return;
    }
    console.log('Callback invoked to indicate the commit config success.');
});
```

W
wusongqing 已提交
1203
### commitConfig
N
nikhilraut 已提交
1204

W
wusongqing 已提交
1205
commitConfig\(\): Promise<void\>
N
nikhilraut 已提交
1206

W
wusongqing 已提交
1207
Commits the configuration for this **CaptureSession** instance. This API uses a promise to return the result.
N
nikhilraut 已提交
1208

W
wusongqing 已提交
1209
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1210

W
wusongqing 已提交
1211
**Return value**
N
nikhilraut 已提交
1212

W
wusongqing 已提交
1213 1214 1215
| Type          | Description                       |
| -------------- | --------------------------- |
| Promise<void\> | Promise used to return the result.|
N
nikhilraut 已提交
1216 1217 1218 1219 1220 1221 1222 1223 1224

**Example**

```
captureSession.commitConfig().then(() => {
    console.log('Promise returned to indicate the commit config success.');
})
```

W
wusongqing 已提交
1225
### addInput
N
nikhilraut 已提交
1226

W
wusongqing 已提交
1227
addInput\(cameraInput: CameraInput, callback: AsyncCallback<void\>\): void
N
nikhilraut 已提交
1228

W
wusongqing 已提交
1229
Adds a **CameraInput** instance to this **CaptureSession** instance. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
1230

W
wusongqing 已提交
1231
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1232 1233 1234

**Parameters**

W
wusongqing 已提交
1235 1236 1237 1238
| Name       | Type                       | Mandatory| Description                       |
| ----------- | --------------------------- | ---- | --------------------------- |
| cameraInput | [CameraInput](#camerainput) | Yes  | **CameraInput** instance to add.|
| callback    | AsyncCallback<void\>        | Yes  | Callback used to return the result.   |
N
nikhilraut 已提交
1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251

**Example**

```
captureSession.addInput(cameraInput, (err) => {
    if (err) {
        console.error('Failed to add the CameraInput instance. ${err.message}');
        return;
    }
    console.log('Callback invoked to indicate that the CameraInput instance is added.');
});
```

W
wusongqing 已提交
1252
### addInput
N
nikhilraut 已提交
1253

W
wusongqing 已提交
1254
addInput\(cameraInput: CameraInput\): Promise<void\>
N
nikhilraut 已提交
1255

W
wusongqing 已提交
1256
Adds a **CameraInput** instance to this **CaptureSession** instance. This API uses a promise to return the result.
N
nikhilraut 已提交
1257

W
wusongqing 已提交
1258
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1259 1260 1261

**Parameters**

W
wusongqing 已提交
1262 1263 1264
| Name       | Type                       | Mandatory| Description                       |
| ----------- | --------------------------- | ---- | --------------------------- |
| cameraInput | [CameraInput](#camerainput) | Yes  | **CameraInput** instance to add.|
N
nikhilraut 已提交
1265

W
wusongqing 已提交
1266
**Return value**
N
nikhilraut 已提交
1267

W
wusongqing 已提交
1268 1269 1270
| Type          | Description                       |
| -------------- | --------------------------- |
| Promise<void\> | Promise used to return the result.|
N
nikhilraut 已提交
1271 1272 1273 1274 1275 1276 1277 1278 1279

**Example**

```
captureSession.addInput(cameraInput).then(() => {
    console.log('Promise used to indicate that the CameraInput instance is added.');
})
```

W
wusongqing 已提交
1280
### addOutput
N
nikhilraut 已提交
1281

W
wusongqing 已提交
1282
addOutput\(previewOutput: PreviewOutput, callback: AsyncCallback<void\>\): void
N
nikhilraut 已提交
1283

W
wusongqing 已提交
1284
Adds a **PreviewOutput** instance to this **CaptureSession** instance. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
1285

W
wusongqing 已提交
1286
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1287 1288 1289

**Parameters**

W
wusongqing 已提交
1290 1291 1292 1293
| Name         | Type                           | Mandatory| Description                         |
| ------------- | ------------------------------- | ---- | ----------------------------- |
| previewOutput | [PreviewOutput](#previewoutput) | Yes  | **PreviewOutput** instance to add.|
| callback      | AsyncCallback<void\>            | Yes  | Callback used to return the result.     |
N
nikhilraut 已提交
1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306

**Example**

```
captureSession.addOutput(previewOutput, (err) => {
    if (err) {
        console.error('Failed to add the PreviewOutput instance ${err.message}');
        return;
    }
    console.log('Callback invoked to indicate that the PreviewOutput instance is added.');
});
```

W
wusongqing 已提交
1307
### addOutput
N
nikhilraut 已提交
1308

W
wusongqing 已提交
1309
addOutput\(previewOutput: PreviewOutput\): Promise<void\>
N
nikhilraut 已提交
1310

W
wusongqing 已提交
1311
Adds a **PreviewOutput** instance to this **CaptureSession** instance. This API uses a promise to return the result.
N
nikhilraut 已提交
1312

W
wusongqing 已提交
1313
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1314 1315 1316

**Parameters**

W
wusongqing 已提交
1317 1318 1319
| Name         | Type                           | Mandatory| Description                         |
| ------------- | ------------------------------- | ---- | ----------------------------- |
| previewOutput | [PreviewOutput](#previewoutput) | Yes  | **PreviewOutput** instance to add.|
N
nikhilraut 已提交
1320

W
wusongqing 已提交
1321
**Return value**
N
nikhilraut 已提交
1322

W
wusongqing 已提交
1323 1324 1325
| Type          | Description                       |
| -------------- | --------------------------- |
| Promise<void\> | Promise used to return the result.|
N
nikhilraut 已提交
1326 1327 1328 1329 1330 1331 1332 1333 1334

**Example**

```
captureSession.addOutput(previewOutput).then(() => {
    console.log('Promise used to indicate that the PreviewOutput instance is added.');
})
```

W
wusongqing 已提交
1335
### addOutput
N
nikhilraut 已提交
1336

W
wusongqing 已提交
1337
addOutput\(photoOutput: PhotoOutput, callback: AsyncCallback<void\>\): void
N
nikhilraut 已提交
1338

W
wusongqing 已提交
1339
Adds a **PhotoOutput** instance to this **CaptureSession** instance. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
1340

W
wusongqing 已提交
1341
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1342 1343 1344

**Parameters**

W
wusongqing 已提交
1345 1346 1347 1348
| Name       | Type                       | Mandatory| Description                       |
| ----------- | --------------------------- | ---- | --------------------------- |
| photoOutput | [PhotoOutput](#photooutput) | Yes  | **PhotoOutput** instance to add.|
| callback    | AsyncCallback<void\>        | Yes  | Callback used to return the result.   |
N
nikhilraut 已提交
1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361

**Example**

```
captureSession.addOutput(photoOutput, (err) => {
    if (err) {
        console.error('Failed to add the PhotoOutput instance ${err.message}');
        return;
    }
    console.log('Callback invoked to indicate that the PhotoOutput instance is added.');
});
```

W
wusongqing 已提交
1362
### addOutput
N
nikhilraut 已提交
1363

W
wusongqing 已提交
1364
addOutput\(photoOutput: PhotoOutput\): Promise<void\>
N
nikhilraut 已提交
1365

W
wusongqing 已提交
1366
Adds a **PhotoOutput** instance to this **CaptureSession** instance. This API uses a promise to return the result.
N
nikhilraut 已提交
1367

W
wusongqing 已提交
1368
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1369 1370 1371

**Parameters**

W
wusongqing 已提交
1372 1373 1374
| Name       | Type                       | Mandatory| Description                       |
| ----------- | --------------------------- | ---- | --------------------------- |
| photoOutput | [PhotoOutput](#photooutput) | Yes  | **PhotoOutput** instance to add.|
N
nikhilraut 已提交
1375

W
wusongqing 已提交
1376
**Return value**
N
nikhilraut 已提交
1377 1378

| Type          | Description                       |
W
wusongqing 已提交
1379 1380
| -------------- | --------------------------- |
| Promise\<void> | Promise used to return the result.|
N
nikhilraut 已提交
1381 1382 1383 1384

**Example**

```
N
nikhilraut 已提交
1385
captureSession.addOutput(photoOutput).then(() => {
N
nikhilraut 已提交
1386 1387 1388 1389
    console.log('Promise used to indicate that the PhotoOutput instance is added.');
})
```

W
wusongqing 已提交
1390
### addOutput
N
nikhilraut 已提交
1391

W
wusongqing 已提交
1392
addOutput\(videoOutput: VideoOutput, callback: AsyncCallback<void\>\): void
N
nikhilraut 已提交
1393

W
wusongqing 已提交
1394
Adds a **VideoOutput** instance to this **CaptureSession** instance. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
1395

W
wusongqing 已提交
1396
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1397 1398 1399

**Parameters**

W
wusongqing 已提交
1400 1401 1402 1403
| Name       | Type                       | Mandatory| Description                       |
| ----------- | --------------------------- | ---- | --------------------------- |
| videoOutput | [VideoOutput](#videooutput) | Yes  | **VideoOutput** instance to add.|
| callback    | AsyncCallback<void\>        | Yes  | Callback used to return the result.   |
N
nikhilraut 已提交
1404 1405 1406 1407

**Example**

```
N
nikhilraut 已提交
1408
captureSession.addOutput(videoOutput, (err) => {
N
nikhilraut 已提交
1409 1410 1411 1412 1413 1414 1415 1416
    if (err) {
        console.error('Failed to add the VideoOutput instance ${err.message}');
        return;
    }
    console.log('Callback invoked to indicate that the VideoOutput instance is added.');
});
```

W
wusongqing 已提交
1417
### addOutput
N
nikhilraut 已提交
1418

W
wusongqing 已提交
1419
addOutput\(videoOutput: VideoOutput\): Promise<void\>
N
nikhilraut 已提交
1420

W
wusongqing 已提交
1421
Adds a **VideoOutput** instance to this **CaptureSession** instance. This API uses a promise to return the result.
N
nikhilraut 已提交
1422

W
wusongqing 已提交
1423
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1424 1425 1426

**Parameters**

W
wusongqing 已提交
1427 1428 1429
| Name       | Type                       | Mandatory| Description                       |
| ----------- | --------------------------- | ---- | --------------------------- |
| videoOutput | [VideoOutput](#videooutput) | Yes  | **VideoOutput** instance to add.|
N
nikhilraut 已提交
1430

W
wusongqing 已提交
1431
**Return value**
N
nikhilraut 已提交
1432

W
wusongqing 已提交
1433 1434 1435
| Type          | Description                       |
| -------------- | --------------------------- |
| Promise\<void> | Promise used to return the result.|
N
nikhilraut 已提交
1436 1437 1438 1439

**Example**

```
N
nikhilraut 已提交
1440
captureSession.addOutput(videoOutput).then(() => {
N
nikhilraut 已提交
1441 1442 1443 1444
    console.log('Promise used to indicate that the VideoOutput instance is added.');
})
```

W
wusongqing 已提交
1445
### removeInput
N
nikhilraut 已提交
1446

W
wusongqing 已提交
1447
removeInput\(cameraInput: CameraInput, callback: AsyncCallback<void\>\): void
N
nikhilraut 已提交
1448

W
wusongqing 已提交
1449
Removes a **CameraInput** instance from this **CaptureSession** instance. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
1450

W
wusongqing 已提交
1451
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1452 1453 1454

**Parameters**

W
wusongqing 已提交
1455 1456 1457 1458
| Name       | Type                       | Mandatory| Description                       |
| ----------- | --------------------------- | ---- | --------------------------- |
| cameraInput | [CameraInput](#camerainput) | Yes  | **CameraInput** instance to remove.|
| callback    | AsyncCallback<void\>        | Yes  | Callback used to return the result.   |
N
nikhilraut 已提交
1459 1460 1461 1462

**Example**

```
N
nikhilraut 已提交
1463
captureSession.removeInput(cameraInput, (err) => {
N
nikhilraut 已提交
1464 1465 1466 1467 1468 1469 1470 1471
    if (err) {
        console.error('Failed to remove the CameraInput instance. ${err.message}');
        return;
    }
    console.log('Callback invoked to indicate that the cameraInput instance is removed.');
});
```

W
wusongqing 已提交
1472
### removeInput
N
nikhilraut 已提交
1473

W
wusongqing 已提交
1474
removeInput\(cameraInput: CameraInput\): Promise<void\>
N
nikhilraut 已提交
1475

W
wusongqing 已提交
1476
Removes a **CameraInput** instance from this **CaptureSession** instance. This API uses a promise to return the result.
N
nikhilraut 已提交
1477

W
wusongqing 已提交
1478
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1479 1480 1481

**Parameters**

W
wusongqing 已提交
1482 1483 1484
| Name       | Type                       | Mandatory| Description                       |
| ----------- | --------------------------- | ---- | --------------------------- |
| cameraInput | [CameraInput](#camerainput) | Yes  | **CameraInput** instance to remove.|
N
nikhilraut 已提交
1485

W
wusongqing 已提交
1486
**Return value**
N
nikhilraut 已提交
1487

W
wusongqing 已提交
1488 1489 1490
| Type          | Description                       |
| -------------- | --------------------------- |
| Promise\<void> | Promise used to return the result.|
N
nikhilraut 已提交
1491 1492 1493 1494

**Example**

```
N
nikhilraut 已提交
1495
captureSession.removeInput(cameraInput).then(() => {
N
nikhilraut 已提交
1496 1497 1498 1499
    console.log('Promise returned to indicate that the cameraInput instance is removed.');
})
```

W
wusongqing 已提交
1500
### removeOutput
N
nikhilraut 已提交
1501

W
wusongqing 已提交
1502
removeOutput\(previewOutput: PreviewOutput, callback: AsyncCallback<void\>\): void
N
nikhilraut 已提交
1503

W
wusongqing 已提交
1504
Removes a **PreviewOutput** instance from this **CaptureSession** instance. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
1505

W
wusongqing 已提交
1506
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1507 1508 1509

**Parameters**

W
wusongqing 已提交
1510 1511 1512 1513
| Name         | Type                           | Mandatory| Description                         |
| ------------- | ------------------------------- | ---- | ----------------------------- |
| previewOutput | [PreviewOutput](#previewoutput) | Yes  | **PreviewOutput** instance to remove.|
| callback      | AsyncCallback<void\>            | Yes  | Callback used to return the result.     |
N
nikhilraut 已提交
1514 1515 1516 1517

**Example**

```
N
nikhilraut 已提交
1518
captureSession.removeOutput(previewOutput, (err) => {
N
nikhilraut 已提交
1519 1520 1521 1522 1523 1524 1525 1526
    if (err) {
        console.error('Failed to remove the PreviewOutput instance. ${err.message}');
        return;
    }
    console.log('Callback invoked to indicate that the PreviewOutput instance is removed.');
});
```

W
wusongqing 已提交
1527
### removeOutput
N
nikhilraut 已提交
1528

W
wusongqing 已提交
1529
removeOutput(previewOutput: PreviewOutput): Promise<void\>
N
nikhilraut 已提交
1530

W
wusongqing 已提交
1531
Removes a **PreviewOutput** instance from this **CaptureSession** instance. This API uses a promise to return the result.
N
nikhilraut 已提交
1532

W
wusongqing 已提交
1533
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1534 1535 1536

**Parameters**

W
wusongqing 已提交
1537 1538 1539
| Name         | Type                           | Mandatory| Description                         |
| ------------- | ------------------------------- | ---- | ----------------------------- |
| previewOutput | [PreviewOutput](#previewoutput) | Yes  | **PreviewOutput** instance to remove.|
N
nikhilraut 已提交
1540 1541


W
wusongqing 已提交
1542
**Return value**
N
nikhilraut 已提交
1543

W
wusongqing 已提交
1544 1545 1546
| Type          | Description                       |
| -------------- | --------------------------- |
| Promise<void\> | Promise used to return the result.|
N
nikhilraut 已提交
1547 1548 1549 1550 1551


**Example**

```
N
nikhilraut 已提交
1552
captureSession.removeOutput(previewOutput).then(() => {
N
nikhilraut 已提交
1553 1554 1555 1556
    console.log('Promise returned to indicate that the PreviewOutput instance is removed.');
})
```

W
wusongqing 已提交
1557
### removeOutput
N
nikhilraut 已提交
1558

W
wusongqing 已提交
1559
removeOutput(photoOutput: PhotoOutput, callback: AsyncCallback<void\>): void
N
nikhilraut 已提交
1560

W
wusongqing 已提交
1561
Removes a **PhotoOutput** instance from this **CaptureSession** instance. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
1562

W
wusongqing 已提交
1563
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1564 1565 1566

**Parameters**

W
wusongqing 已提交
1567 1568 1569 1570
| Name       | Type                       | Mandatory| Description                       |
| ----------- | --------------------------- | ---- | --------------------------- |
| photoOutput | [PhotoOutput](#photooutput) | Yes  | **PhotoOutput** instance to remove.|
| callback    | AsyncCallback<void\>        | Yes  | Callback used to return the result.   |
N
nikhilraut 已提交
1571 1572 1573 1574

**Example**

```
N
nikhilraut 已提交
1575
captureSession.removeOutput(photoOutput, (err) => {
N
nikhilraut 已提交
1576 1577 1578 1579 1580 1581 1582 1583
    if (err) {
        console.error('Failed to remove the PhotoOutput instance. ${err.message}');
        return;
    }
    console.log('Callback invoked to indicate that the PhotoOutput instance is removed.');
});
```

W
wusongqing 已提交
1584
### removeOutput
N
nikhilraut 已提交
1585

W
wusongqing 已提交
1586
removeOutput(photoOutput: PhotoOutput): Promise<void\>
N
nikhilraut 已提交
1587

W
wusongqing 已提交
1588
Removes a **PhotoOutput** instance from this **CaptureSession** instance. This API uses a promise to return the result.
N
nikhilraut 已提交
1589

W
wusongqing 已提交
1590
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1591 1592 1593

**Parameters**

W
wusongqing 已提交
1594 1595 1596
| Name       | Type                       | Mandatory| Description                       |
| ----------- | --------------------------- | ---- | --------------------------- |
| photoOutput | [PhotoOutput](#photooutput) | Yes  | **PhotoOutput** instance to remove.|
N
nikhilraut 已提交
1597 1598


W
wusongqing 已提交
1599
**Return value**
N
nikhilraut 已提交
1600

W
wusongqing 已提交
1601 1602 1603
| Type          | Description                       |
| -------------- | --------------------------- |
| Promise<void\> | Promise used to return the result.|
N
nikhilraut 已提交
1604 1605 1606 1607 1608


**Example**

```
N
nikhilraut 已提交
1609
captureSession.removeOutput(photoOutput).then(() => {
N
nikhilraut 已提交
1610 1611 1612 1613
    console.log('Promise returned to indicate that the PhotoOutput instance is removed.');
})
```

W
wusongqing 已提交
1614
### removeOutput
N
nikhilraut 已提交
1615

W
wusongqing 已提交
1616
removeOutput(videoOutput: VideoOutput, callback: AsyncCallback<void\>): void
N
nikhilraut 已提交
1617

W
wusongqing 已提交
1618
Removes a **VideoOutput** instance from this **CaptureSession** instance. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
1619

W
wusongqing 已提交
1620
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1621 1622 1623

**Parameters**

W
wusongqing 已提交
1624 1625 1626 1627
| Name       | Type                       | Mandatory| Description                       |
| ----------- | --------------------------- | ---- | --------------------------- |
| videoOutput | [VideoOutput](#videooutput) | Yes  | **VideoOutput** instance to remove.|
| callback    | AsyncCallback<void\>        | Yes  | Callback used to return the result.   |
N
nikhilraut 已提交
1628 1629 1630 1631

**Example**

```
N
nikhilraut 已提交
1632
captureSession.removeOutput(videoOutput, (err) => {
N
nikhilraut 已提交
1633 1634 1635 1636 1637 1638 1639 1640
    if (err) {
        console.error('Failed to remove the VideoOutput instance. ${err.message}');
        return;
    }
    console.log('Callback invoked to indicate that the VideoOutput instance is removed.');
});
```

W
wusongqing 已提交
1641
### removeOutput
N
nikhilraut 已提交
1642

W
wusongqing 已提交
1643
removeOutput(videoOutput: VideoOutput): Promise<void\>
N
nikhilraut 已提交
1644

W
wusongqing 已提交
1645
Removes a **VideoOutput** instance from this **CaptureSession** instance. This API uses a promise to return the result.
N
nikhilraut 已提交
1646

W
wusongqing 已提交
1647
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1648 1649 1650

**Parameters**

W
wusongqing 已提交
1651 1652 1653
| Name       | Type                       | Mandatory| Description                       |
| ----------- | --------------------------- | ---- | --------------------------- |
| videoOutput | [VideoOutput](#videooutput) | Yes  | **VideoOutput** instance to remove.|
N
nikhilraut 已提交
1654 1655


W
wusongqing 已提交
1656
**Return value**
N
nikhilraut 已提交
1657

W
wusongqing 已提交
1658 1659 1660
| Type          | Description                       |
| -------------- | --------------------------- |
| Promise<void\> | Promise used to return the result.|
N
nikhilraut 已提交
1661 1662 1663 1664 1665


**Example**

```
N
nikhilraut 已提交
1666
captureSession.removeOutput(videoOutput).then(() => {
N
nikhilraut 已提交
1667 1668 1669 1670
    console.log('Promise returned to indicate that the VideoOutput instance is removed.');
})
```

W
wusongqing 已提交
1671
### start
N
nikhilraut 已提交
1672

W
wusongqing 已提交
1673
start\(callback: AsyncCallback<void\>\): void
N
nikhilraut 已提交
1674

W
wusongqing 已提交
1675
Starts this **CaptureSession** instance. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
1676

W
wusongqing 已提交
1677
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1678 1679 1680

**Parameters**

W
wusongqing 已提交
1681 1682 1683
| Name    | Type                | Mandatory| Description                    |
| -------- | -------------------- | ---- | ------------------------ |
| callback | AsyncCallback<void\> | Yes  | Callback used to return the result.|
N
nikhilraut 已提交
1684 1685 1686 1687

**Example**

```
N
nikhilraut 已提交
1688
captureSession.start((err) => {
N
nikhilraut 已提交
1689 1690 1691 1692 1693 1694 1695 1696
    if (err) {
        console.error('Failed to start the session ${err.message}');
        return;
    }
    console.log('Callback invoked to indicate the session start success.');
});
```

W
wusongqing 已提交
1697
### start
N
nikhilraut 已提交
1698

W
wusongqing 已提交
1699
start\(\): Promise<void\>
N
nikhilraut 已提交
1700

W
wusongqing 已提交
1701
Starts this **CaptureSession** instance. This API uses a promise to return the result.
N
nikhilraut 已提交
1702

W
wusongqing 已提交
1703
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1704

W
wusongqing 已提交
1705
**Return value**
N
nikhilraut 已提交
1706

W
wusongqing 已提交
1707 1708 1709
| Type          | Description                       |
| -------------- | --------------------------- |
| Promise<void\> | Promise used to return the result.|
N
nikhilraut 已提交
1710 1711 1712 1713

**Example**

```
N
nikhilraut 已提交
1714
captureSession.start().then(() => {
N
nikhilraut 已提交
1715 1716 1717 1718
    console.log('Promise returned to indicate the session start success.');
})
```

W
wusongqing 已提交
1719
### stop
N
nikhilraut 已提交
1720

W
wusongqing 已提交
1721
stop\(callback: AsyncCallback<void\>\): void
N
nikhilraut 已提交
1722

W
wusongqing 已提交
1723
Stops this **CaptureSession** instance. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
1724

W
wusongqing 已提交
1725
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1726 1727 1728 1729

**Parameters**


W
wusongqing 已提交
1730 1731 1732
| Name    | Type                | Mandatory| Description                    |
| -------- | -------------------- | ---- | ------------------------ |
| callback | AsyncCallback<void\> | Yes  | Callback used to return the result.|
N
nikhilraut 已提交
1733 1734 1735 1736

**Example**

```
N
nikhilraut 已提交
1737
captureSession.stop((err) => {
N
nikhilraut 已提交
1738 1739 1740 1741 1742 1743 1744 1745
    if (err) {
        console.error('Failed to stop the session ${err.message}');
        return;
    }
    console.log('Callback invoked to indicate the session stop success.');
});
```

W
wusongqing 已提交
1746
### stop
N
nikhilraut 已提交
1747

W
wusongqing 已提交
1748
stop(): Promise<void\>
N
nikhilraut 已提交
1749

W
wusongqing 已提交
1750
Stops this **CaptureSession** instance. This API uses a promise to return the result.
N
nikhilraut 已提交
1751

W
wusongqing 已提交
1752
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1753

W
wusongqing 已提交
1754
**Return value**
N
nikhilraut 已提交
1755

W
wusongqing 已提交
1756 1757 1758
| Type          | Description                       |
| -------------- | --------------------------- |
| Promise<void\> | Promise used to return the result.|
N
nikhilraut 已提交
1759 1760 1761 1762

**Example**

```
N
nikhilraut 已提交
1763
captureSession.stop().then(() => {
N
nikhilraut 已提交
1764 1765 1766 1767
    console.log('Promise returned to indicate the session stop success.');
})
```

W
wusongqing 已提交
1768
### release
N
nikhilraut 已提交
1769

W
wusongqing 已提交
1770
release\(callback: AsyncCallback<void\>\): void
N
nikhilraut 已提交
1771

W
wusongqing 已提交
1772
Releases this **CaptureSession** instance. This API uses an asynchronous callback to return the instance.
N
nikhilraut 已提交
1773

W
wusongqing 已提交
1774
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1775 1776 1777

**Parameters**

W
wusongqing 已提交
1778 1779 1780
| Name    | Type                | Mandatory| Description                    |
| -------- | -------------------- | ---- | ------------------------ |
| callback | AsyncCallback<void\> | Yes  | Callback used to return the result.|
N
nikhilraut 已提交
1781 1782 1783 1784

**Example**

```
N
nikhilraut 已提交
1785
captureSession.release((err) => {
N
nikhilraut 已提交
1786 1787 1788 1789 1790 1791 1792 1793
    if (err) {
        console.error('Failed to release the CaptureSession instance ${err.message}');
        return;
    }
    console.log('Callback invoked to indicate that the CaptureSession instance is released successfully.');
});
```

W
wusongqing 已提交
1794
### release
N
nikhilraut 已提交
1795

W
wusongqing 已提交
1796
release(): Promise<void\>
N
nikhilraut 已提交
1797

W
wusongqing 已提交
1798
Releases this **CaptureSession** instance. This API uses a promise to return the result.
N
nikhilraut 已提交
1799

W
wusongqing 已提交
1800
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1801

W
wusongqing 已提交
1802
**Return value**
N
nikhilraut 已提交
1803

W
wusongqing 已提交
1804 1805 1806
| Type          | Description                       |
| -------------- | --------------------------- |
| Promise<void\> | Promise used to return the result.|
N
nikhilraut 已提交
1807 1808 1809 1810

**Example**

```
N
nikhilraut 已提交
1811
captureSession.release().then(() => {
N
nikhilraut 已提交
1812 1813 1814 1815
    console.log('Promise returned to indicate that the CaptureSession instance is released successfully.');
})
```

W
wusongqing 已提交
1816
### on('error')
N
nikhilraut 已提交
1817

W
wusongqing 已提交
1818
on(type: 'error', callback: ErrorCallback<CaptureSessionError\>): void
N
nikhilraut 已提交
1819

W
wusongqing 已提交
1820
Listens for **CaptureSession** errors. This API uses a callback to return the errors.
N
nikhilraut 已提交
1821

W
wusongqing 已提交
1822
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1823 1824 1825

**Parameters**

W
wusongqing 已提交
1826 1827 1828 1829
| Name    | Type                               | Mandatory| Description                                         |
| :------- | :---------------------------------- | :--- | :-------------------------------------------- |
| type     | string                              | Yes  | Type of event to listen for. The value is fixed at **error**, indicating the capture session error event.|
| callback | ErrorCallback<CaptureSessionError\> | Yes  | Callback used to return the capture session errors.                 |
N
nikhilraut 已提交
1830 1831 1832 1833 1834 1835 1836 1837 1838

**Example**

```
captureSession.on('error', (captureSessionError) => {
    console.log('Capture session error code: ' + captureSessionError.code);
})
```

W
wusongqing 已提交
1839
## camera.createPreviewOutput
N
nikhilraut 已提交
1840

W
wusongqing 已提交
1841
createPreviewOutput(surfaceId: string, callback: AsyncCallback<PreviewOutput\>): void
N
nikhilraut 已提交
1842

W
wusongqing 已提交
1843
Creates a **PreviewOutput** instance. This API uses an asynchronous callback to return the instance.
N
nikhilraut 已提交
1844

W
wusongqing 已提交
1845
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1846 1847 1848

**Parameters**

W
wusongqing 已提交
1849 1850 1851 1852
| Name     | Type                                           | Mandatory| Description                                 |
| --------- | ----------------------------------------------- | ---- | ------------------------------------- |
| surfaceId | string                                          | Yes  | Surface ID received from **XComponent**.   |
| callback  | AsyncCallback<[PreviewOutput](#previewoutput)\> | Yes  | Callback used to return the **PreviewOutput** instance.|
N
nikhilraut 已提交
1853 1854 1855 1856

**Example**

```
1857
camera.createPreviewOutput((surfaceId), (err, previewOutput) => {
N
nikhilraut 已提交
1858 1859 1860 1861 1862 1863
    if (err) {
        console.error('Failed to create the PreviewOutput instance. ${err.message}');
        return;
    }
    console.log('Callback returned with previewOutput instance');
});
W
wusongqing 已提交
1864
```
N
nikhilraut 已提交
1865

W
wusongqing 已提交
1866
## camera.createPreviewOutput
N
nikhilraut 已提交
1867

W
wusongqing 已提交
1868
createPreviewOutput(surfaceId: string): Promise\<PreviewOutput>
N
nikhilraut 已提交
1869

W
wusongqing 已提交
1870
Creates a **PreviewOutput** instance. This API uses a promise to return the instance.
N
nikhilraut 已提交
1871

W
wusongqing 已提交
1872
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1873 1874 1875

**Parameters**

W
wusongqing 已提交
1876 1877 1878
| Name     | Type  | Mandatory| Description                              |
| --------- | ------ | ---- | ---------------------------------- |
| surfaceId | string | Yes  | Surface ID received from **XComponent**.|
N
nikhilraut 已提交
1879

W
wusongqing 已提交
1880
**Return value**
N
nikhilraut 已提交
1881

W
wusongqing 已提交
1882 1883 1884
| Type                                     | Description                       |
| ----------------------------------------- | --------------------------- |
| Promise<[PreviewOutput](#previewoutput)\> | Promise used to return the **PreviewOutput** instance.|
N
nikhilraut 已提交
1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897

**Example**

```
camera.createPreviewOutput(surfaceId).then((previewOutput) => {
    console.log('Promise returned with the PreviewOutput instance');
})
```

## PreviewOutput

Implements preview output.

W
wusongqing 已提交
1898
### release
N
nikhilraut 已提交
1899

W
wusongqing 已提交
1900
release(callback: AsyncCallback<void\>): void
N
nikhilraut 已提交
1901

W
wusongqing 已提交
1902
Releases this **PreviewOutput** instance. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
1903

W
wusongqing 已提交
1904
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1905 1906 1907

**Parameters**

W
wusongqing 已提交
1908 1909 1910
| Name    | Type                | Mandatory| Description                    |
| -------- | -------------------- | ---- | ------------------------ |
| callback | AsyncCallback<void\> | Yes  | Callback used to return the result.|
N
nikhilraut 已提交
1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923

**Example**

```
previewOutput.release((err) => {
    if (err) {
        console.error('Failed to release the PreviewOutput instance ${err.message}');
        return;
    }
    console.log('Callback invoked to indicate that the PreviewOutput instance is released successfully.');
});
```

W
wusongqing 已提交
1924
### release
N
nikhilraut 已提交
1925

W
wusongqing 已提交
1926
release(): Promise<void\>
N
nikhilraut 已提交
1927

W
wusongqing 已提交
1928
Releases this **PreviewOutput** instance. This API uses a promise to return the result.
N
nikhilraut 已提交
1929

W
wusongqing 已提交
1930
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1931

W
wusongqing 已提交
1932
**Return value**
N
nikhilraut 已提交
1933

W
wusongqing 已提交
1934 1935 1936
| Type          | Description                       |
| -------------- | --------------------------- |
| Promise<void\> | Promise used to return the result.|
N
nikhilraut 已提交
1937 1938 1939 1940 1941 1942 1943 1944 1945 1946


**Example**

```
previewOutput.release().then(() => {
    console.log('Promise returned to indicate that the PreviewOutput instance is released successfully.');
})
```

W
wusongqing 已提交
1947
### on('frameStart')
N
nikhilraut 已提交
1948

W
wusongqing 已提交
1949
on(type: 'frameStart', callback: AsyncCallback<void\>): void
N
nikhilraut 已提交
1950

W
wusongqing 已提交
1951
Listens for preview frame start events. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
1952

W
wusongqing 已提交
1953
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1954 1955 1956

**Parameters**

W
wusongqing 已提交
1957 1958 1959 1960
| Name    | Type                | Mandatory| Description                                        |
| :------- | :------------------- | :--- | :------------------------------------------- |
| type     | string               | Yes  | Type of event to listen for. The value is fixed at **frameStart**, indicating the preview frame start event.|
| callback | AsyncCallback<void\> | Yes  | Callback used to return the result.                    |
N
nikhilraut 已提交
1961 1962 1963 1964 1965 1966 1967 1968 1969

**Example**

```
previewOutput.on('frameStart', () => {
    console.log('Preview frame started');
})
```

W
wusongqing 已提交
1970
### on('frameEnd')
N
nikhilraut 已提交
1971

W
wusongqing 已提交
1972
on(type: 'frameEnd', callback: AsyncCallback<void\>): void
N
nikhilraut 已提交
1973

W
wusongqing 已提交
1974
Listens for preview frame end events. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
1975

W
wusongqing 已提交
1976
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1977 1978 1979

**Parameters**

W
wusongqing 已提交
1980 1981 1982 1983
| Name    | Type                | Mandatory| Description                                      |
| :------- | :------------------- | :--- | :----------------------------------------- |
| type     | string               | Yes  | Type of event to listen for. The value is fixed at **frameEnd**, indicating the preview frame end event.|
| callback | AsyncCallback<void\> | Yes  | Callback used to return the result.                  |
N
nikhilraut 已提交
1984 1985 1986 1987 1988 1989 1990 1991 1992

**Example**

```
previewOutput.on('frameEnd', () => {
    console.log('Preview frame ended');
})
```

W
wusongqing 已提交
1993
### on('error')
N
nikhilraut 已提交
1994

W
wusongqing 已提交
1995
on(type: 'error', callback: ErrorCallback<PreviewOutputError\>): void
N
nikhilraut 已提交
1996

W
wusongqing 已提交
1997
Listens for **PreviewOutput** errors. This API uses a callback to return the errors.
N
nikhilraut 已提交
1998

W
wusongqing 已提交
1999
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
2000 2001 2002

**Parameters**

W
wusongqing 已提交
2003 2004 2005 2006
| Name    | Type                              | Mandatory| Description                                         |
| :------- | :--------------------------------- | :--- | :-------------------------------------------- |
| type     | string                             | Yes  | Type of event to listen for. The value is fixed at **error**, indicating the preview output error event.|
| callback | ErrorCallback<PreviewOutputError\> | Yes  | Callback used to return the preview output errors.                 |
N
nikhilraut 已提交
2007 2008 2009 2010 2011 2012 2013 2014 2015

**Example**

```
previewOutput.on('error', (previewOutputError) => {
    console.log('Preview output error code: ' + previewOutputError.code);
})
```

W
wusongqing 已提交
2016
## camera.createPhotoOutput
N
nikhilraut 已提交
2017

W
wusongqing 已提交
2018
createPhotoOutput(surfaceId: string, callback: AsyncCallback<PhotoOutput\>): void
N
nikhilraut 已提交
2019

W
wusongqing 已提交
2020
Creates a **PhotoOutput** instance. This API uses an asynchronous callback to return the instance.
N
nikhilraut 已提交
2021

W
wusongqing 已提交
2022
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
2023 2024 2025

**Parameters**

W
wusongqing 已提交
2026 2027 2028 2029
| Name     | Type                                       | Mandatory| Description                               |
| --------- | ------------------------------------------- | ---- | ----------------------------------- |
| surfaceId | string                                      | Yes  | Surface ID received from **ImageReceiver**.  |
| callback  | AsyncCallback<[PhotoOutput](#photooutput)\> | Yes  | Callback used to return the **PhotoOutput** instance.|
N
nikhilraut 已提交
2030 2031 2032 2033

**Example**

```
2034
camera.createPhotoOutput((surfaceId), (err, photoOutput) => {
N
nikhilraut 已提交
2035 2036 2037 2038 2039 2040
    if (err) {
        console.error('Failed to create the PhotoOutput instance. ${err.message}');
        return;
    }
    console.log('Callback returned with the PhotoOutput instance.');
});
W
wusongqing 已提交
2041
```
N
nikhilraut 已提交
2042

W
wusongqing 已提交
2043
## camera.createPhotoOutput
N
nikhilraut 已提交
2044

W
wusongqing 已提交
2045
createPhotoOutput(surfaceId: string): Promise<PhotoOutput\>
N
nikhilraut 已提交
2046

W
wusongqing 已提交
2047
Creates a **PhotoOutput** instance. This API uses a promise to return the instance.
N
nikhilraut 已提交
2048

W
wusongqing 已提交
2049
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
2050 2051 2052

**Parameters**

W
wusongqing 已提交
2053 2054 2055
| Name     | Type  | Mandatory| Description                             |
| --------- | ------ | ---- | --------------------------------- |
| surfaceId | string | Yes  | Surface ID received from **ImageReceiver**.|
N
nikhilraut 已提交
2056

W
wusongqing 已提交
2057
**Return value**
N
nikhilraut 已提交
2058

W
wusongqing 已提交
2059 2060 2061
| Type                                 | Description                                  |
| ------------------------------------- | -------------------------------------- |
| Promise<[PhotoOutput](#photooutput)\> | Promise used to return the **PhotoOutput** instance.|
N
nikhilraut 已提交
2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073

**Example**

```
camera.createPhotoOutput(surfaceId).then((photoOutput) => {
    console.log('Promise returned with PhotoOutput instance');
})
```
## ImageRotation

Enumerates the image rotation angles.

W
wusongqing 已提交
2074
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
2075

W
wusongqing 已提交
2076 2077 2078 2079 2080 2081
| Name        | Default Value| Description           |
| ------------ | ------ | --------------- |
| ROTATION_0   | 0      | The image rotates 0 degrees.  |
| ROTATION_90  | 90     | The image rotates 90 degrees. |
| ROTATION_180 | 180    | The image rotates 180 degrees.|
| ROTATION_270 | 270    | The image rotates 270 degrees.|
N
nikhilraut 已提交
2082 2083 2084 2085 2086 2087 2088



## QualityLevel

Enumerates the image quality levels.

W
wusongqing 已提交
2089
**System capability**: SystemCapability.Multimedia.Camera.Core
2090

W
wusongqing 已提交
2091 2092 2093 2094 2095
| Name                | Default Value| Description          |
| -------------------- | ------ | -------------- |
| QUALITY_LEVEL_HIGH   | 0      | High image quality.  |
| QUALITY_LEVEL_MEDIUM | 1      | Medium image quality.|
| QUALITY_LEVEL_LOW    | 2      | Low image quality.  |
N
nikhilraut 已提交
2096 2097 2098 2099 2100 2101


## PhotoCaptureSetting

Defines the settings for image capture.

W
wusongqing 已提交
2102
**System capability**: SystemCapability.Multimedia.Camera.Core
2103

W
wusongqing 已提交
2104 2105 2106 2107
| Name    | Type                           | Mandatory| Description          |
| -------- | ------------------------------- | ---- | -------------- |
| quality  | [QualityLevel](#qualitylevel)   | No  | Photo image quality.    |
| rotation | [ImageRotation](#imagerotation) | No  | Photo rotation.|
N
nikhilraut 已提交
2108 2109 2110 2111 2112 2113


## PhotoOutput

Implements photo output.

W
wusongqing 已提交
2114
### capture
N
nikhilraut 已提交
2115

W
wusongqing 已提交
2116
capture(callback: AsyncCallback<void\>): void
N
nikhilraut 已提交
2117

W
wusongqing 已提交
2118
Captures a photo. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
2119

W
wusongqing 已提交
2120
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
2121 2122 2123

**Parameters**

W
wusongqing 已提交
2124 2125 2126
| Name    | Type                | Mandatory| Description                    |
| -------- | -------------------- | ---- | ------------------------ |
| callback | AsyncCallback<void\> | Yes  | Callback used to return the result.|
N
nikhilraut 已提交
2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139

**Example**

```
photoOutput.capture((err) => {
    if (err) {
        console.error('Failed to capture the photo ${err.message}');
        return;
    }
    console.log('Callback invoked to indicate the photo capture request success.');
});
```

W
wusongqing 已提交
2140
### capture
N
nikhilraut 已提交
2141

W
wusongqing 已提交
2142
capture(setting: PhotoCaptureSetting, callback: AsyncCallback<void\>): void
N
nikhilraut 已提交
2143

W
wusongqing 已提交
2144
Captures a photo with the specified capture settings. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
2145

W
wusongqing 已提交
2146
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
2147 2148 2149

**Parameters**

W
wusongqing 已提交
2150 2151 2152 2153
| Name    | Type                                       | Mandatory| Description                    |
| -------- | ------------------------------------------- | ---- | ------------------------ |
| setting  | [PhotoCaptureSetting](#photocapturesetting) | Yes  | Photo capture settings.              |
| callback | AsyncCallback<void\>                        | Yes  | Callback used to return the result.|
N
nikhilraut 已提交
2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166

**Example**

```
photoOutput.capture(settings, (err) => {
    if (err) {
        console.error('Failed to capture the photo ${err.message}');
        return;
    }
    console.log('Callback invoked to indicate the photo capture request success.');
});
```

W
wusongqing 已提交
2167
### capture
N
nikhilraut 已提交
2168

W
wusongqing 已提交
2169
capture(setting?: PhotoCaptureSetting): Promise<void\>
N
nikhilraut 已提交
2170

W
wusongqing 已提交
2171
Captures a photo with the specified capture settings. This API uses a promise to return the result.
N
nikhilraut 已提交
2172

W
wusongqing 已提交
2173
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
2174 2175 2176

**Parameters**

W
wusongqing 已提交
2177 2178 2179
| Name   | Type                                       | Mandatory| Description      |
| ------- | ------------------------------------------- | ---- | ---------- |
| setting | [PhotoCaptureSetting](#photocapturesetting) | No  | Photo capture settings.|
N
nikhilraut 已提交
2180

W
wusongqing 已提交
2181
**Return value**
N
nikhilraut 已提交
2182

W
wusongqing 已提交
2183 2184 2185
| Type          | Description                       |
| -------------- | --------------------------- |
| Promise<void\> | Promise used to return the result.|
N
nikhilraut 已提交
2186 2187 2188 2189 2190 2191 2192 2193 2194 2195


**Example**

```
photoOutput.capture().then(() => {
    console.log('Promise returned to indicate that photo capture request success.');
})
```

W
wusongqing 已提交
2196
### release
N
nikhilraut 已提交
2197

W
wusongqing 已提交
2198
release(callback: AsyncCallback<void\>): void
N
nikhilraut 已提交
2199

W
wusongqing 已提交
2200
Releases this **PhotoOutput** instance. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
2201

W
wusongqing 已提交
2202
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
2203 2204 2205

**Parameters**

W
wusongqing 已提交
2206 2207 2208
| Name    | Type                | Mandatory| Description                    |
| -------- | -------------------- | ---- | ------------------------ |
| callback | AsyncCallback<void\> | Yes  | Callback used to return the result.|
N
nikhilraut 已提交
2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221

**Example**

```
photoOutput.release((err) => {
    if (err) {
        console.error('Failed to release the PhotoOutput instance ${err.message}');
        return;
    }
    console.log('Callback invoked to indicate that the PhotoOutput instance is released successfully.');
});
```

W
wusongqing 已提交
2222
### release
N
nikhilraut 已提交
2223

W
wusongqing 已提交
2224
release(): Promise<void\>
N
nikhilraut 已提交
2225

W
wusongqing 已提交
2226
Releases this **PhotoOutput** instance. This API uses a promise to return the result.
N
nikhilraut 已提交
2227

W
wusongqing 已提交
2228
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
2229

W
wusongqing 已提交
2230
**Return value**
N
nikhilraut 已提交
2231

W
wusongqing 已提交
2232 2233 2234
| Type          | Description                       |
| -------------- | --------------------------- |
| Promise<void\> | Promise used to return the result.|
N
nikhilraut 已提交
2235 2236 2237 2238 2239 2240 2241 2242 2243 2244


**Example**

```
photoOutput.release().then(() => {
    console.log('Promise returned to indicate that the PhotoOutput instance is released successfully.');
})
```

W
wusongqing 已提交
2245
### on('captureStart')
N
nikhilraut 已提交
2246

W
wusongqing 已提交
2247
on(type: 'captureStart', callback: AsyncCallback<number\>): void
N
nikhilraut 已提交
2248

W
wusongqing 已提交
2249
Listens for photo capture start events. This API uses a callback to return the event information.
N
nikhilraut 已提交
2250

W
wusongqing 已提交
2251
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
2252 2253 2254

**Parameters**

W
wusongqing 已提交
2255 2256 2257 2258
| Name    | Type                  | Mandatory| Description                                            |
| :------- | :--------------------- | :--- | :----------------------------------------------- |
| type     | string                 | Yes  | Type of event to listen for. The value is fixed at **captureStart**, indicating the photo capture start event.|
| callback | AsyncCallback<number\> | Yes  | Callback used to return the capture ID.              |
N
nikhilraut 已提交
2259 2260 2261 2262 2263 2264 2265 2266 2267

**Example**

```
photoOutput.on('captureStart', (captureId) => {
    console.log('photo capture stated, captureId : ' + captureId);
})
```

W
wusongqing 已提交
2268
### on('frameShutter')
N
nikhilraut 已提交
2269

W
wusongqing 已提交
2270
on(type: 'frameShutter', callback: AsyncCallback<FrameShutterInfo\>): void
N
nikhilraut 已提交
2271

W
wusongqing 已提交
2272
Listens for frame shutter events. This API uses a callback to return the event information.
N
nikhilraut 已提交
2273

W
wusongqing 已提交
2274
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
2275 2276 2277

**Parameters**

W
wusongqing 已提交
2278 2279 2280 2281
| Name    | Type                            | Mandatory| Description                                          |
| :------- | :------------------------------- | :--- | :--------------------------------------------- |
| type     | string                           | Yes  | Type of event to listen for. The value is fixed at **frameShutter**, indicating the frame shutter event.|
| callback | AsyncCallback<FrameShutterInfo\> | Yes  | Callback used to return the frame shutter information.                  |
N
nikhilraut 已提交
2282 2283 2284 2285 2286 2287 2288 2289 2290 2291

**Example**

```
photoOutput.on('frameShutter', (frameShutterInfo) => {
    console.log('photo capture end, captureId : ' + frameShutterInfo.captureId);
    console.log('Timestamp for frame : ' + frameShutterInfo.timestamp);
})
```

W
wusongqing 已提交
2292
### on('captureEnd')
N
nikhilraut 已提交
2293

W
wusongqing 已提交
2294
on(type: 'captureEnd', callback: AsyncCallback<CaptureEndInfo\>): void
N
nikhilraut 已提交
2295

W
wusongqing 已提交
2296
Listens for photo capture end events. This API uses a callback to return the event information.
N
nikhilraut 已提交
2297

W
wusongqing 已提交
2298
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
2299 2300 2301

**Parameters**

W
wusongqing 已提交
2302 2303 2304 2305
| Name    | Type                          | Mandatory| Description                                          |
| :------- | :----------------------------- | :--- | :--------------------------------------------- |
| type     | string                         | Yes  | Type of event to listen for. The value is fixed at **captureEnd**, indicating the photo capture end event.|
| callback | AsyncCallback<CaptureEndInfo\> | Yes  | Callback used to return the photo capture end information.                  |
N
nikhilraut 已提交
2306 2307 2308 2309 2310 2311 2312 2313 2314 2315

**Example**

```
photoOutput.on('captureEnd', (captureEndInfo) => {
    console.log('photo capture end, captureId : ' + captureEndInfo.captureId);
    console.log('frameCount : ' + captureEndInfo.frameCount);
})
```

W
wusongqing 已提交
2316
### on('error')
N
nikhilraut 已提交
2317

W
wusongqing 已提交
2318
on(type: 'error', callback: ErrorCallback<PhotoOutputError\>): void
N
nikhilraut 已提交
2319

W
wusongqing 已提交
2320
Listens for **PhotoOutput** errors. This API uses a callback to return the errors.
N
nikhilraut 已提交
2321

W
wusongqing 已提交
2322
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
2323 2324 2325

**Parameters**

W
wusongqing 已提交
2326 2327 2328 2329
| Name    | Type                            | Mandatory| Description                                     |
| :------- | :------------------------------- | :--- | :---------------------------------------- |
| type     | string                           | Yes  | Type of event to listen for. The value is fixed at **error**, indicating the photo output error event.|
| callback | ErrorCallback<PhotoOutputError\> | Yes  | Callback used to return the photo output errors.             |
N
nikhilraut 已提交
2330 2331 2332 2333 2334 2335 2336 2337 2338

**Example**

```
photoOutput.on('error', (photoOutputError) => {
    console.log('Photo output error code: ' + photoOutputError.code);
})
```

W
wusongqing 已提交
2339
## camera.createVideoOutput
N
nikhilraut 已提交
2340

W
wusongqing 已提交
2341
createVideoOutput(surfaceId: string, callback: AsyncCallback<VideoOutput\>): void
N
nikhilraut 已提交
2342

W
wusongqing 已提交
2343
Creates a **VideoOutput** instance. This API uses an asynchronous callback to return the instance.
N
nikhilraut 已提交
2344

W
wusongqing 已提交
2345
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
2346 2347 2348

**Parameters**

W
wusongqing 已提交
2349 2350 2351 2352
| Name     | Type                                       | Mandatory| Description                               |
| --------- | ------------------------------------------- | ---- | ----------------------------------- |
| surfaceId | string                                      | Yes  | Surface ID received from **VideoRecorder**.  |
| callback  | AsyncCallback<[VideoOutput](#videooutput)\> | Yes  | Callback used to return the **VideoOutput** instance.|
N
nikhilraut 已提交
2353 2354 2355 2356

**Example**

```
2357
camera.createVideoOutput((surfaceId), (err, videoOutput) => {
N
nikhilraut 已提交
2358 2359 2360 2361 2362 2363
    if (err) {
        console.error('Failed to create the VideoOutput instance. ${err.message}');
        return;
    }
    console.log('Callback returned with the VideoOutput instance');
});
W
wusongqing 已提交
2364
```
N
nikhilraut 已提交
2365

W
wusongqing 已提交
2366
## camera.createVideoOutput
N
nikhilraut 已提交
2367

W
wusongqing 已提交
2368
createVideoOutput(surfaceId: string): Promise<VideoOutput\>
N
nikhilraut 已提交
2369

W
wusongqing 已提交
2370
Creates a **VideoOutput** instance. This API uses a promise to return the instance.
N
nikhilraut 已提交
2371

W
wusongqing 已提交
2372
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
2373 2374 2375

**Parameters**

W
wusongqing 已提交
2376 2377 2378
| Name     | Type  | Mandatory| Description                             |
| --------- | ------ | ---- | --------------------------------- |
| surfaceId | string | Yes  | Surface ID received from **VideoRecorder**.|
N
nikhilraut 已提交
2379

W
wusongqing 已提交
2380
**Return value**
N
nikhilraut 已提交
2381

W
wusongqing 已提交
2382 2383 2384
| Type                                 | Description                                  |
| ------------------------------------- | -------------------------------------- |
| Promise<[VideoOutput](#videooutput)\> | Promise used to return the **VideoOutput** instance.|
N
nikhilraut 已提交
2385 2386 2387 2388 2389 2390 2391 2392

**Example**

```
camera.createVideoOutput(surfaceId).then((videoOutput) => {
    console.log('Promise returned with the VideoOutput instance');
})
```
W
wusongqing 已提交
2393

N
nikhilraut 已提交
2394 2395 2396
## VideoOutput

Implements video output.
N
nikhilraut 已提交
2397

W
wusongqing 已提交
2398
### start
N
nikhilraut 已提交
2399

W
wusongqing 已提交
2400
start(callback: AsyncCallback<void\>): void
N
nikhilraut 已提交
2401

W
wusongqing 已提交
2402
Starts the video output. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
2403

W
wusongqing 已提交
2404
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
2405 2406 2407

**Parameters**

W
wusongqing 已提交
2408 2409 2410
| Name    | Type                | Mandatory| Description                    |
| -------- | -------------------- | ---- | ------------------------ |
| callback | AsyncCallback<void\> | Yes  | Callback used to return the result.|
N
nikhilraut 已提交
2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423

**Example**

```
videoOutput.start((err) => {
    if (err) {
        console.error('Failed to start the video output ${err.message}');
        return;
    }
    console.log('Callback invoked to indicate the video output start success.');
});
```

W
wusongqing 已提交
2424
### start
N
nikhilraut 已提交
2425

W
wusongqing 已提交
2426
start(): Promise<void\>
N
nikhilraut 已提交
2427

W
wusongqing 已提交
2428
Starts the video output. This API uses a promise to return the result.
N
nikhilraut 已提交
2429

W
wusongqing 已提交
2430
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
2431

W
wusongqing 已提交
2432
**Return value**
N
nikhilraut 已提交
2433

W
wusongqing 已提交
2434 2435 2436
| Type          | Description                       |
| -------------- | --------------------------- |
| Promise<void\> | Promise used to return the result.|
N
nikhilraut 已提交
2437 2438 2439 2440 2441 2442 2443 2444 2445 2446


**Example**

```
videoOutput.start().then(() => {
    console.log('Promise returned to indicate that start method execution success.');
})
```

W
wusongqing 已提交
2447
### stop
N
nikhilraut 已提交
2448

W
wusongqing 已提交
2449
stop(callback: AsyncCallback<void\>): void
N
nikhilraut 已提交
2450

W
wusongqing 已提交
2451
Stops the video output. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
2452

W
wusongqing 已提交
2453
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
2454 2455 2456

**Parameters**

W
wusongqing 已提交
2457 2458 2459
| Name    | Type                | Mandatory| Description                    |
| -------- | -------------------- | ---- | ------------------------ |
| callback | AsyncCallback<void\> | Yes  | Callback used to return the result.|
N
nikhilraut 已提交
2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472

**Example**

```
videoOutput.stop((err) => {
    if (err) {
        console.error('Failed to stop the video output ${err.message}');
        return;
    }
    console.log('Callback invoked to indicate the video output stop success.');
});
```

W
wusongqing 已提交
2473
### stop
N
nikhilraut 已提交
2474

W
wusongqing 已提交
2475
stop(): Promise<void\>
N
nikhilraut 已提交
2476

W
wusongqing 已提交
2477
Stops the video output. This API uses a promise to return the result.
N
nikhilraut 已提交
2478

W
wusongqing 已提交
2479
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
2480

W
wusongqing 已提交
2481
**Return value**
N
nikhilraut 已提交
2482

W
wusongqing 已提交
2483 2484 2485
| Type          | Description                       |
| -------------- | --------------------------- |
| Promise<void\> | Promise used to return the result.|
N
nikhilraut 已提交
2486 2487 2488 2489 2490 2491 2492 2493 2494

**Example**

```
videoOutput.start().then(() => {
    console.log('Promise returned to indicate that stop method execution success.');
})
```

W
wusongqing 已提交
2495
### release
N
nikhilraut 已提交
2496

W
wusongqing 已提交
2497
release(callback: AsyncCallback<void\>): void
N
nikhilraut 已提交
2498

W
wusongqing 已提交
2499
Releases this **VideoOutput** instance. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
2500

W
wusongqing 已提交
2501
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
2502 2503 2504

**Parameters**

W
wusongqing 已提交
2505 2506 2507
| Name    | Type                | Mandatory| Description                    |
| -------- | -------------------- | ---- | ------------------------ |
| callback | AsyncCallback<void\> | Yes  | Callback used to return the result.|
N
nikhilraut 已提交
2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520

**Example**

```
videoOutput.release((err) => {
    if (err) {
        console.error('Failed to release the VideoOutput instance ${err.message}');
        return;
    }
    console.log('Callback invoked to indicate that the VideoOutput instance is released successfully.');
});
```

W
wusongqing 已提交
2521
### release
N
nikhilraut 已提交
2522

W
wusongqing 已提交
2523
release(): Promise<void\>
N
nikhilraut 已提交
2524

W
wusongqing 已提交
2525
Releases this **VideoOutput** instance. This API uses a promise to return the result.
N
nikhilraut 已提交
2526

W
wusongqing 已提交
2527
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
2528

W
wusongqing 已提交
2529
**Return value**
N
nikhilraut 已提交
2530

W
wusongqing 已提交
2531 2532 2533
| Type          | Description                       |
| -------------- | --------------------------- |
| Promise<void\> | Promise used to return the result.|
N
nikhilraut 已提交
2534 2535 2536 2537 2538 2539 2540 2541


**Example**

```
videoOutput.release().then(() => {
    console.log('Promise returned to indicate that the VideoOutput instance is released successfully.');
})
N
nikhilraut 已提交
2542 2543
```

W
wusongqing 已提交
2544
### on('frameStart')
N
nikhilraut 已提交
2545

W
wusongqing 已提交
2546
on(type: 'frameStart', callback: AsyncCallback<void\>): void
N
nikhilraut 已提交
2547

W
wusongqing 已提交
2548
Listens for video frame start events. This API uses a callback to return the event information.
N
nikhilraut 已提交
2549

W
wusongqing 已提交
2550
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
2551 2552 2553

**Parameters**

W
wusongqing 已提交
2554 2555 2556 2557
| Name    | Type                | Mandatory| Description                                            |
| :------- | :------------------- | :--- | :----------------------------------------------- |
| type     | string               | Yes  | Type of event to listen for. The value is fixed at **frameStart**, indicating the video frame start event.|
| callback | AsyncCallback<void\> | Yes  | Callback used to return the result.                        |
N
nikhilraut 已提交
2558 2559 2560 2561 2562 2563 2564 2565 2566

**Example**

```
videoOutput.on('frameStart', () => {
    console.log('Video frame started');
})
```

W
wusongqing 已提交
2567 2568 2569
### on('frameEnd')

on(type: 'frameEnd', callback: AsyncCallback<void\>): void
N
nikhilraut 已提交
2570

W
wusongqing 已提交
2571 2572 2573
Listens for video frame end events. This API uses a callback to return the event information.

**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
2574 2575 2576

**Parameters**

W
wusongqing 已提交
2577 2578 2579 2580
| Name    | Type                | Mandatory| Description                                          |
| :------- | :------------------- | :--- | :--------------------------------------------- |
| type     | string               | Yes  | Type of event to listen for. The value is fixed at **frameEnd**, indicating the video frame end event.|
| callback | AsyncCallback<void\> | Yes  | Callback used to return the result.                      |
N
nikhilraut 已提交
2581 2582 2583 2584 2585 2586 2587 2588 2589

**Example**

```
videoOutput.on('frameEnd', () => {
    console.log('Video frame ended');
})
```

W
wusongqing 已提交
2590 2591 2592
### on('error')

on(type: 'error', callback: ErrorCallback<VideoOutputError\>): void
N
nikhilraut 已提交
2593

W
wusongqing 已提交
2594 2595 2596
Listens for **VideoOutput** errors. This API uses a callback to return the errors.

**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
2597 2598 2599

**Parameters**

W
wusongqing 已提交
2600 2601 2602 2603
| Name    | Type                       | Mandatory| Description                                         |
| :------- | :-------------------------- | :--- | :-------------------------------------------- |
| type     | string                      | Yes  | Type of event to listen for. The value is fixed at **error**, indicating the video output error event.|
| callback | Callback<VideoOutputError\> | Yes  | Callback used to return the video output errors.                 |
N
nikhilraut 已提交
2604 2605 2606 2607 2608 2609 2610

**Example**

```
videoOutput.on('error', (VideoOutputError) => {
    console.log('Video output error code: ' + VideoOutputError.code);
})
W
wusongqing 已提交
2611
```