js-apis-camera.md 87.6 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);
})
```

178 179 180 181 182 183 184 185 186 187 188
### Size

Size parameters. This interface used to get supported size for Preview + Photo + Video.

**System capability**: SystemCapability.Multimedia.Camera.Core

| Name    | Default Value                                     | Mandatory| Description                               |
| -------- | ------------------------------------------- | ---- | ----------------------------------- |
| height | number                                      | Yes  | Desired height of the Preview + Photo + Video.                       |
| width | number                                       | Yes  | Desired width of the Preview + Photo + Video.|

W
wusongqing 已提交
189
### createCameraInput
N
nikhilraut 已提交
190

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

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

W
wusongqing 已提交
195
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
196 197 198

**Parameters**

W
wusongqing 已提交
199 200 201 202
| 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 已提交
203 204 205 206 207 208 209 210 211 212 213 214 215

**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 已提交
216
### createCameraInput
N
nikhilraut 已提交
217

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

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

W
wusongqing 已提交
222
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
223 224 225

**Parameters**

W
wusongqing 已提交
226 227 228
| Name    | Default Value| Mandatory| Description        |
| -------- | ------ | ---- | ------------ |
| cameraId | string | Yes  | Camera ID used to create the instance.|
N
nikhilraut 已提交
229

W
wusongqing 已提交
230
**Return value**
N
nikhilraut 已提交
231

W
wusongqing 已提交
232 233 234
| Type                                 | Description                                    |
| ------------------------------------- | ---------------------------------------- |
| Promise<[CameraInput](#camerainput)\> | Promise used to return the **CameraInput** instance.|
N
nikhilraut 已提交
235 236 237 238 239 240 241 242 243

**Example**

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

W
wusongqing 已提交
244
### createCameraInput
N
nikhilraut 已提交
245

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

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

W
wusongqing 已提交
250
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
251 252 253

**Parameters**

W
wusongqing 已提交
254 255 256 257 258
| 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 已提交
259 260 261 262

**Example**

```
263
cameraManager.createCameraInput(camera.CameraPosition.CAMERA_POSITION_BACK, camera.CameraType.CAMERA_TYPE_UNSPECIFIED, (err, cameraInput) => {
N
nikhilraut 已提交
264 265 266 267 268 269 270 271
    if (err) {
        console.error('Failed to create the CameraInput instance. ${err.message}');
        return;
    }
    console.log('Callback returned with the CameraInput instance');
})
```

W
wusongqing 已提交
272
### createCameraInput
N
nikhilraut 已提交
273

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

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

W
wusongqing 已提交
278
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
279 280 281

**Parameters**

W
wusongqing 已提交
282 283 284 285
| Name    | Type                             | Mandatory| Description      |
| -------- | --------------------------------- | ---- | ---------- |
| position | [CameraPosition](#cameraposition) | Yes  | Camera position.|
| type     | [CameraType](#cameratype)         | Yes  | Camera type.|
N
nikhilraut 已提交
286

W
wusongqing 已提交
287
**Return value**
N
nikhilraut 已提交
288

W
wusongqing 已提交
289 290 291
| Type                                 | Description                                    |
| ------------------------------------- | ---------------------------------------- |
| Promise<[CameraInput](#camerainput)\> | Promise used to return the **CameraInput** instance.|
N
nikhilraut 已提交
292 293 294 295

**Example**

```
J
jiangminyang 已提交
296
cameraManager.createCameraInput(camera.CameraPosition.CAMERA_POSITION_BACK, camera.CameraType.CAMERA_TYPE_UNSPECIFIED).then((cameraInput) => {
N
nikhilraut 已提交
297 298 299 300
    console.log('Promise returned with the CameraInput instance.');
})
```

W
wusongqing 已提交
301
### on('cameraStatus')
N
nikhilraut 已提交
302

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

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

W
wusongqing 已提交
307
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
308 309 310

**Parameters**

W
wusongqing 已提交
311 312 313 314
| 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 已提交
315 316 317 318

**Example**

```
319 320 321 322 323
cameraManager.on('cameraStatus', (err, cameraInput) => {
    if (err) {
        console.error('Failed to get cameraStatus callback. ${err.message}');
        return;
    }
N
nikhilraut 已提交
324 325 326 327 328
    console.log('camera : ' + cameraStatusInfo.camera.cameraId);
    console.log('status: ' + cameraStatusInfo.status);
})
```

W
wusongqing 已提交
329
## Camera
330

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

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

W
wusongqing 已提交
335 336 337 338 339 340
| 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 已提交
341

W
wusongqing 已提交
342
**Example**
N
nikhilraut 已提交
343 344

```
J
jiangminyang 已提交
345
async function getCameraInfo("cameraId") {
346 347 348 349 350 351
    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;
352
    var connectionType = cameraObj.connectionType;
353
}
N
nikhilraut 已提交
354 355 356

```

W
wusongqing 已提交
357
## CameraStatusInfo
N
nikhilraut 已提交
358

W
wusongqing 已提交
359
Describes the camera status information.
N
nikhilraut 已提交
360

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

W
wusongqing 已提交
363 364 365 366
| Name  | Type                         | Description      |
| ------ | ----------------------------- | ---------- |
| camera | [Camera](#camera)             | Camera object.|
| status | [CameraStatus](#camerastatus) | Camera status.|
N
nikhilraut 已提交
367

N
nikhilraut 已提交
368

W
wusongqing 已提交
369
## CameraInput
N
nikhilraut 已提交
370

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

W
wusongqing 已提交
373
### getCameraId
N
nikhilraut 已提交
374

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

W
wusongqing 已提交
377
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 已提交
378

W
wusongqing 已提交
379
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
380 381 382

**Parameters**

W
wusongqing 已提交
383 384 385 386 387
| Name    | Type                  | Mandatory| Description                      |
| -------- | ---------------------- | ---- | -------------------------- |
| callback | AsyncCallback<string\> | Yes  | Callback used to return the camera ID.|

**Example**
N
nikhilraut 已提交
388 389 390 391 392 393 394 395 396 397 398

```
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 已提交
399
### getCameraId
N
nikhilraut 已提交
400

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

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

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

W
wusongqing 已提交
407
**Return value**
N
nikhilraut 已提交
408

W
wusongqing 已提交
409 410 411
| Type            | Description                         |
| ---------------- | ----------------------------- |
| Promise<string\> | Promise used to return the camera ID.|
N
nikhilraut 已提交
412 413 414 415 416 417 418 419 420 421

**Example**

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


W
wusongqing 已提交
422
### hasFlash
N
nikhilraut 已提交
423

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

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

W
wusongqing 已提交
428
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
429 430 431

**Parameters**

W
wusongqing 已提交
432 433 434
| 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 已提交
435 436 437 438 439 440 441 442 443 444 445 446 447

**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 已提交
448
### hasFlash
N
nikhilraut 已提交
449

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

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

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

W
wusongqing 已提交
456
**Return value**
N
nikhilraut 已提交
457

W
wusongqing 已提交
458 459 460
| 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 已提交
461 462 463 464 465 466 467 468 469

**Example**

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

W
wusongqing 已提交
470
### isFlashModeSupported
N
nikhilraut 已提交
471

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

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

W
wusongqing 已提交
476
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
477 478 479

**Parameters**

W
wusongqing 已提交
480 481 482 483
| 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 已提交
484 485 486 487

**Example**

```
488
cameraInput.isFlashModeSupported(camera.FlashMode.FLASH_MODE_AUTO, (err, status) => {
N
nikhilraut 已提交
489 490 491 492 493 494 495 496
    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 已提交
497
### isFlashModeSupported
N
nikhilraut 已提交
498

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

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

W
wusongqing 已提交
503
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
504 505 506

**Parameters**

W
wusongqing 已提交
507 508 509
| Name     | Type                   | Mandatory| Description            |
| --------- | ----------------------- | ---- | ---------------- |
| flashMode | [FlashMode](#flashmode) | Yes  | Flash mode.|
N
nikhilraut 已提交
510

W
wusongqing 已提交
511
**Return value**
N
nikhilraut 已提交
512

W
wusongqing 已提交
513 514 515
| 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 已提交
516 517 518 519

**Example**

```
J
jiangminyang 已提交
520
cameraInput.isFlashModeSupported(camera.FlashMode.FLASH_MODE_AUTO).then((status) => {
N
nikhilraut 已提交
521 522 523 524
    console.log('Promise returned with flash mode support status.' + status);
})
```

W
wusongqing 已提交
525
### setFlashMode
N
nikhilraut 已提交
526

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

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

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

W
wusongqing 已提交
533 534
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 已提交
535

W
wusongqing 已提交
536
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
537 538 539

**Parameters**

W
wusongqing 已提交
540 541 542 543
| Name     | Type                   | Mandatory| Description                    |
| --------- | ----------------------- | ---- | ------------------------ |
| flashMode | [FlashMode](#flashmode) | Yes  | Flash mode.        |
| callback  | AsyncCallback<void\>    | Yes  | Callback used to return the result.|
N
nikhilraut 已提交
544 545 546 547

**Example**

```
J
jiangminyang 已提交
548
cameraInput.setFlashMode(camera.FlashMode.FLASH_MODE_AUTO, (err) => {
N
nikhilraut 已提交
549 550 551 552 553 554 555 556
    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 已提交
557
### setFlashMode
N
nikhilraut 已提交
558

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

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

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

W
wusongqing 已提交
565 566
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 已提交
567

W
wusongqing 已提交
568
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
569 570 571

**Parameters**

W
wusongqing 已提交
572 573 574
| Name     | Type                   | Mandatory| Description            |
| --------- | ----------------------- | ---- | ---------------- |
| flashMode | [FlashMode](#flashmode) | Yes  | Flash mode.|
N
nikhilraut 已提交
575

W
wusongqing 已提交
576
**Return value**
N
nikhilraut 已提交
577

W
wusongqing 已提交
578 579 580
| Type          | Description                       |
| -------------- | --------------------------- |
| Promise<void\> | Promise used to return the result.|
N
nikhilraut 已提交
581 582 583 584

**Example**

```
J
jiangminyang 已提交
585
cameraInput.setFlashMode(camera.FlashMode.FLASH_MODE_AUTO).then(() => {
N
nikhilraut 已提交
586 587 588 589
    console.log('Promise returned with the successful execution of setFlashMode.');
})
```

W
wusongqing 已提交
590
### getFlashMode
N
nikhilraut 已提交
591

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

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

W
wusongqing 已提交
596
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
597 598 599

**Parameters**

W
wusongqing 已提交
600 601 602
| Name    | Type                                   | Mandatory| Description                                    |
| -------- | --------------------------------------- | ---- | ---------------------------------------- |
| callback | AsyncCallback<[FlashMode](#flashmode)\> | Yes  | Callback used to return the current flash mode.|
N
nikhilraut 已提交
603 604 605 606 607 608 609 610 611 612 613 614 615

**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 已提交
616
### getFlashMode
N
nikhilraut 已提交
617

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

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

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

W
wusongqing 已提交
624
**Return value**
N
nikhilraut 已提交
625

W
wusongqing 已提交
626 627 628
| Type                             | Description                                   |
| --------------------------------- | --------------------------------------- |
| Promise<[FlashMode](#flashmode)\> | Promise used to return the current flash mode.|
N
nikhilraut 已提交
629 630 631 632

**Example**

```
633
cameraInput.getFlashMode().then((flashMode) => {
N
nikhilraut 已提交
634 635 636 637
    console.log('Promise returned with current flash mode : ' + flashMode);
})
```

W
wusongqing 已提交
638
### isFocusModeSupported
N
nikhilraut 已提交
639

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

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

W
wusongqing 已提交
644
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
645 646 647

**Parameters**

W
wusongqing 已提交
648 649 650 651
| 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 已提交
652 653 654 655

**Example**

```
656
cameraInput.isFocusModeSupported(camera.FocusMode.FOCUS_MODE_AUTO, (err, status) => {
N
nikhilraut 已提交
657
    if (err) {
N
nikhilraut 已提交
658
        console.error('Failed to check whether the focus mode is supported. ${err.message}');
N
nikhilraut 已提交
659 660
        return;
    }
N
nikhilraut 已提交
661 662
    console.log('Callback returned with the focus mode support status: ' + status);
})
N
nikhilraut 已提交
663 664
```

W
wusongqing 已提交
665
### isFocusModeSupported
N
nikhilraut 已提交
666

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

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

W
wusongqing 已提交
671
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
672 673 674

**Parameters**

W
wusongqing 已提交
675 676 677
| Name  | Type                   | Mandatory| Description            |
| ------ | ----------------------- | ---- | ---------------- |
| afMode | [FocusMode](#focusmode) | Yes  | Focus mode.|
N
nikhilraut 已提交
678

W
wusongqing 已提交
679
**Return value**
N
nikhilraut 已提交
680

W
wusongqing 已提交
681 682 683
| 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 已提交
684 685 686 687

**Example**

```
J
jiangminyang 已提交
688
cameraInput.isFocusModeSupported(camera.FocusMode.FOCUS_MODE_AUTO).then((status) => {
N
nikhilraut 已提交
689
    console.log('Promise returned with focus mode support status.' + status);
N
nikhilraut 已提交
690 691 692
})
```

W
wusongqing 已提交
693
### setFocusMode
N
nikhilraut 已提交
694

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

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

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

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

N
nikhilraut 已提交
703 704
**Parameters**

W
wusongqing 已提交
705 706 707 708
| Name    | Type                   | Mandatory| Description                    |
| -------- | ----------------------- | ---- | ------------------------ |
| afMode   | [FocusMode](#focusmode) | Yes  | Focus mode.        |
| callback | AsyncCallback<void\>    | Yes  | Callback used to return the result.|
N
nikhilraut 已提交
709 710 711 712

**Example**

```
J
jiangminyang 已提交
713
cameraInput.setFocusMode(camera.FocusMode.FOCUS_MODE_AUTO, (err) => {
N
nikhilraut 已提交
714
    if (err) {
N
nikhilraut 已提交
715
        console.error('Failed to set the focus mode  ${err.message}');
N
nikhilraut 已提交
716 717
        return;
    }
N
nikhilraut 已提交
718 719
    console.log('Callback returned with the successful execution of setFocusMode.');
})
N
nikhilraut 已提交
720 721
```

W
wusongqing 已提交
722
### setFocusMode
N
nikhilraut 已提交
723

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

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

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

W
wusongqing 已提交
730
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
731 732 733

**Parameters**

W
wusongqing 已提交
734 735 736
| Name  | Type                   | Mandatory| Description            |
| ------ | ----------------------- | ---- | ---------------- |
| afMode | [FocusMode](#focusmode) | Yes  | Focus mode.|
N
nikhilraut 已提交
737

W
wusongqing 已提交
738
**Return value**
N
nikhilraut 已提交
739

W
wusongqing 已提交
740 741 742
| Type          | Description                       |
| -------------- | --------------------------- |
| Promise<void\> | Promise used to return the result.|
N
nikhilraut 已提交
743 744 745 746

**Example**

```
J
jiangminyang 已提交
747
cameraInput.setFocusMode(camera.FocusMode.FOCUS_MODE_AUTO).then(() => {
N
nikhilraut 已提交
748
    console.log('Promise returned with the successful execution of setFocusMode.');
N
nikhilraut 已提交
749 750 751
})
```

W
wusongqing 已提交
752
### getFocusMode
N
nikhilraut 已提交
753

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

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

W
wusongqing 已提交
758
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
759 760 761

**Parameters**

W
wusongqing 已提交
762 763 764
| Name    | Type                                   | Mandatory| Description                                  |
| -------- | --------------------------------------- | ---- | -------------------------------------- |
| callback | AsyncCallback<[FocusMode](#focusmode)\> | Yes  | Callback used to return the current focus mode.|
N
nikhilraut 已提交
765 766 767 768

**Example**

```
N
nikhilraut 已提交
769
cameraInput.getFocusMode((err, afMode) => {
N
nikhilraut 已提交
770
    if (err) {
N
nikhilraut 已提交
771
        console.error('Failed to get the focus mode  ${err.message}');
N
nikhilraut 已提交
772 773
        return;
    }
N
nikhilraut 已提交
774 775
    console.log('Callback returned with current focus mode: ' + afMode);
})
N
nikhilraut 已提交
776 777
```

W
wusongqing 已提交
778
### getFocusMode
N
nikhilraut 已提交
779

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

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

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

W
wusongqing 已提交
786
**Return value**
N
nikhilraut 已提交
787

W
wusongqing 已提交
788 789 790
| Type               | Description                                 |
| ------------------- | ------------------------------------- |
| Promise<FocusMode\> | Promise used to return the current focus mode.|
N
nikhilraut 已提交
791 792 793 794

**Example**

```
795
cameraInput.getFocusMode().then((afMode) => {
N
nikhilraut 已提交
796
    console.log('Promise returned with current focus mode : ' + afMode);
N
nikhilraut 已提交
797 798 799
})
```

W
wusongqing 已提交
800
### getZoomRatioRange
N
nikhilraut 已提交
801

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

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

W
wusongqing 已提交
806
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
807 808 809

**Parameters**

W
wusongqing 已提交
810 811 812
| Name    | Type                          | Mandatory| Description                    |
| -------- | ------------------------------ | ---- | ------------------------ |
| callback | AsyncCallback<Array<number\>\> | Yes  | Callback used to return the zoom ratio range.|
N
nikhilraut 已提交
813 814 815 816

**Example**

```
817
cameraInput.getZoomRatioRange((err, zoomRatioRange) => {
N
nikhilraut 已提交
818
    if (err) {
N
nikhilraut 已提交
819
        console.error('Failed to get the zoom ratio range. ${err.message}');
N
nikhilraut 已提交
820 821
        return;
    }
N
nikhilraut 已提交
822 823
    console.log('Callback returned with zoom ratio range: ' + zoomRatioRange.length);
})
N
nikhilraut 已提交
824 825
```

W
wusongqing 已提交
826
### getZoomRatioRange
N
nikhilraut 已提交
827

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

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

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

W
wusongqing 已提交
834
**Return value**
N
nikhilraut 已提交
835

W
wusongqing 已提交
836 837 838
| Type                    | Description                                       |
| ------------------------ | ------------------------------------------- |
| Promise<Array<number\>\> | Promise used to return the zoom ratio range.|
N
nikhilraut 已提交
839 840 841 842

**Example**

```
N
nikhilraut 已提交
843 844
cameraInput.getZoomRatioRange().then((zoomRatioRange) => {
    console.log('Promise returned with zoom ratio range: ' + zoomRatioRange.length);
N
nikhilraut 已提交
845 846 847
})
```

W
wusongqing 已提交
848
### setZoomRatio
N
nikhilraut 已提交
849

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

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

W
wusongqing 已提交
854
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
855 856 857

**Parameters**

W
wusongqing 已提交
858 859 860 861
| Name     | Type                | Mandatory| Description                    |
| --------- | -------------------- | ---- | ------------------------ |
| zoomRatio | number               | Yes  | Zoom ratio to set.            |
| callback  | AsyncCallback<void\> | Yes  | Callback used to return the result.|
N
nikhilraut 已提交
862 863 864 865

**Example**

```
866
cameraInput.setZoomRatio(1, (err) => {
N
nikhilraut 已提交
867
    if (err) {
N
nikhilraut 已提交
868
        console.error('Failed to set the zoom ratio value ${err.message}');
N
nikhilraut 已提交
869 870
        return;
    }
N
nikhilraut 已提交
871 872
    console.log('Callback returned with the successful execution of setZoomRatio.');
})
N
nikhilraut 已提交
873 874
```

W
wusongqing 已提交
875
### setZoomRatio
N
nikhilraut 已提交
876

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

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

W
wusongqing 已提交
881
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
882 883 884

**Parameters**

W
wusongqing 已提交
885 886 887
| Name     | Type  | Mandatory| Description        |
| --------- | ------ | ---- | ------------ |
| zoomRatio | number | Yes  | Zoom ratio to set.|
N
nikhilraut 已提交
888

W
wusongqing 已提交
889
**Return value**
N
nikhilraut 已提交
890

W
wusongqing 已提交
891 892 893
| Type          | Description                       |
| -------------- | --------------------------- |
| Promise<void\> | Promise used to return the result.|
N
nikhilraut 已提交
894 895 896 897

**Example**

```
J
jiangminyang 已提交
898
cameraInput.setZoomRatio(1).then(() => {
N
nikhilraut 已提交
899
    console.log('Promise returned with the successful execution of setZoomRatio.');
N
nikhilraut 已提交
900 901 902
})
```

W
wusongqing 已提交
903
### getZoomRatio
N
nikhilraut 已提交
904

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

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

W
wusongqing 已提交
909
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
910 911 912

**Parameters**

W
wusongqing 已提交
913 914 915
| Name    | Type                  | Mandatory| Description                    |
| -------- | ---------------------- | ---- | ------------------------ |
| callback | AsyncCallback<number\> | Yes  | Callback used to return the current zoom ratio.|
N
nikhilraut 已提交
916 917 918 919

**Example**

```
N
nikhilraut 已提交
920
cameraInput.getZoomRatio((err, zoomRatio) => {
N
nikhilraut 已提交
921
    if (err) {
N
nikhilraut 已提交
922
        console.error('Failed to get the zoom ratio ${err.message}');
N
nikhilraut 已提交
923 924
        return;
    }
N
nikhilraut 已提交
925 926
    console.log('Callback returned with current zoom ratio: ' + zoomRatio);
})
N
nikhilraut 已提交
927 928
```

W
wusongqing 已提交
929
### getZoomRatio
N
nikhilraut 已提交
930

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

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

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

W
wusongqing 已提交
937
**Return value**
N
nikhilraut 已提交
938

W
wusongqing 已提交
939 940 941
| Type            | Description                       |
| ---------------- | --------------------------- |
| Promise<number\> | Promise used to return the current zoom ratio.|
N
nikhilraut 已提交
942 943 944 945

**Example**

```
946
cameraInput.getZoomRatio().then((zoomRatio) => {
N
nikhilraut 已提交
947 948 949 950
    console.log('Promise returned with current zoom ratio : ' + zoomRatio);
})
```

W
wusongqing 已提交
951
### release
N
nikhilraut 已提交
952

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

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

W
wusongqing 已提交
957
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
958 959 960

**Parameters**

W
wusongqing 已提交
961 962 963
| Name    | Type                | Mandatory| Description                    |
| -------- | -------------------- | ---- | ------------------------ |
| callback | AsyncCallback<void\> | Yes  | Callback used to return the result.|
N
nikhilraut 已提交
964 965 966 967

**Example**

```
968
cameraInput.release((err) => {
N
nikhilraut 已提交
969 970 971 972 973 974 975 976
    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 已提交
977
### release
N
nikhilraut 已提交
978

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

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

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

W
wusongqing 已提交
985
**Return value**
N
nikhilraut 已提交
986

W
wusongqing 已提交
987 988 989
| Type          | Description                       |
| -------------- | --------------------------- |
| Promise<void\> | Promise used to return the result.|
N
nikhilraut 已提交
990 991 992 993 994 995 996 997 998

**Example**

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

W
wusongqing 已提交
999
### on('focusStateChange')
N
nikhilraut 已提交
1000

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

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

W
wusongqing 已提交
1005
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1006 1007 1008

**Parameters**

W
wusongqing 已提交
1009 1010 1011 1012
| 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 已提交
1013 1014 1015 1016 1017 1018 1019 1020 1021

**Example**

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

W
wusongqing 已提交
1022
### on('error')
N
nikhilraut 已提交
1023

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

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

W
wusongqing 已提交
1028
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1029 1030 1031

**Parameters**

W
wusongqing 已提交
1032 1033 1034 1035
| 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 已提交
1036 1037 1038 1039 1040 1041 1042 1043 1044

**Example**

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

1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065
## CameraInputErrorCode

Enumerates the CameraInput error code.

**System capability**: SystemCapability.Multimedia.Camera.Core

| Name                  | Default Value| Description        |
| ---------------------- | ------ | ------------ |
| ERROR_UNKNOWN       | -1      | Unknown error.|

## CameraInputError

Camera input error object which extends **Error** interface.

**System capability**: SystemCapability.Multimedia.Camera.Core

**Parameters**

| Name                  | Default Value| Description        |
| ---------------------- | ------ | ------------ |
| code                | [CameraInputErrorCode](#camerainputerrorcode)     | Used to get error code in CameraInput on('error') callback|
N
nikhilraut 已提交
1066

W
wusongqing 已提交
1067
## FlashMode
N
nikhilraut 已提交
1068

W
wusongqing 已提交
1069
Enumerates the flash modes.
1070

W
wusongqing 已提交
1071
**System capability**: SystemCapability.Multimedia.Camera.Core
1072

W
wusongqing 已提交
1073 1074 1075 1076 1077 1078
| 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 已提交
1079

W
wusongqing 已提交
1080
## FocusMode
N
nikhilraut 已提交
1081 1082 1083

Enumerates the focus modes.

W
wusongqing 已提交
1084 1085 1086 1087 1088 1089 1090 1091
**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.        |
1092

W
wusongqing 已提交
1093
## FocusState
1094

W
wusongqing 已提交
1095
Enumerates the focus states.
N
nikhilraut 已提交
1096

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

W
wusongqing 已提交
1099 1100 1101 1102 1103
| Name                 | Default Value| Description        |
| --------------------- | ------ | ------------ |
| FOCUS_STATE_SCAN      | 0      | Scanning.  |
| FOCUS_STATE_FOCUSED   | 1      | Focused.|
| FOCUS_STATE_UNFOCUSED | 2      | Unfocused.|
N
nikhilraut 已提交
1104

W
wusongqing 已提交
1105
## camera.createCaptureSession
N
nikhilraut 已提交
1106

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

W
wusongqing 已提交
1109 1110 1111
Creates a **CaptureSession** instance. This API uses an asynchronous callback to return the instance.

**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1112 1113 1114

**Parameters**

W
wusongqing 已提交
1115 1116 1117 1118
| Name    | Type                                             | Mandatory| Description                                  |
| -------- | ------------------------------------------------- | ---- | -------------------------------------- |
| context  | Context                                           | Yes  | Application context.                          |
| callback | AsyncCallback<[CaptureSession](#capturesession)\> | Yes  | Callback used to return the **CaptureSession** instance.|
N
nikhilraut 已提交
1119 1120 1121 1122

**Example**

```
W
wusongqing 已提交
1123
camera.createCaptureSession((context), (err, captureSession) => {
N
nikhilraut 已提交
1124 1125 1126 1127 1128 1129 1130 1131
    if (err) {
        console.error('Failed to create the CaptureSession instance. ${err.message}');
        return;
    }
    console.log('Callback returned with the CaptureSession instance.' + captureSession);
});
```

W
wusongqing 已提交
1132
## camera.createCaptureSession
N
nikhilraut 已提交
1133

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

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

W
wusongqing 已提交
1138
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1139 1140 1141

**Parameters**

W
wusongqing 已提交
1142 1143 1144
| Name   | Type   | Mandatory| Description        |
| ------- | ------- | ---- | ------------ |
| context | Context | Yes  | Application context.|
N
nikhilraut 已提交
1145

W
wusongqing 已提交
1146
**Return value**
N
nikhilraut 已提交
1147

W
wusongqing 已提交
1148 1149 1150
| Type                                       | Description                                     |
| ------------------------------------------- | ----------------------------------------- |
| Promise<[CaptureSession](#capturesession)\> | Promise used to return the **CaptureSession** instance.|
N
nikhilraut 已提交
1151 1152 1153 1154

**Example**

```
W
wusongqing 已提交
1155
camera.createCaptureSession(context).then((captureSession) => {
N
nikhilraut 已提交
1156 1157 1158 1159
    console.log('Promise returned with the CaptureSession instance');
})
```

W
wusongqing 已提交
1160
## CaptureSession
N
nikhilraut 已提交
1161 1162 1163

Implements session capture.

W
wusongqing 已提交
1164
### beginConfig
N
nikhilraut 已提交
1165

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

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

W
wusongqing 已提交
1170
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1171 1172 1173

**Parameters**

W
wusongqing 已提交
1174 1175 1176
| Name    | Type                | Mandatory| Description                    |
| -------- | -------------------- | ---- | ------------------------ |
| callback | AsyncCallback<void\> | Yes  | Callback used to return the result.|
N
nikhilraut 已提交
1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189

**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 已提交
1190
### beginConfig
N
nikhilraut 已提交
1191

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

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

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

W
wusongqing 已提交
1198
**Return value**
N
nikhilraut 已提交
1199

W
wusongqing 已提交
1200 1201 1202
| Type          | Description                       |
| -------------- | --------------------------- |
| Promise<void\> | Promise used to return the result.|
N
nikhilraut 已提交
1203 1204 1205 1206 1207 1208 1209 1210 1211 1212


**Example**

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

W
wusongqing 已提交
1213
### commitConfig
N
nikhilraut 已提交
1214

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

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

W
wusongqing 已提交
1219
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1220 1221 1222

**Parameters**

W
wusongqing 已提交
1223 1224 1225
| Name    | Type                | Mandatory| Description                    |
| -------- | -------------------- | ---- | ------------------------ |
| callback | AsyncCallback<void\> | Yes  | Callback used to return the result.|
N
nikhilraut 已提交
1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238

**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 已提交
1239
### commitConfig
N
nikhilraut 已提交
1240

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

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

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

W
wusongqing 已提交
1247
**Return value**
N
nikhilraut 已提交
1248

W
wusongqing 已提交
1249 1250 1251
| Type          | Description                       |
| -------------- | --------------------------- |
| Promise<void\> | Promise used to return the result.|
N
nikhilraut 已提交
1252 1253 1254 1255 1256 1257 1258 1259 1260

**Example**

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

W
wusongqing 已提交
1261
### addInput
N
nikhilraut 已提交
1262

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

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

W
wusongqing 已提交
1267
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1268 1269 1270

**Parameters**

W
wusongqing 已提交
1271 1272 1273 1274
| Name       | Type                       | Mandatory| Description                       |
| ----------- | --------------------------- | ---- | --------------------------- |
| cameraInput | [CameraInput](#camerainput) | Yes  | **CameraInput** instance to add.|
| callback    | AsyncCallback<void\>        | Yes  | Callback used to return the result.   |
N
nikhilraut 已提交
1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287

**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 已提交
1288
### addInput
N
nikhilraut 已提交
1289

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

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

W
wusongqing 已提交
1294
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1295 1296 1297

**Parameters**

W
wusongqing 已提交
1298 1299 1300
| Name       | Type                       | Mandatory| Description                       |
| ----------- | --------------------------- | ---- | --------------------------- |
| cameraInput | [CameraInput](#camerainput) | Yes  | **CameraInput** instance to add.|
N
nikhilraut 已提交
1301

W
wusongqing 已提交
1302
**Return value**
N
nikhilraut 已提交
1303

W
wusongqing 已提交
1304 1305 1306
| Type          | Description                       |
| -------------- | --------------------------- |
| Promise<void\> | Promise used to return the result.|
N
nikhilraut 已提交
1307 1308 1309 1310 1311 1312 1313 1314 1315

**Example**

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

W
wusongqing 已提交
1316
### addOutput
N
nikhilraut 已提交
1317

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

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

W
wusongqing 已提交
1322
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1323 1324 1325

**Parameters**

W
wusongqing 已提交
1326 1327 1328 1329
| Name         | Type                           | Mandatory| Description                         |
| ------------- | ------------------------------- | ---- | ----------------------------- |
| previewOutput | [PreviewOutput](#previewoutput) | Yes  | **PreviewOutput** instance to add.|
| callback      | AsyncCallback<void\>            | Yes  | Callback used to return the result.     |
N
nikhilraut 已提交
1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342

**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 已提交
1343
### addOutput
N
nikhilraut 已提交
1344

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

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

W
wusongqing 已提交
1349
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1350 1351 1352

**Parameters**

W
wusongqing 已提交
1353 1354 1355
| Name         | Type                           | Mandatory| Description                         |
| ------------- | ------------------------------- | ---- | ----------------------------- |
| previewOutput | [PreviewOutput](#previewoutput) | Yes  | **PreviewOutput** instance to add.|
N
nikhilraut 已提交
1356

W
wusongqing 已提交
1357
**Return value**
N
nikhilraut 已提交
1358

W
wusongqing 已提交
1359 1360 1361
| Type          | Description                       |
| -------------- | --------------------------- |
| Promise<void\> | Promise used to return the result.|
N
nikhilraut 已提交
1362 1363 1364 1365 1366 1367 1368 1369 1370

**Example**

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

W
wusongqing 已提交
1371
### addOutput
N
nikhilraut 已提交
1372

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

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

W
wusongqing 已提交
1377
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1378 1379 1380

**Parameters**

W
wusongqing 已提交
1381 1382 1383 1384
| Name       | Type                       | Mandatory| Description                       |
| ----------- | --------------------------- | ---- | --------------------------- |
| photoOutput | [PhotoOutput](#photooutput) | Yes  | **PhotoOutput** instance to add.|
| callback    | AsyncCallback<void\>        | Yes  | Callback used to return the result.   |
N
nikhilraut 已提交
1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397

**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 已提交
1398
### addOutput
N
nikhilraut 已提交
1399

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

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

W
wusongqing 已提交
1404
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1405 1406 1407

**Parameters**

W
wusongqing 已提交
1408 1409 1410
| Name       | Type                       | Mandatory| Description                       |
| ----------- | --------------------------- | ---- | --------------------------- |
| photoOutput | [PhotoOutput](#photooutput) | Yes  | **PhotoOutput** instance to add.|
N
nikhilraut 已提交
1411

W
wusongqing 已提交
1412
**Return value**
N
nikhilraut 已提交
1413 1414

| Type          | Description                       |
W
wusongqing 已提交
1415 1416
| -------------- | --------------------------- |
| Promise\<void> | Promise used to return the result.|
N
nikhilraut 已提交
1417 1418 1419 1420

**Example**

```
N
nikhilraut 已提交
1421
captureSession.addOutput(photoOutput).then(() => {
N
nikhilraut 已提交
1422 1423 1424 1425
    console.log('Promise used to indicate that the PhotoOutput instance is added.');
})
```

W
wusongqing 已提交
1426
### addOutput
N
nikhilraut 已提交
1427

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

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

W
wusongqing 已提交
1432
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1433 1434 1435

**Parameters**

W
wusongqing 已提交
1436 1437 1438 1439
| Name       | Type                       | Mandatory| Description                       |
| ----------- | --------------------------- | ---- | --------------------------- |
| videoOutput | [VideoOutput](#videooutput) | Yes  | **VideoOutput** instance to add.|
| callback    | AsyncCallback<void\>        | Yes  | Callback used to return the result.   |
N
nikhilraut 已提交
1440 1441 1442 1443

**Example**

```
N
nikhilraut 已提交
1444
captureSession.addOutput(videoOutput, (err) => {
N
nikhilraut 已提交
1445 1446 1447 1448 1449 1450 1451 1452
    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 已提交
1453
### addOutput
N
nikhilraut 已提交
1454

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

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

W
wusongqing 已提交
1459
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1460 1461 1462

**Parameters**

W
wusongqing 已提交
1463 1464 1465
| Name       | Type                       | Mandatory| Description                       |
| ----------- | --------------------------- | ---- | --------------------------- |
| videoOutput | [VideoOutput](#videooutput) | Yes  | **VideoOutput** instance to add.|
N
nikhilraut 已提交
1466

W
wusongqing 已提交
1467
**Return value**
N
nikhilraut 已提交
1468

W
wusongqing 已提交
1469 1470 1471
| Type          | Description                       |
| -------------- | --------------------------- |
| Promise\<void> | Promise used to return the result.|
N
nikhilraut 已提交
1472 1473 1474 1475

**Example**

```
N
nikhilraut 已提交
1476
captureSession.addOutput(videoOutput).then(() => {
N
nikhilraut 已提交
1477 1478 1479 1480
    console.log('Promise used to indicate that the VideoOutput instance is added.');
})
```

W
wusongqing 已提交
1481
### removeInput
N
nikhilraut 已提交
1482

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

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

W
wusongqing 已提交
1487
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1488 1489 1490

**Parameters**

W
wusongqing 已提交
1491 1492 1493 1494
| Name       | Type                       | Mandatory| Description                       |
| ----------- | --------------------------- | ---- | --------------------------- |
| cameraInput | [CameraInput](#camerainput) | Yes  | **CameraInput** instance to remove.|
| callback    | AsyncCallback<void\>        | Yes  | Callback used to return the result.   |
N
nikhilraut 已提交
1495 1496 1497 1498

**Example**

```
N
nikhilraut 已提交
1499
captureSession.removeInput(cameraInput, (err) => {
N
nikhilraut 已提交
1500 1501 1502 1503 1504 1505 1506 1507
    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 已提交
1508
### removeInput
N
nikhilraut 已提交
1509

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

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

W
wusongqing 已提交
1514
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1515 1516 1517

**Parameters**

W
wusongqing 已提交
1518 1519 1520
| Name       | Type                       | Mandatory| Description                       |
| ----------- | --------------------------- | ---- | --------------------------- |
| cameraInput | [CameraInput](#camerainput) | Yes  | **CameraInput** instance to remove.|
N
nikhilraut 已提交
1521

W
wusongqing 已提交
1522
**Return value**
N
nikhilraut 已提交
1523

W
wusongqing 已提交
1524 1525 1526
| Type          | Description                       |
| -------------- | --------------------------- |
| Promise\<void> | Promise used to return the result.|
N
nikhilraut 已提交
1527 1528 1529 1530

**Example**

```
N
nikhilraut 已提交
1531
captureSession.removeInput(cameraInput).then(() => {
N
nikhilraut 已提交
1532 1533 1534 1535
    console.log('Promise returned to indicate that the cameraInput instance is removed.');
})
```

W
wusongqing 已提交
1536
### removeOutput
N
nikhilraut 已提交
1537

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

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

W
wusongqing 已提交
1542
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1543 1544 1545

**Parameters**

W
wusongqing 已提交
1546 1547 1548 1549
| Name         | Type                           | Mandatory| Description                         |
| ------------- | ------------------------------- | ---- | ----------------------------- |
| previewOutput | [PreviewOutput](#previewoutput) | Yes  | **PreviewOutput** instance to remove.|
| callback      | AsyncCallback<void\>            | Yes  | Callback used to return the result.     |
N
nikhilraut 已提交
1550 1551 1552 1553

**Example**

```
N
nikhilraut 已提交
1554
captureSession.removeOutput(previewOutput, (err) => {
N
nikhilraut 已提交
1555 1556 1557 1558 1559 1560 1561 1562
    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 已提交
1563
### removeOutput
N
nikhilraut 已提交
1564

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

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

W
wusongqing 已提交
1569
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1570 1571 1572

**Parameters**

W
wusongqing 已提交
1573 1574 1575
| Name         | Type                           | Mandatory| Description                         |
| ------------- | ------------------------------- | ---- | ----------------------------- |
| previewOutput | [PreviewOutput](#previewoutput) | Yes  | **PreviewOutput** instance to remove.|
N
nikhilraut 已提交
1576 1577


W
wusongqing 已提交
1578
**Return value**
N
nikhilraut 已提交
1579

W
wusongqing 已提交
1580 1581 1582
| Type          | Description                       |
| -------------- | --------------------------- |
| Promise<void\> | Promise used to return the result.|
N
nikhilraut 已提交
1583 1584 1585 1586 1587


**Example**

```
N
nikhilraut 已提交
1588
captureSession.removeOutput(previewOutput).then(() => {
N
nikhilraut 已提交
1589 1590 1591 1592
    console.log('Promise returned to indicate that the PreviewOutput instance is removed.');
})
```

W
wusongqing 已提交
1593
### removeOutput
N
nikhilraut 已提交
1594

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

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

W
wusongqing 已提交
1599
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1600 1601 1602

**Parameters**

W
wusongqing 已提交
1603 1604 1605 1606
| Name       | Type                       | Mandatory| Description                       |
| ----------- | --------------------------- | ---- | --------------------------- |
| photoOutput | [PhotoOutput](#photooutput) | Yes  | **PhotoOutput** instance to remove.|
| callback    | AsyncCallback<void\>        | Yes  | Callback used to return the result.   |
N
nikhilraut 已提交
1607 1608 1609 1610

**Example**

```
N
nikhilraut 已提交
1611
captureSession.removeOutput(photoOutput, (err) => {
N
nikhilraut 已提交
1612 1613 1614 1615 1616 1617 1618 1619
    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 已提交
1620
### removeOutput
N
nikhilraut 已提交
1621

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

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

W
wusongqing 已提交
1626
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1627 1628 1629

**Parameters**

W
wusongqing 已提交
1630 1631 1632
| Name       | Type                       | Mandatory| Description                       |
| ----------- | --------------------------- | ---- | --------------------------- |
| photoOutput | [PhotoOutput](#photooutput) | Yes  | **PhotoOutput** instance to remove.|
N
nikhilraut 已提交
1633 1634


W
wusongqing 已提交
1635
**Return value**
N
nikhilraut 已提交
1636

W
wusongqing 已提交
1637 1638 1639
| Type          | Description                       |
| -------------- | --------------------------- |
| Promise<void\> | Promise used to return the result.|
N
nikhilraut 已提交
1640 1641 1642 1643 1644


**Example**

```
N
nikhilraut 已提交
1645
captureSession.removeOutput(photoOutput).then(() => {
N
nikhilraut 已提交
1646 1647 1648 1649
    console.log('Promise returned to indicate that the PhotoOutput instance is removed.');
})
```

W
wusongqing 已提交
1650
### removeOutput
N
nikhilraut 已提交
1651

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

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

W
wusongqing 已提交
1656
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1657 1658 1659

**Parameters**

W
wusongqing 已提交
1660 1661 1662 1663
| Name       | Type                       | Mandatory| Description                       |
| ----------- | --------------------------- | ---- | --------------------------- |
| videoOutput | [VideoOutput](#videooutput) | Yes  | **VideoOutput** instance to remove.|
| callback    | AsyncCallback<void\>        | Yes  | Callback used to return the result.   |
N
nikhilraut 已提交
1664 1665 1666 1667

**Example**

```
N
nikhilraut 已提交
1668
captureSession.removeOutput(videoOutput, (err) => {
N
nikhilraut 已提交
1669 1670 1671 1672 1673 1674 1675 1676
    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 已提交
1677
### removeOutput
N
nikhilraut 已提交
1678

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

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

W
wusongqing 已提交
1683
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1684 1685 1686

**Parameters**

W
wusongqing 已提交
1687 1688 1689
| Name       | Type                       | Mandatory| Description                       |
| ----------- | --------------------------- | ---- | --------------------------- |
| videoOutput | [VideoOutput](#videooutput) | Yes  | **VideoOutput** instance to remove.|
N
nikhilraut 已提交
1690 1691


W
wusongqing 已提交
1692
**Return value**
N
nikhilraut 已提交
1693

W
wusongqing 已提交
1694 1695 1696
| Type          | Description                       |
| -------------- | --------------------------- |
| Promise<void\> | Promise used to return the result.|
N
nikhilraut 已提交
1697 1698 1699 1700 1701


**Example**

```
N
nikhilraut 已提交
1702
captureSession.removeOutput(videoOutput).then(() => {
N
nikhilraut 已提交
1703 1704 1705 1706
    console.log('Promise returned to indicate that the VideoOutput instance is removed.');
})
```

W
wusongqing 已提交
1707
### start
N
nikhilraut 已提交
1708

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

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

W
wusongqing 已提交
1713
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1714 1715 1716

**Parameters**

W
wusongqing 已提交
1717 1718 1719
| Name    | Type                | Mandatory| Description                    |
| -------- | -------------------- | ---- | ------------------------ |
| callback | AsyncCallback<void\> | Yes  | Callback used to return the result.|
N
nikhilraut 已提交
1720 1721 1722 1723

**Example**

```
N
nikhilraut 已提交
1724
captureSession.start((err) => {
N
nikhilraut 已提交
1725 1726 1727 1728 1729 1730 1731 1732
    if (err) {
        console.error('Failed to start the session ${err.message}');
        return;
    }
    console.log('Callback invoked to indicate the session start success.');
});
```

W
wusongqing 已提交
1733
### start
N
nikhilraut 已提交
1734

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

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

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

W
wusongqing 已提交
1741
**Return value**
N
nikhilraut 已提交
1742

W
wusongqing 已提交
1743 1744 1745
| Type          | Description                       |
| -------------- | --------------------------- |
| Promise<void\> | Promise used to return the result.|
N
nikhilraut 已提交
1746 1747 1748 1749

**Example**

```
N
nikhilraut 已提交
1750
captureSession.start().then(() => {
N
nikhilraut 已提交
1751 1752 1753 1754
    console.log('Promise returned to indicate the session start success.');
})
```

W
wusongqing 已提交
1755
### stop
N
nikhilraut 已提交
1756

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

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

W
wusongqing 已提交
1761
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1762 1763 1764 1765

**Parameters**


W
wusongqing 已提交
1766 1767 1768
| Name    | Type                | Mandatory| Description                    |
| -------- | -------------------- | ---- | ------------------------ |
| callback | AsyncCallback<void\> | Yes  | Callback used to return the result.|
N
nikhilraut 已提交
1769 1770 1771 1772

**Example**

```
N
nikhilraut 已提交
1773
captureSession.stop((err) => {
N
nikhilraut 已提交
1774 1775 1776 1777 1778 1779 1780 1781
    if (err) {
        console.error('Failed to stop the session ${err.message}');
        return;
    }
    console.log('Callback invoked to indicate the session stop success.');
});
```

W
wusongqing 已提交
1782
### stop
N
nikhilraut 已提交
1783

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

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

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

W
wusongqing 已提交
1790
**Return value**
N
nikhilraut 已提交
1791

W
wusongqing 已提交
1792 1793 1794
| Type          | Description                       |
| -------------- | --------------------------- |
| Promise<void\> | Promise used to return the result.|
N
nikhilraut 已提交
1795 1796 1797 1798

**Example**

```
N
nikhilraut 已提交
1799
captureSession.stop().then(() => {
N
nikhilraut 已提交
1800 1801 1802 1803
    console.log('Promise returned to indicate the session stop success.');
})
```

W
wusongqing 已提交
1804
### release
N
nikhilraut 已提交
1805

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

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

W
wusongqing 已提交
1810
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1811 1812 1813

**Parameters**

W
wusongqing 已提交
1814 1815 1816
| Name    | Type                | Mandatory| Description                    |
| -------- | -------------------- | ---- | ------------------------ |
| callback | AsyncCallback<void\> | Yes  | Callback used to return the result.|
N
nikhilraut 已提交
1817 1818 1819 1820

**Example**

```
N
nikhilraut 已提交
1821
captureSession.release((err) => {
N
nikhilraut 已提交
1822 1823 1824 1825 1826 1827 1828 1829
    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 已提交
1830
### release
N
nikhilraut 已提交
1831

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

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

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

W
wusongqing 已提交
1838
**Return value**
N
nikhilraut 已提交
1839

W
wusongqing 已提交
1840 1841 1842
| Type          | Description                       |
| -------------- | --------------------------- |
| Promise<void\> | Promise used to return the result.|
N
nikhilraut 已提交
1843 1844 1845 1846

**Example**

```
N
nikhilraut 已提交
1847
captureSession.release().then(() => {
N
nikhilraut 已提交
1848 1849 1850 1851
    console.log('Promise returned to indicate that the CaptureSession instance is released successfully.');
})
```

W
wusongqing 已提交
1852
### on('error')
N
nikhilraut 已提交
1853

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

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

W
wusongqing 已提交
1858
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1859 1860 1861

**Parameters**

W
wusongqing 已提交
1862 1863 1864 1865
| 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 已提交
1866 1867 1868 1869 1870 1871 1872 1873 1874

**Example**

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

1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896
## CaptureSessionErrorCode

Enumerates the CaptureSession error code.

**System capability**: SystemCapability.Multimedia.Camera.Core

| Name                  | Default Value| Description        |
| ---------------------- | ------ | ------------ |
| ERROR_UNKNOWN       | -1      | Unknown error.|

## CaptureSessionError

Capture session error object which extends **Error** interface.

**System capability**: SystemCapability.Multimedia.Camera.Core

**Parameters**

| Name                  | Default Value| Description        |
| ---------------------- | ------ | ------------ |
| code                | [CaptureSessionErrorCode](#capturesessionerrorcode)     | Used to get error code in CaptureSession on('error') callback.|

W
wusongqing 已提交
1897
## camera.createPreviewOutput
N
nikhilraut 已提交
1898

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

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

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

**Parameters**

W
wusongqing 已提交
1907 1908 1909 1910
| 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 已提交
1911 1912 1913 1914

**Example**

```
1915
camera.createPreviewOutput(("surfaceId"), (err, previewOutput) => {
N
nikhilraut 已提交
1916 1917 1918 1919 1920 1921
    if (err) {
        console.error('Failed to create the PreviewOutput instance. ${err.message}');
        return;
    }
    console.log('Callback returned with previewOutput instance');
});
W
wusongqing 已提交
1922
```
N
nikhilraut 已提交
1923

W
wusongqing 已提交
1924
## camera.createPreviewOutput
N
nikhilraut 已提交
1925

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

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

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

**Parameters**

W
wusongqing 已提交
1934 1935 1936
| Name     | Type  | Mandatory| Description                              |
| --------- | ------ | ---- | ---------------------------------- |
| surfaceId | string | Yes  | Surface ID received from **XComponent**.|
N
nikhilraut 已提交
1937

W
wusongqing 已提交
1938
**Return value**
N
nikhilraut 已提交
1939

W
wusongqing 已提交
1940 1941 1942
| Type                                     | Description                       |
| ----------------------------------------- | --------------------------- |
| Promise<[PreviewOutput](#previewoutput)\> | Promise used to return the **PreviewOutput** instance.|
N
nikhilraut 已提交
1943 1944 1945 1946

**Example**

```
J
jiangminyang 已提交
1947
camera.createPreviewOutput("surfaceId").then((previewOutput) => {
N
nikhilraut 已提交
1948 1949 1950 1951 1952 1953 1954 1955
    console.log('Promise returned with the PreviewOutput instance');
})
```

## PreviewOutput

Implements preview output.

W
wusongqing 已提交
1956
### release
N
nikhilraut 已提交
1957

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

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

W
wusongqing 已提交
1962
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1963 1964 1965

**Parameters**

W
wusongqing 已提交
1966 1967 1968
| Name    | Type                | Mandatory| Description                    |
| -------- | -------------------- | ---- | ------------------------ |
| callback | AsyncCallback<void\> | Yes  | Callback used to return the result.|
N
nikhilraut 已提交
1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981

**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 已提交
1982
### release
N
nikhilraut 已提交
1983

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

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

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

W
wusongqing 已提交
1990
**Return value**
N
nikhilraut 已提交
1991

W
wusongqing 已提交
1992 1993 1994
| Type          | Description                       |
| -------------- | --------------------------- |
| Promise<void\> | Promise used to return the result.|
N
nikhilraut 已提交
1995 1996 1997 1998 1999 2000 2001 2002 2003 2004


**Example**

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

W
wusongqing 已提交
2005
### on('frameStart')
N
nikhilraut 已提交
2006

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

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

W
wusongqing 已提交
2011
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
2012 2013 2014

**Parameters**

W
wusongqing 已提交
2015 2016 2017 2018
| 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 已提交
2019 2020 2021 2022 2023 2024 2025 2026 2027

**Example**

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

W
wusongqing 已提交
2028
### on('frameEnd')
N
nikhilraut 已提交
2029

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

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

W
wusongqing 已提交
2034
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
2035 2036 2037

**Parameters**

W
wusongqing 已提交
2038 2039 2040 2041
| 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 已提交
2042 2043 2044 2045 2046 2047 2048 2049 2050

**Example**

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

W
wusongqing 已提交
2051
### on('error')
N
nikhilraut 已提交
2052

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

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

W
wusongqing 已提交
2057
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
2058 2059 2060

**Parameters**

W
wusongqing 已提交
2061 2062 2063 2064
| 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 已提交
2065 2066 2067 2068 2069 2070 2071 2072 2073

**Example**

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

2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095
## PreviewOutputErrorCode

Enumerates the PreviewOutput error code.

**System capability**: SystemCapability.Multimedia.Camera.Core

| Name                  | Default Value| Description        |
| ---------------------- | ------ | ------------ |
| ERROR_UNKNOWN       | -1      | Unknown error.|

## PreviewOutputError

Preview output error object which extends **Error** interface.

**System capability**: SystemCapability.Multimedia.Camera.Core

**Parameters**

| Name                  | Default Value| Description        |
| ---------------------- | ------ | ------------ |
| code                | [PreviewOutputErrorCode](#previewoutputerrorcode)     | Used to get error code in PreviewOutput on('error') callback.|

W
wusongqing 已提交
2096
## camera.createPhotoOutput
N
nikhilraut 已提交
2097

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

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

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

**Parameters**

W
wusongqing 已提交
2106 2107 2108 2109
| 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 已提交
2110 2111 2112 2113

**Example**

```
J
jiangminyang 已提交
2114
camera.createPhotoOutput(("surfaceId"), (err, photoOutput) => {
N
nikhilraut 已提交
2115 2116 2117 2118 2119 2120
    if (err) {
        console.error('Failed to create the PhotoOutput instance. ${err.message}');
        return;
    }
    console.log('Callback returned with the PhotoOutput instance.');
});
W
wusongqing 已提交
2121
```
N
nikhilraut 已提交
2122

W
wusongqing 已提交
2123
## camera.createPhotoOutput
N
nikhilraut 已提交
2124

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

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

W
wusongqing 已提交
2129
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
2130 2131 2132

**Parameters**

W
wusongqing 已提交
2133 2134 2135
| Name     | Type  | Mandatory| Description                             |
| --------- | ------ | ---- | --------------------------------- |
| surfaceId | string | Yes  | Surface ID received from **ImageReceiver**.|
N
nikhilraut 已提交
2136

W
wusongqing 已提交
2137
**Return value**
N
nikhilraut 已提交
2138

W
wusongqing 已提交
2139 2140 2141
| Type                                 | Description                                  |
| ------------------------------------- | -------------------------------------- |
| Promise<[PhotoOutput](#photooutput)\> | Promise used to return the **PhotoOutput** instance.|
N
nikhilraut 已提交
2142 2143 2144 2145

**Example**

```
J
jiangminyang 已提交
2146
camera.createPhotoOutput("surfaceId").then((photoOutput) => {
N
nikhilraut 已提交
2147 2148 2149 2150 2151 2152 2153
    console.log('Promise returned with PhotoOutput instance');
})
```
## ImageRotation

Enumerates the image rotation angles.

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

W
wusongqing 已提交
2156 2157 2158 2159 2160 2161
| 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 已提交
2162 2163 2164 2165 2166 2167 2168



## QualityLevel

Enumerates the image quality levels.

W
wusongqing 已提交
2169
**System capability**: SystemCapability.Multimedia.Camera.Core
2170

W
wusongqing 已提交
2171 2172 2173 2174 2175
| 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 已提交
2176 2177 2178 2179 2180 2181


## PhotoCaptureSetting

Defines the settings for image capture.

W
wusongqing 已提交
2182
**System capability**: SystemCapability.Multimedia.Camera.Core
2183

W
wusongqing 已提交
2184 2185 2186 2187
| Name    | Type                           | Mandatory| Description          |
| -------- | ------------------------------- | ---- | -------------- |
| quality  | [QualityLevel](#qualitylevel)   | No  | Photo image quality.    |
| rotation | [ImageRotation](#imagerotation) | No  | Photo rotation.|
N
nikhilraut 已提交
2188 2189 2190 2191 2192 2193


## PhotoOutput

Implements photo output.

W
wusongqing 已提交
2194
### capture
N
nikhilraut 已提交
2195

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

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

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

**Parameters**

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

**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 已提交
2220
### capture
N
nikhilraut 已提交
2221

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

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

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

**Parameters**

W
wusongqing 已提交
2230 2231 2232 2233
| Name    | Type                                       | Mandatory| Description                    |
| -------- | ------------------------------------------- | ---- | ------------------------ |
| setting  | [PhotoCaptureSetting](#photocapturesetting) | Yes  | Photo capture settings.              |
| callback | AsyncCallback<void\>                        | Yes  | Callback used to return the result.|
N
nikhilraut 已提交
2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246

**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 已提交
2247
### capture
N
nikhilraut 已提交
2248

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

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

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

**Parameters**

W
wusongqing 已提交
2257 2258 2259
| Name   | Type                                       | Mandatory| Description      |
| ------- | ------------------------------------------- | ---- | ---------- |
| setting | [PhotoCaptureSetting](#photocapturesetting) | No  | Photo capture settings.|
N
nikhilraut 已提交
2260

W
wusongqing 已提交
2261
**Return value**
N
nikhilraut 已提交
2262

W
wusongqing 已提交
2263 2264 2265
| Type          | Description                       |
| -------------- | --------------------------- |
| Promise<void\> | Promise used to return the result.|
N
nikhilraut 已提交
2266 2267 2268 2269 2270 2271 2272 2273 2274 2275


**Example**

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

W
wusongqing 已提交
2276
### release
N
nikhilraut 已提交
2277

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

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

W
wusongqing 已提交
2282
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
2283 2284 2285

**Parameters**

W
wusongqing 已提交
2286 2287 2288
| Name    | Type                | Mandatory| Description                    |
| -------- | -------------------- | ---- | ------------------------ |
| callback | AsyncCallback<void\> | Yes  | Callback used to return the result.|
N
nikhilraut 已提交
2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301

**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 已提交
2302
### release
N
nikhilraut 已提交
2303

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

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

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

W
wusongqing 已提交
2310
**Return value**
N
nikhilraut 已提交
2311

W
wusongqing 已提交
2312 2313 2314
| Type          | Description                       |
| -------------- | --------------------------- |
| Promise<void\> | Promise used to return the result.|
N
nikhilraut 已提交
2315 2316 2317 2318 2319 2320 2321 2322 2323 2324


**Example**

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

W
wusongqing 已提交
2325
### on('captureStart')
N
nikhilraut 已提交
2326

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

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

W
wusongqing 已提交
2331
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
2332 2333 2334

**Parameters**

W
wusongqing 已提交
2335 2336 2337 2338
| 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 已提交
2339 2340 2341 2342

**Example**

```
J
jiangminyang 已提交
2343
photoOutput.on('captureStart', (err, captureId) => {
N
nikhilraut 已提交
2344 2345 2346 2347
    console.log('photo capture stated, captureId : ' + captureId);
})
```

W
wusongqing 已提交
2348
### on('frameShutter')
N
nikhilraut 已提交
2349

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

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

W
wusongqing 已提交
2354
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
2355 2356 2357

**Parameters**

W
wusongqing 已提交
2358 2359 2360 2361
| 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 已提交
2362 2363 2364 2365 2366 2367 2368 2369 2370 2371

**Example**

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

W
wusongqing 已提交
2372
### on('captureEnd')
N
nikhilraut 已提交
2373

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

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

W
wusongqing 已提交
2378
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
2379 2380 2381

**Parameters**

W
wusongqing 已提交
2382 2383 2384 2385
| 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 已提交
2386 2387 2388 2389 2390 2391 2392 2393 2394 2395

**Example**

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

W
wusongqing 已提交
2396
### on('error')
N
nikhilraut 已提交
2397

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

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

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

**Parameters**

W
wusongqing 已提交
2406 2407 2408 2409
| 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 已提交
2410 2411 2412 2413 2414 2415 2416 2417 2418

**Example**

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

2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462
### FrameShutterInfo

Frame shutter callback info which provides **captureId** & **timestamp** parameteres & indicates the frame shutter event.

**Parameteres**

| Name    | Type                            | Mandatory| Description                                     |
| :------- | :------------------------------- | :--- | :---------------------------------------- |
| captureId     | number                           | Yes  | Capture id.|
| timestamp | number | Yes  | Timestamp for frame.    

### CaptureEndInfo

Capture end info which provides **captureId** & **frameCount** parameteres & indicates the photo capture end event.

**Parameteres**

| Name    | Type                            | Mandatory| Description                                     |
| :------- | :------------------------------- | :--- | :---------------------------------------- |
| captureId     | number                           | Yes  | Capture id.|
| frameCount | number | Yes  | Frame count.    

## PhotoOutputErrorCode

Enumerates the PhotoOutput error code.

**System capability**: SystemCapability.Multimedia.Camera.Core

| Name                  | Default Value| Description        |
| ---------------------- | ------ | ------------ |
| ERROR_UNKNOWN       | -1      | Unknown error.|

## PhotoOutputError

Photo output error object which extends **Error** interface.

**System capability**: SystemCapability.Multimedia.Camera.Core

**Parameters**

| Name                  | Default Value| Description        |
| ---------------------- | ------ | ------------ |
| code                | [PhotoOutputErrorCode](#photooutputerrorcode)     | Used to get error code in PhotoOutput on('error') callback.|

W
wusongqing 已提交
2463
## camera.createVideoOutput
N
nikhilraut 已提交
2464

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

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

W
wusongqing 已提交
2469
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
2470 2471 2472

**Parameters**

W
wusongqing 已提交
2473 2474 2475 2476
| 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 已提交
2477 2478 2479 2480

**Example**

```
J
jiangminyang 已提交
2481
camera.createVideoOutput(("surfaceId"), (err, videoOutput) => {
N
nikhilraut 已提交
2482 2483 2484 2485 2486 2487
    if (err) {
        console.error('Failed to create the VideoOutput instance. ${err.message}');
        return;
    }
    console.log('Callback returned with the VideoOutput instance');
});
W
wusongqing 已提交
2488
```
N
nikhilraut 已提交
2489

W
wusongqing 已提交
2490
## camera.createVideoOutput
N
nikhilraut 已提交
2491

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

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

W
wusongqing 已提交
2496
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
2497 2498 2499

**Parameters**

W
wusongqing 已提交
2500 2501 2502
| Name     | Type  | Mandatory| Description                             |
| --------- | ------ | ---- | --------------------------------- |
| surfaceId | string | Yes  | Surface ID received from **VideoRecorder**.|
N
nikhilraut 已提交
2503

W
wusongqing 已提交
2504
**Return value**
N
nikhilraut 已提交
2505

W
wusongqing 已提交
2506 2507 2508
| Type                                 | Description                                  |
| ------------------------------------- | -------------------------------------- |
| Promise<[VideoOutput](#videooutput)\> | Promise used to return the **VideoOutput** instance.|
N
nikhilraut 已提交
2509 2510 2511 2512

**Example**

```
J
jiangminyang 已提交
2513 2514
camera.createVideoOutput("surfaceId"
).then((videoOutput) => {
N
nikhilraut 已提交
2515 2516 2517
    console.log('Promise returned with the VideoOutput instance');
})
```
W
wusongqing 已提交
2518

N
nikhilraut 已提交
2519 2520 2521
## VideoOutput

Implements video output.
N
nikhilraut 已提交
2522

W
wusongqing 已提交
2523
### start
N
nikhilraut 已提交
2524

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

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

W
wusongqing 已提交
2529
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
2530 2531 2532

**Parameters**

W
wusongqing 已提交
2533 2534 2535
| Name    | Type                | Mandatory| Description                    |
| -------- | -------------------- | ---- | ------------------------ |
| callback | AsyncCallback<void\> | Yes  | Callback used to return the result.|
N
nikhilraut 已提交
2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548

**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 已提交
2549
### start
N
nikhilraut 已提交
2550

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

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

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

W
wusongqing 已提交
2557
**Return value**
N
nikhilraut 已提交
2558

W
wusongqing 已提交
2559 2560 2561
| Type          | Description                       |
| -------------- | --------------------------- |
| Promise<void\> | Promise used to return the result.|
N
nikhilraut 已提交
2562 2563 2564 2565 2566 2567 2568 2569 2570 2571


**Example**

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

W
wusongqing 已提交
2572
### stop
N
nikhilraut 已提交
2573

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

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

W
wusongqing 已提交
2578
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
2579 2580 2581

**Parameters**

W
wusongqing 已提交
2582 2583 2584
| Name    | Type                | Mandatory| Description                    |
| -------- | -------------------- | ---- | ------------------------ |
| callback | AsyncCallback<void\> | Yes  | Callback used to return the result.|
N
nikhilraut 已提交
2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597

**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 已提交
2598
### stop
N
nikhilraut 已提交
2599

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

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

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

W
wusongqing 已提交
2606
**Return value**
N
nikhilraut 已提交
2607

W
wusongqing 已提交
2608 2609 2610
| Type          | Description                       |
| -------------- | --------------------------- |
| Promise<void\> | Promise used to return the result.|
N
nikhilraut 已提交
2611 2612 2613 2614 2615 2616 2617 2618 2619

**Example**

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

W
wusongqing 已提交
2620
### release
N
nikhilraut 已提交
2621

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

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

W
wusongqing 已提交
2626
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
2627 2628 2629

**Parameters**

W
wusongqing 已提交
2630 2631 2632
| Name    | Type                | Mandatory| Description                    |
| -------- | -------------------- | ---- | ------------------------ |
| callback | AsyncCallback<void\> | Yes  | Callback used to return the result.|
N
nikhilraut 已提交
2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645

**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 已提交
2646
### release
N
nikhilraut 已提交
2647

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

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

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

W
wusongqing 已提交
2654
**Return value**
N
nikhilraut 已提交
2655

W
wusongqing 已提交
2656 2657 2658
| Type          | Description                       |
| -------------- | --------------------------- |
| Promise<void\> | Promise used to return the result.|
N
nikhilraut 已提交
2659 2660 2661 2662 2663 2664 2665 2666


**Example**

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

W
wusongqing 已提交
2669
### on('frameStart')
N
nikhilraut 已提交
2670

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

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

W
wusongqing 已提交
2675
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
2676 2677 2678

**Parameters**

W
wusongqing 已提交
2679 2680 2681 2682
| 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 已提交
2683 2684 2685 2686 2687 2688 2689 2690 2691

**Example**

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

W
wusongqing 已提交
2692 2693 2694
### on('frameEnd')

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

W
wusongqing 已提交
2696 2697 2698
Listens for video frame end events. This API uses a callback to return the event information.

**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
2699 2700 2701

**Parameters**

W
wusongqing 已提交
2702 2703 2704 2705
| 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 已提交
2706 2707 2708 2709 2710 2711 2712 2713 2714

**Example**

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

W
wusongqing 已提交
2715 2716 2717
### on('error')

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

W
wusongqing 已提交
2719 2720 2721
Listens for **VideoOutput** errors. This API uses a callback to return the errors.

**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
2722 2723 2724

**Parameters**

W
wusongqing 已提交
2725 2726 2727 2728
| 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 已提交
2729 2730 2731 2732 2733 2734 2735

**Example**

```
videoOutput.on('error', (VideoOutputError) => {
    console.log('Video output error code: ' + VideoOutputError.code);
})
W
wusongqing 已提交
2736
```
2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758

## VideoOutputErrorCode

Enumerates the VideoOutput error code.

**System capability**: SystemCapability.Multimedia.Camera.Core

| Name                  | Default Value| Description        |
| ---------------------- | ------ | ------------ |
| ERROR_UNKNOWN       | -1      | Unknown error.|

## VideoOutputError

Photo output error object which extends **Error** interface.

**System capability**: SystemCapability.Multimedia.Camera.Core

**Parameters**

| Name                  | Default Value| Description        |
| ---------------------- | ------ | ------------ |
| code                | [VideoOutputErrorCode](#videooutputerrorcode)     | Used to get error code in VideoOutput on('error') callback.|