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

W
wusongqing 已提交
3 4
> **NOTE**
>
5
> 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 已提交
6

N
nikhilraut 已提交
7 8
## Modules to Import

W
wusongqing 已提交
9
```js
N
nikhilraut 已提交
10 11 12
import camera from '@ohos.multimedia.camera';
```

W
wusongqing 已提交
13
## camera.getCameraManager
N
nikhilraut 已提交
14

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

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

W
wusongqing 已提交
19
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
20 21 22

**Parameters**

W
wusongqing 已提交
23 24 25 26
| Name    | Type                                           | Mandatory| Description                              |
| -------- | ----------------------------------------------- | ---- | ---------------------------------- |
| context  | Context                                         | Yes  | Application context.                      |
| callback | AsyncCallback<[CameraManager](#cameramanager)\> | Yes  | Callback used to return the **CameraManager** instance.|
N
nikhilraut 已提交
27 28 29

**Example**

W
wusongqing 已提交
30
```js
N
nikhilraut 已提交
31 32 33 34 35 36 37 38 39
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 已提交
40
## camera.getCameraManager
N
nikhilraut 已提交
41

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

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

W
wusongqing 已提交
46
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
47 48 49

**Parameters**

W
wusongqing 已提交
50 51 52
| Name   | Type   | Mandatory| Description        |
| ------- | ------- | ---- | ------------ |
| context | Context | Yes  | Application context.|
N
nikhilraut 已提交
53

W
wusongqing 已提交
54
**Return value**
N
nikhilraut 已提交
55

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

**Example**

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

W
wusongqing 已提交
68
## CameraStatus
N
nikhilraut 已提交
69

W
wusongqing 已提交
70
Enumerates the camera statuses.
N
nikhilraut 已提交
71

W
wusongqing 已提交
72
**System capability**: SystemCapability.Multimedia.Camera.Core
73

W
wusongqing 已提交
74 75 76 77 78 79
| Name                     | 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.|
80

N
nikhilraut 已提交
81

W
wusongqing 已提交
82
## CameraPosition
N
nikhilraut 已提交
83 84 85

Enumerates the camera positions.

W
wusongqing 已提交
86
**System capability**: SystemCapability.Multimedia.Camera.Core
87

W
wusongqing 已提交
88 89 90 91 92
| Name                       | Value  | Description            |
| --------------------------- | ---- | ---------------- |
| CAMERA_POSITION_UNSPECIFIED | 0    | Unspecified position.|
| CAMERA_POSITION_BACK        | 1    | Rear camera.      |
| CAMERA_POSITION_FRONT       | 2    | Front camera.      |
N
nikhilraut 已提交
93

W
wusongqing 已提交
94
## CameraType
N
nikhilraut 已提交
95 96 97

Enumerates the camera types.

W
wusongqing 已提交
98
**System capability**: SystemCapability.Multimedia.Camera.Core
99

W
wusongqing 已提交
100 101 102 103 104 105 106
| Name                   | 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.      |
107

N
nikhilraut 已提交
108

W
wusongqing 已提交
109
## ConnectionType
N
nikhilraut 已提交
110

W
wusongqing 已提交
111
Enumerates the camera connection types.
N
nikhilraut 已提交
112

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

W
wusongqing 已提交
115 116 117 118 119 120 121 122 123 124 125
| Name                        | 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. |

## Size

Defines the image size that can be used in previewing, photographing, and video recording.

**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
126

W
wusongqing 已提交
127 128 129 130
| Name  | Type  | Readable| Writable| Description        |
| ------ | ------ | ---- | ---- | ------------ |
| height | string | Yes  | Yes  | Image height.|
| width  | number | Yes  | Yes  | Image width.|
N
nikhilraut 已提交
131

W
wusongqing 已提交
132
## CameraManager
N
nikhilraut 已提交
133

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

W
wusongqing 已提交
136
### getCameras
N
nikhilraut 已提交
137

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

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

W
wusongqing 已提交
142
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
143 144 145

**Parameters**

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

**Example**

W
wusongqing 已提交
152
```js
N
nikhilraut 已提交
153 154 155 156 157 158 159 160 161
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 已提交
162
### getCameras
N
nikhilraut 已提交
163

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

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

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

W
wusongqing 已提交
170
**Return value**
N
nikhilraut 已提交
171

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


**Example**

W
wusongqing 已提交
179
```js
N
nikhilraut 已提交
180 181 182 183 184
cameraManager.getCameras().then((cameraArray) => {
    console.log('Promise returned with an array of supported cameras: ' + cameraArray.length);
})
```

W
wusongqing 已提交
185
### createCameraInput
N
nikhilraut 已提交
186

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

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

W
wusongqing 已提交
191 192
**Required permissions**: ohos.permission.CAMERA

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

**Parameters**

W
wusongqing 已提交
197
| Name    | Type                                       | Mandatory| Description                               |
W
wusongqing 已提交
198 199 200
| -------- | ------------------------------------------- | ---- | ----------------------------------- |
| cameraId | string                                      | Yes  | Camera ID used to create the instance.                       |
| callback | AsyncCallback<[CameraInput](#camerainput)\> | Yes  | Callback used to return the **CameraInput** instance.|
N
nikhilraut 已提交
201 202 203

**Example**

W
wusongqing 已提交
204
```js
N
nikhilraut 已提交
205 206 207 208 209 210 211 212 213
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 已提交
214
### createCameraInput
N
nikhilraut 已提交
215

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

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

W
wusongqing 已提交
220 221
**Required permissions**: ohos.permission.CAMERA

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

**Parameters**

W
wusongqing 已提交
226
| Name    | Type  | Mandatory| Description        |
W
wusongqing 已提交
227 228
| -------- | ------ | ---- | ------------ |
| 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

**Example**

W
wusongqing 已提交
238
```js
N
nikhilraut 已提交
239 240 241 242 243
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 251
**Required permissions**: ohos.permission.CAMERA

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

**Parameters**

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

**Example**

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

W
wusongqing 已提交
274
### createCameraInput
N
nikhilraut 已提交
275

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

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

W
wusongqing 已提交
280 281
**Required permissions**: ohos.permission.CAMERA

W
wusongqing 已提交
282
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
283 284 285

**Parameters**

W
wusongqing 已提交
286 287 288 289
| Name    | Type                             | Mandatory| Description      |
| -------- | --------------------------------- | ---- | ---------- |
| position | [CameraPosition](#cameraposition) | Yes  | Camera position.|
| type     | [CameraType](#cameratype)         | Yes  | Camera type.|
N
nikhilraut 已提交
290

W
wusongqing 已提交
291
**Return value**
N
nikhilraut 已提交
292

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

**Example**

W
wusongqing 已提交
299
```js
J
jiangminyang 已提交
300
cameraManager.createCameraInput(camera.CameraPosition.CAMERA_POSITION_BACK, camera.CameraType.CAMERA_TYPE_UNSPECIFIED).then((cameraInput) => {
N
nikhilraut 已提交
301 302 303 304
    console.log('Promise returned with the CameraInput instance.');
})
```

W
wusongqing 已提交
305
### on('cameraStatus')
N
nikhilraut 已提交
306

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

W
wusongqing 已提交
309
Listens for camera status changes. This API uses an asynchronous callback to return the camera status changes.
N
nikhilraut 已提交
310

W
wusongqing 已提交
311
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
312 313 314

**Parameters**

W
wusongqing 已提交
315 316 317 318
| 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 已提交
319 320 321

**Example**

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

W
wusongqing 已提交
333
## Camera
334

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

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

W
wusongqing 已提交
339 340 341 342 343 344
| 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 已提交
345

W
wusongqing 已提交
346
**Example**
N
nikhilraut 已提交
347

W
wusongqing 已提交
348
```js
J
jiangminyang 已提交
349
async function getCameraInfo("cameraId") {
J
jiangminyang 已提交
350
    var cameraManager = await camera.getCameraManager(context);
351 352 353 354 355
    var cameras = await cameraManager.getCameras();
    var cameraObj = cameras[0];
    var cameraId = cameraObj.cameraId;
    var cameraPosition = cameraObj.cameraPosition;
    var cameraType = cameraObj.cameraType;
356
    var connectionType = cameraObj.connectionType;
357
}
N
nikhilraut 已提交
358 359
```

W
wusongqing 已提交
360
## CameraStatusInfo
N
nikhilraut 已提交
361

W
wusongqing 已提交
362
Describes the camera status information.
N
nikhilraut 已提交
363

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

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

N
nikhilraut 已提交
371

W
wusongqing 已提交
372
## CameraInput
N
nikhilraut 已提交
373

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

W
wusongqing 已提交
376
### getCameraId
N
nikhilraut 已提交
377

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

W
wusongqing 已提交
380
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 已提交
381

W
wusongqing 已提交
382
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
383 384 385

**Parameters**

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

**Example**
N
nikhilraut 已提交
391

W
wusongqing 已提交
392
```js
N
nikhilraut 已提交
393 394 395 396 397 398 399 400 401
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 已提交
402
### getCameraId
N
nikhilraut 已提交
403

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

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

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

W
wusongqing 已提交
410
**Return value**
N
nikhilraut 已提交
411

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

**Example**

W
wusongqing 已提交
418
```js
N
nikhilraut 已提交
419 420 421 422 423 424
cameraInput.getCameraId().then((cameraId) => {
    console.log('Promise returned with the camera ID:' + cameraId);
})
```


W
wusongqing 已提交
425
### hasFlash
N
nikhilraut 已提交
426

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

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

W
wusongqing 已提交
431
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
432 433 434

**Parameters**

W
wusongqing 已提交
435 436 437
| 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 已提交
438 439 440

**Example**

W
wusongqing 已提交
441
```js
N
nikhilraut 已提交
442 443 444 445 446 447 448 449 450
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 已提交
451
### hasFlash
N
nikhilraut 已提交
452

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

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

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

W
wusongqing 已提交
459
**Return value**
N
nikhilraut 已提交
460

W
wusongqing 已提交
461 462 463
| 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 已提交
464 465 466

**Example**

W
wusongqing 已提交
467
```js
N
nikhilraut 已提交
468 469 470 471 472
cameraInput.hasFlash().then((status) => {
    console.log('Promise returned with the flash light support status:' + status);
})
```

W
wusongqing 已提交
473
### isFlashModeSupported
N
nikhilraut 已提交
474

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

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

W
wusongqing 已提交
479
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
480 481 482

**Parameters**

W
wusongqing 已提交
483 484 485 486
| 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 已提交
487 488 489

**Example**

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

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

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

W
wusongqing 已提交
506
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
507 508 509

**Parameters**

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

W
wusongqing 已提交
514
**Return value**
N
nikhilraut 已提交
515

W
wusongqing 已提交
516 517 518
| 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 已提交
519 520 521

**Example**

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

W
wusongqing 已提交
528
### setFlashMode
N
nikhilraut 已提交
529

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

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

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

W
wusongqing 已提交
536 537
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 已提交
538

W
wusongqing 已提交
539
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
540 541 542

**Parameters**

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

**Example**

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

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

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

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

W
wusongqing 已提交
568 569
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 已提交
570

W
wusongqing 已提交
571
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
572 573 574

**Parameters**

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

W
wusongqing 已提交
579
**Return value**
N
nikhilraut 已提交
580

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

**Example**

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

W
wusongqing 已提交
593
### getFlashMode
N
nikhilraut 已提交
594

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

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

W
wusongqing 已提交
599
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
600 601 602

**Parameters**

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

**Example**

W
wusongqing 已提交
609
```js
N
nikhilraut 已提交
610 611 612 613 614 615 616 617 618
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 已提交
619
### getFlashMode
N
nikhilraut 已提交
620

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

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

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

W
wusongqing 已提交
627
**Return value**
N
nikhilraut 已提交
628

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

**Example**

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

W
wusongqing 已提交
641
### isFocusModeSupported
N
nikhilraut 已提交
642

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

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

W
wusongqing 已提交
647
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
648 649 650

**Parameters**

W
wusongqing 已提交
651 652 653 654
| 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 已提交
655 656 657

**Example**

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

W
wusongqing 已提交
668
### isFocusModeSupported
N
nikhilraut 已提交
669

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

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

W
wusongqing 已提交
674
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
675 676 677

**Parameters**

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

W
wusongqing 已提交
682
**Return value**
N
nikhilraut 已提交
683

W
wusongqing 已提交
684 685
| Type             | Description                                                       |
| ----------------- | ----------------------------------------------------------- |
W
wusongqing 已提交
686
| Promise<boolean\> | Promise used to return the focus mode support status. The value **true** means that the specified focus mode is supported.|
N
nikhilraut 已提交
687 688 689

**Example**

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

W
wusongqing 已提交
696
### setFocusMode
N
nikhilraut 已提交
697

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

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

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

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

N
nikhilraut 已提交
706 707
**Parameters**

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

**Example**

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

W
wusongqing 已提交
725
### setFocusMode
N
nikhilraut 已提交
726

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

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

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

W
wusongqing 已提交
733
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
734 735 736

**Parameters**

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

W
wusongqing 已提交
741
**Return value**
N
nikhilraut 已提交
742

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

**Example**

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

W
wusongqing 已提交
755
### getFocusMode
N
nikhilraut 已提交
756

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

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

W
wusongqing 已提交
761
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
762 763 764

**Parameters**

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

**Example**

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

W
wusongqing 已提交
781
### getFocusMode
N
nikhilraut 已提交
782

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

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

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

W
wusongqing 已提交
789
**Return value**
N
nikhilraut 已提交
790

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

**Example**

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

W
wusongqing 已提交
803
### getZoomRatioRange
N
nikhilraut 已提交
804

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

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

W
wusongqing 已提交
809
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
810 811 812

**Parameters**

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

**Example**

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

W
wusongqing 已提交
829
### getZoomRatioRange
N
nikhilraut 已提交
830

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

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

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

W
wusongqing 已提交
837
**Return value**
N
nikhilraut 已提交
838

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

**Example**

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

W
wusongqing 已提交
851
### setZoomRatio
N
nikhilraut 已提交
852

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

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

W
wusongqing 已提交
857
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
858 859 860

**Parameters**

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

**Example**

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

W
wusongqing 已提交
878
### setZoomRatio
N
nikhilraut 已提交
879

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

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

W
wusongqing 已提交
884
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
885 886 887

**Parameters**

W
wusongqing 已提交
888 889 890
| Name     | Type  | Mandatory| Description        |
| --------- | ------ | ---- | ------------ |
| zoomRatio | number | Yes  | Zoom ratio to set.|
N
nikhilraut 已提交
891

W
wusongqing 已提交
892
**Return value**
N
nikhilraut 已提交
893

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

**Example**

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

W
wusongqing 已提交
906
### getZoomRatio
N
nikhilraut 已提交
907

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

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

W
wusongqing 已提交
912
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
913 914 915

**Parameters**

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

**Example**

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

W
wusongqing 已提交
932
### getZoomRatio
N
nikhilraut 已提交
933

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

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

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

W
wusongqing 已提交
940
**Return value**
N
nikhilraut 已提交
941

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

**Example**

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

W
wusongqing 已提交
954
### release
N
nikhilraut 已提交
955

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

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

W
wusongqing 已提交
960
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
961 962 963

**Parameters**

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

**Example**

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

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

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

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

W
wusongqing 已提交
988
**Return value**
N
nikhilraut 已提交
989

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

**Example**

W
wusongqing 已提交
996
```js
N
nikhilraut 已提交
997 998 999 1000 1001
cameraInput.release().then(() => {
    console.log('Promise returned to indicate that the CameraInput instance is released successfully.');
})
```

W
wusongqing 已提交
1002
### on('focusStateChange')
N
nikhilraut 已提交
1003

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

W
wusongqing 已提交
1006
Listens for focus state changes. This API uses an asynchronous callback to return the focus state changes.
N
nikhilraut 已提交
1007

W
wusongqing 已提交
1008
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1009 1010 1011

**Parameters**

W
wusongqing 已提交
1012 1013 1014 1015
| 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 已提交
1016 1017 1018

**Example**

W
wusongqing 已提交
1019
```js
N
nikhilraut 已提交
1020 1021 1022 1023 1024
cameraInput.on('focusStateChange', (focusState) => {
    console.log('Focus state  : ' + focusState);
})
```

W
wusongqing 已提交
1025
### on('error')
N
nikhilraut 已提交
1026

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

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

W
wusongqing 已提交
1031
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1032 1033 1034

**Parameters**

W
wusongqing 已提交
1035 1036
| Name    | Type                            | Mandatory| Description                                            |
| :------- | :------------------------------- | :--- | :----------------------------------------------- |
W
wusongqing 已提交
1037
| type     | string                           | Yes  | Type of event to listen for. The value is fixed at **error**, indicating the camera input error event.|
W
wusongqing 已提交
1038
| callback | ErrorCallback<[CameraInputError](#camerainputerror)\> | Yes  | Callback used to return the error information.                        |
N
nikhilraut 已提交
1039 1040 1041

**Example**

W
wusongqing 已提交
1042
```js
N
nikhilraut 已提交
1043 1044 1045 1046 1047
cameraInput.on('error', (cameraInputError) => {
    console.log('Camera input error code: ' + cameraInputError.code);
})
```

W
wusongqing 已提交
1048
##  CameraInputErrorCode
1049

W
wusongqing 已提交
1050
Enumerates the **CameraInput** error codes.
1051 1052 1053

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

W
wusongqing 已提交
1054 1055 1056
| Name         | Value  | Description      |
| ------------- | ---- | ---------- |
| ERROR_UNKNOWN | -1   | Unknown error.|
1057

W
wusongqing 已提交
1058
##  CameraInputError
1059

W
wusongqing 已提交
1060
Defines a **CameraInput** error object.
1061 1062 1063

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

W
wusongqing 已提交
1064 1065 1066
| Name| Type                                       | Description                      |
| ---- | ------------------------------------------- | -------------------------- |
| code | [CameraInputErrorCode](#camerainputerrorcode) | **CameraInput** error code.|
1067

N
nikhilraut 已提交
1068

W
wusongqing 已提交
1069
## FlashMode
N
nikhilraut 已提交
1070

W
wusongqing 已提交
1071
Enumerates the flash modes.
1072

W
wusongqing 已提交
1073
**System capability**: SystemCapability.Multimedia.Camera.Core
1074

W
wusongqing 已提交
1075 1076 1077 1078 1079 1080
| Name                  | 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 已提交
1081

W
wusongqing 已提交
1082
## FocusMode
N
nikhilraut 已提交
1083 1084 1085

Enumerates the focus modes.

W
wusongqing 已提交
1086 1087
**System capability**: SystemCapability.Multimedia.Camera.Core

W
wusongqing 已提交
1088 1089 1090 1091 1092 1093
| Name                      | 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.        |
1094

W
wusongqing 已提交
1095
## FocusState
1096

W
wusongqing 已提交
1097
Enumerates the focus states.
N
nikhilraut 已提交
1098

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

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

W
wusongqing 已提交
1107
## camera.createCaptureSession
N
nikhilraut 已提交
1108

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

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

**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1114 1115 1116

**Parameters**

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

**Example**

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

W
wusongqing 已提交
1134
## camera.createCaptureSession
N
nikhilraut 已提交
1135

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

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

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

**Parameters**

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

W
wusongqing 已提交
1148
**Return value**
N
nikhilraut 已提交
1149

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

**Example**

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

W
wusongqing 已提交
1162
## CaptureSession
N
nikhilraut 已提交
1163 1164 1165

Implements session capture.

W
wusongqing 已提交
1166
### beginConfig
N
nikhilraut 已提交
1167

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

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

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

**Parameters**

W
wusongqing 已提交
1176 1177 1178
| Name    | Type                | Mandatory| Description                    |
| -------- | -------------------- | ---- | ------------------------ |
| callback | AsyncCallback<void\> | Yes  | Callback used to return the result.|
N
nikhilraut 已提交
1179 1180 1181

**Example**

W
wusongqing 已提交
1182
```js
N
nikhilraut 已提交
1183 1184 1185 1186 1187 1188 1189 1190 1191
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 已提交
1192
### beginConfig
N
nikhilraut 已提交
1193

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

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

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

W
wusongqing 已提交
1200
**Return value**
N
nikhilraut 已提交
1201

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


**Example**

W
wusongqing 已提交
1209
```js
N
nikhilraut 已提交
1210 1211 1212 1213 1214
captureSession.beginConfig().then(() => {
    console.log('Promise returned to indicate the begin config success.');
})
```

W
wusongqing 已提交
1215
### commitConfig
N
nikhilraut 已提交
1216

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

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

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

**Parameters**

W
wusongqing 已提交
1225 1226 1227
| Name    | Type                | Mandatory| Description                    |
| -------- | -------------------- | ---- | ------------------------ |
| callback | AsyncCallback<void\> | Yes  | Callback used to return the result.|
N
nikhilraut 已提交
1228 1229 1230

**Example**

W
wusongqing 已提交
1231
```js
N
nikhilraut 已提交
1232 1233 1234 1235 1236 1237 1238 1239 1240
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 已提交
1241
### commitConfig
N
nikhilraut 已提交
1242

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

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

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

W
wusongqing 已提交
1249
**Return value**
N
nikhilraut 已提交
1250

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

**Example**

W
wusongqing 已提交
1257
```js
N
nikhilraut 已提交
1258 1259 1260 1261 1262
captureSession.commitConfig().then(() => {
    console.log('Promise returned to indicate the commit config success.');
})
```

W
wusongqing 已提交
1263
### addInput
N
nikhilraut 已提交
1264

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

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

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

**Parameters**

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

**Example**

W
wusongqing 已提交
1280
```js
N
nikhilraut 已提交
1281 1282 1283 1284 1285 1286 1287 1288 1289
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 已提交
1290
### addInput
N
nikhilraut 已提交
1291

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

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

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

**Parameters**

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

W
wusongqing 已提交
1304
**Return value**
N
nikhilraut 已提交
1305

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

**Example**

W
wusongqing 已提交
1312
```js
N
nikhilraut 已提交
1313 1314 1315 1316 1317
captureSession.addInput(cameraInput).then(() => {
    console.log('Promise used to indicate that the CameraInput instance is added.');
})
```

W
wusongqing 已提交
1318
### addOutput
N
nikhilraut 已提交
1319

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

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

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

**Parameters**

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

**Example**

W
wusongqing 已提交
1335
```js
N
nikhilraut 已提交
1336 1337 1338 1339 1340 1341 1342 1343 1344
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 已提交
1345
### addOutput
N
nikhilraut 已提交
1346

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

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

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

**Parameters**

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

W
wusongqing 已提交
1359
**Return value**
N
nikhilraut 已提交
1360

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

**Example**

W
wusongqing 已提交
1367
```js
N
nikhilraut 已提交
1368 1369 1370 1371 1372
captureSession.addOutput(previewOutput).then(() => {
    console.log('Promise used to indicate that the PreviewOutput instance is added.');
})
```

W
wusongqing 已提交
1373
### addOutput
N
nikhilraut 已提交
1374

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

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

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

**Parameters**

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

**Example**

W
wusongqing 已提交
1390
```js
N
nikhilraut 已提交
1391 1392 1393 1394 1395 1396 1397 1398 1399
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 已提交
1400
### addOutput
N
nikhilraut 已提交
1401

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

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

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

**Parameters**

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

W
wusongqing 已提交
1414
**Return value**
N
nikhilraut 已提交
1415 1416

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

**Example**

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

W
wusongqing 已提交
1428
### addOutput
N
nikhilraut 已提交
1429

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

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

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

**Parameters**

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

**Example**

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

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

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

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

**Parameters**

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

W
wusongqing 已提交
1469
**Return value**
N
nikhilraut 已提交
1470

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

**Example**

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

W
wusongqing 已提交
1483
### removeInput
N
nikhilraut 已提交
1484

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

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

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

**Parameters**

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

**Example**

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

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

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

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

**Parameters**

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

W
wusongqing 已提交
1524
**Return value**
N
nikhilraut 已提交
1525

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

**Example**

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

W
wusongqing 已提交
1538
### removeOutput
N
nikhilraut 已提交
1539

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

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

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

**Parameters**

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

**Example**

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

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

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

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

**Parameters**

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


W
wusongqing 已提交
1580
**Return value**
N
nikhilraut 已提交
1581

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


**Example**

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

W
wusongqing 已提交
1595
### removeOutput
N
nikhilraut 已提交
1596

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

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

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

**Parameters**

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

**Example**

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

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

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

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

**Parameters**

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


W
wusongqing 已提交
1637
**Return value**
N
nikhilraut 已提交
1638

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


**Example**

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

W
wusongqing 已提交
1652
### removeOutput
N
nikhilraut 已提交
1653

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

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

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

**Parameters**

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

**Example**

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

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

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

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

**Parameters**

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


W
wusongqing 已提交
1694
**Return value**
N
nikhilraut 已提交
1695

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


**Example**

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

W
wusongqing 已提交
1709
### start
N
nikhilraut 已提交
1710

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

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

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

**Parameters**

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

**Example**

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

W
wusongqing 已提交
1735
### start
N
nikhilraut 已提交
1736

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

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

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

W
wusongqing 已提交
1743
**Return value**
N
nikhilraut 已提交
1744

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

**Example**

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

W
wusongqing 已提交
1757
### stop
N
nikhilraut 已提交
1758

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

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

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

**Parameters**


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

**Example**

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

W
wusongqing 已提交
1784
### stop
N
nikhilraut 已提交
1785

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

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

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

W
wusongqing 已提交
1792
**Return value**
N
nikhilraut 已提交
1793

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

**Example**

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

W
wusongqing 已提交
1806
### release
N
nikhilraut 已提交
1807

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

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

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

**Parameters**

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

**Example**

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

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

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

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

W
wusongqing 已提交
1840
**Return value**
N
nikhilraut 已提交
1841

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

**Example**

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

W
wusongqing 已提交
1854
### on('error')
N
nikhilraut 已提交
1855

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

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

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

**Parameters**

W
wusongqing 已提交
1864 1865 1866 1867
| 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](#capturesessionerror)\> | Yes  | Callback used to return the error information.                 |
N
nikhilraut 已提交
1868 1869 1870

**Example**

W
wusongqing 已提交
1871
```js
N
nikhilraut 已提交
1872 1873 1874 1875 1876
captureSession.on('error', (captureSessionError) => {
    console.log('Capture session error code: ' + captureSessionError.code);
})
```

W
wusongqing 已提交
1877
##  CaptureSessionErrorCode
1878

W
wusongqing 已提交
1879
Enumerates the **CaptureSession** error codes.
1880 1881 1882

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

W
wusongqing 已提交
1883 1884 1885
| Name         | Value  | Description      |
| ------------- | ---- | ---------- |
| ERROR_UNKNOWN | -1   | Unknown error.|
1886

W
wusongqing 已提交
1887
##  CaptureSessionError
1888

W
wusongqing 已提交
1889
Defines a **CaptureSession** error object.
1890 1891 1892

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

W
wusongqing 已提交
1893 1894 1895
| Name| Type                                       | Description                      |
| ---- | ------------------------------------------- | -------------------------- |
| code | [CaptureSessionError](#capturesessionerror) | **CaptureSession** error code.|
1896

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

**Example**

W
wusongqing 已提交
1914
```js
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

**Example**

W
wusongqing 已提交
1946
```js
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

**Example**

W
wusongqing 已提交
1972
```js
N
nikhilraut 已提交
1973 1974 1975 1976 1977 1978 1979 1980 1981
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


**Example**

W
wusongqing 已提交
1999
```js
N
nikhilraut 已提交
2000 2001 2002 2003 2004
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

**Example**

W
wusongqing 已提交
2022
```js
N
nikhilraut 已提交
2023 2024 2025 2026 2027
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

**Example**

W
wusongqing 已提交
2045
```js
N
nikhilraut 已提交
2046 2047 2048 2049 2050
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<[PreviewOutputErrorCode](#previewoutputerrorcode)\> | Yes  | Callback used to return the error information.                 |
N
nikhilraut 已提交
2065 2066 2067

**Example**

W
wusongqing 已提交
2068
```js
N
nikhilraut 已提交
2069 2070 2071 2072 2073
previewOutput.on('error', (previewOutputError) => {
    console.log('Preview output error code: ' + previewOutputError.code);
})
```

2074 2075
## PreviewOutputErrorCode

W
wusongqing 已提交
2076
Enumerates the **PreviewOutput** error codes.
2077 2078 2079

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

W
wusongqing 已提交
2080 2081 2082
| Name         | Value  | Description      |
| ------------- | ---- | ---------- |
| ERROR_UNKNOWN | -1   | Unknown error.|
2083

W
wusongqing 已提交
2084
##  PreviewOutputError
2085

W
wusongqing 已提交
2086
Defines a **PreviewOutput** error object.
2087 2088 2089

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

W
wusongqing 已提交
2090 2091 2092
| Name| Type                                             | Description                  |
| ---- | ------------------------------------------------- | ---------------------- |
| code | [PreviewOutputErrorCode](#previewoutputerrorcode) | **PreviewOutput** error code.|
2093

W
wusongqing 已提交
2094
## camera.createPhotoOutput
N
nikhilraut 已提交
2095

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

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

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

**Parameters**

W
wusongqing 已提交
2104 2105 2106 2107
| 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 已提交
2108 2109 2110

**Example**

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

W
wusongqing 已提交
2121
## camera.createPhotoOutput
N
nikhilraut 已提交
2122

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

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

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

**Parameters**

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

W
wusongqing 已提交
2135
**Return value**
N
nikhilraut 已提交
2136

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

**Example**

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

Enumerates the image rotation angles.

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

W
wusongqing 已提交
2154 2155 2156 2157 2158 2159
| Name        | 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 已提交
2160 2161 2162 2163 2164

## QualityLevel

Enumerates the image quality levels.

W
wusongqing 已提交
2165
**System capability**: SystemCapability.Multimedia.Camera.Core
2166

W
wusongqing 已提交
2167 2168 2169 2170 2171
| Name                | 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 已提交
2172 2173 2174 2175


## PhotoCaptureSetting

W
wusongqing 已提交
2176
Defines the settings for photo capture.
N
nikhilraut 已提交
2177

W
wusongqing 已提交
2178
**System capability**: SystemCapability.Multimedia.Camera.Core
2179

W
wusongqing 已提交
2180 2181
| Name    | Type                           | Mandatory| Description          |
| -------- | ------------------------------- | ---- | -------------- |
W
wusongqing 已提交
2182 2183
| quality  | [QualityLevel](#qualitylevel)   | No  | Photo quality.    |
| rotation | [ImageRotation](#imagerotation) | No  | Rotation angle of the photo.|
N
nikhilraut 已提交
2184 2185 2186 2187 2188 2189


## PhotoOutput

Implements photo output.

W
wusongqing 已提交
2190
### capture
N
nikhilraut 已提交
2191

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

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

W
wusongqing 已提交
2196
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
2197 2198 2199

**Parameters**

W
wusongqing 已提交
2200 2201 2202
| Name    | Type                | Mandatory| Description                    |
| -------- | -------------------- | ---- | ------------------------ |
| callback | AsyncCallback<void\> | Yes  | Callback used to return the result.|
N
nikhilraut 已提交
2203 2204 2205

**Example**

W
wusongqing 已提交
2206
```js
N
nikhilraut 已提交
2207 2208 2209 2210 2211 2212 2213 2214 2215
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 已提交
2216
### capture
N
nikhilraut 已提交
2217

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

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

W
wusongqing 已提交
2222
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
2223 2224 2225

**Parameters**

W
wusongqing 已提交
2226 2227 2228 2229
| Name    | Type                                       | Mandatory| Description                    |
| -------- | ------------------------------------------- | ---- | ------------------------ |
| setting  | [PhotoCaptureSetting](#photocapturesetting) | Yes  | Photo capture settings.              |
| callback | AsyncCallback<void\>                        | Yes  | Callback used to return the result.|
N
nikhilraut 已提交
2230 2231 2232

**Example**

W
wusongqing 已提交
2233
```js
N
nikhilraut 已提交
2234 2235 2236 2237 2238 2239 2240 2241 2242
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 已提交
2243
### capture
N
nikhilraut 已提交
2244

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

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

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

**Parameters**

W
wusongqing 已提交
2253 2254 2255
| Name   | Type                                       | Mandatory| Description      |
| ------- | ------------------------------------------- | ---- | ---------- |
| setting | [PhotoCaptureSetting](#photocapturesetting) | No  | Photo capture settings.|
N
nikhilraut 已提交
2256

W
wusongqing 已提交
2257
**Return value**
N
nikhilraut 已提交
2258

W
wusongqing 已提交
2259 2260 2261
| Type          | Description                       |
| -------------- | --------------------------- |
| Promise<void\> | Promise used to return the result.|
N
nikhilraut 已提交
2262 2263 2264 2265


**Example**

W
wusongqing 已提交
2266
```js
N
nikhilraut 已提交
2267 2268 2269 2270 2271
photoOutput.capture().then(() => {
    console.log('Promise returned to indicate that photo capture request success.');
})
```

W
wusongqing 已提交
2272
### release
N
nikhilraut 已提交
2273

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

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

W
wusongqing 已提交
2278
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
2279 2280 2281

**Parameters**

W
wusongqing 已提交
2282 2283 2284
| Name    | Type                | Mandatory| Description                    |
| -------- | -------------------- | ---- | ------------------------ |
| callback | AsyncCallback<void\> | Yes  | Callback used to return the result.|
N
nikhilraut 已提交
2285 2286 2287

**Example**

W
wusongqing 已提交
2288
```js
N
nikhilraut 已提交
2289 2290 2291 2292 2293 2294 2295 2296 2297
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 已提交
2298
### release
N
nikhilraut 已提交
2299

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

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

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

W
wusongqing 已提交
2306
**Return value**
N
nikhilraut 已提交
2307

W
wusongqing 已提交
2308 2309 2310
| Type          | Description                       |
| -------------- | --------------------------- |
| Promise<void\> | Promise used to return the result.|
N
nikhilraut 已提交
2311 2312 2313 2314


**Example**

W
wusongqing 已提交
2315
```js
N
nikhilraut 已提交
2316 2317 2318 2319 2320
photoOutput.release().then(() => {
    console.log('Promise returned to indicate that the PhotoOutput instance is released successfully.');
})
```

W
wusongqing 已提交
2321
### on('captureStart')
N
nikhilraut 已提交
2322

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

W
wusongqing 已提交
2325
Listens for photo capture start events. This API uses an asynchronous callback to return the capture ID.
N
nikhilraut 已提交
2326

W
wusongqing 已提交
2327
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
2328 2329 2330

**Parameters**

W
wusongqing 已提交
2331 2332 2333 2334
| 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 已提交
2335 2336 2337

**Example**

W
wusongqing 已提交
2338
```js
J
jiangminyang 已提交
2339
photoOutput.on('captureStart', (err, captureId) => {
N
nikhilraut 已提交
2340 2341 2342 2343
    console.log('photo capture stated, captureId : ' + captureId);
})
```

W
wusongqing 已提交
2344
### on('frameShutter')
N
nikhilraut 已提交
2345

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

W
wusongqing 已提交
2348
Listens for frame shutter events. This API uses an asynchronous callback to return the event information.
N
nikhilraut 已提交
2349

W
wusongqing 已提交
2350
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
2351 2352 2353

**Parameters**

W
wusongqing 已提交
2354 2355 2356 2357
| 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](#frameshutterinfo)\> | Yes  | Callback used to return the information.                  |
N
nikhilraut 已提交
2358 2359 2360

**Example**

W
wusongqing 已提交
2361
```js
J
jiangminyang 已提交
2362
photoOutput.on('frameShutter', (err, frameShutterInfo) => {
N
nikhilraut 已提交
2363 2364 2365 2366 2367
    console.log('photo capture end, captureId : ' + frameShutterInfo.captureId);
    console.log('Timestamp for frame : ' + frameShutterInfo.timestamp);
})
```

W
wusongqing 已提交
2368
### on('captureEnd')
N
nikhilraut 已提交
2369

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

W
wusongqing 已提交
2372
Listens for photo capture end events. This API uses an asynchronous callback to return the event information.
N
nikhilraut 已提交
2373

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

**Parameters**

W
wusongqing 已提交
2378 2379 2380 2381
| 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](#captureendinfo)\> | Yes  | Callback used to return the information.                  |
N
nikhilraut 已提交
2382 2383 2384

**Example**

W
wusongqing 已提交
2385
```js
J
jiangminyang 已提交
2386
photoOutput.on('captureEnd', (err, captureEndInfo) => {
N
nikhilraut 已提交
2387 2388 2389 2390 2391
    console.log('photo capture end, captureId : ' + captureEndInfo.captureId);
    console.log('frameCount : ' + captureEndInfo.frameCount);
})
```

W
wusongqing 已提交
2392
### on('error')
N
nikhilraut 已提交
2393

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

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

W
wusongqing 已提交
2398
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
2399 2400 2401

**Parameters**

W
wusongqing 已提交
2402 2403 2404 2405
| 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](#photooutputerror)\> | Yes  | Callback used to return the error information.             |
N
nikhilraut 已提交
2406 2407 2408

**Example**

W
wusongqing 已提交
2409
```js
J
jiangminyang 已提交
2410
photoOutput.on('error', (err, photoOutputError) => {
N
nikhilraut 已提交
2411 2412 2413 2414
    console.log('Photo output error code: ' + photoOutputError.code);
})
```

W
wusongqing 已提交
2415
## FrameShutterInfo
2416

W
wusongqing 已提交
2417
Defines the frame shutter information.
2418

W
wusongqing 已提交
2419
**System capability**: SystemCapability.Multimedia.Camera.Core
2420

W
wusongqing 已提交
2421 2422 2423 2424
| Name     | Type  | Mandatory| Description                         |
| --------- | ------ | ---- | ----------------------------- |
| captureId | number | Yes  | ID of this capture action.|
| timestamp | number | Yes  | Timestamp when the frame shutter event is triggered.                     |
2425

W
wusongqing 已提交
2426
## CaptureEndInfo
2427

W
wusongqing 已提交
2428
Defines the capture end information.
2429

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

W
wusongqing 已提交
2432 2433 2434 2435
| Name      | Type  | Mandatory| Description                         |
| ---------- | ------ | ---- | ----------------------------- |
| captureId  | number | Yes  | ID of this capture action.|
| frameCount | number | Yes  | Number of frames captured.                     |
2436 2437 2438

## PhotoOutputErrorCode

W
wusongqing 已提交
2439
Enumerates the **PhotoOutput** error codes.
2440 2441 2442

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

W
wusongqing 已提交
2443 2444 2445
| Name         | Value  | Description      |
| ------------- | ---- | ---------- |
| ERROR_UNKNOWN | -1   | Unknown error.|
2446

W
wusongqing 已提交
2447
##  PhotoOutputError
2448

W
wusongqing 已提交
2449
Defines a **PhotoOutput** error object.
2450 2451 2452

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

W
wusongqing 已提交
2453 2454 2455
| Name| Type                                 | Description                   |
| ---- | ------------------------------------- | ----------------------- |
| code | [PhotoOutputError](#photooutputerror) | **PhotoOutput** error code.|
2456

W
wusongqing 已提交
2457
## camera.createVideoOutput
N
nikhilraut 已提交
2458

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

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

W
wusongqing 已提交
2463
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
2464 2465 2466

**Parameters**

W
wusongqing 已提交
2467 2468 2469 2470
| 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 已提交
2471 2472 2473

**Example**

W
wusongqing 已提交
2474
```js
J
jiangminyang 已提交
2475
camera.createVideoOutput(("surfaceId"), (err, videoOutput) => {
N
nikhilraut 已提交
2476 2477 2478 2479 2480 2481
    if (err) {
        console.error('Failed to create the VideoOutput instance. ${err.message}');
        return;
    }
    console.log('Callback returned with the VideoOutput instance');
});
W
wusongqing 已提交
2482
```
N
nikhilraut 已提交
2483

W
wusongqing 已提交
2484
## camera.createVideoOutput
N
nikhilraut 已提交
2485

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

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

W
wusongqing 已提交
2490
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
2491 2492 2493

**Parameters**

W
wusongqing 已提交
2494 2495 2496
| Name     | Type  | Mandatory| Description                             |
| --------- | ------ | ---- | --------------------------------- |
| surfaceId | string | Yes  | Surface ID received from **VideoRecorder**.|
N
nikhilraut 已提交
2497

W
wusongqing 已提交
2498
**Return value**
N
nikhilraut 已提交
2499

W
wusongqing 已提交
2500 2501 2502
| Type                                 | Description                                  |
| ------------------------------------- | -------------------------------------- |
| Promise<[VideoOutput](#videooutput)\> | Promise used to return the **VideoOutput** instance.|
N
nikhilraut 已提交
2503 2504 2505

**Example**

W
wusongqing 已提交
2506
```js
J
jiangminyang 已提交
2507 2508
camera.createVideoOutput("surfaceId"
).then((videoOutput) => {
N
nikhilraut 已提交
2509 2510 2511
    console.log('Promise returned with the VideoOutput instance');
})
```
W
wusongqing 已提交
2512

N
nikhilraut 已提交
2513 2514 2515
## VideoOutput

Implements video output.
N
nikhilraut 已提交
2516

W
wusongqing 已提交
2517
### start
N
nikhilraut 已提交
2518

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

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

W
wusongqing 已提交
2523
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
2524 2525 2526

**Parameters**

W
wusongqing 已提交
2527 2528 2529
| Name    | Type                | Mandatory| Description                    |
| -------- | -------------------- | ---- | ------------------------ |
| callback | AsyncCallback<void\> | Yes  | Callback used to return the result.|
N
nikhilraut 已提交
2530 2531 2532

**Example**

W
wusongqing 已提交
2533
```js
N
nikhilraut 已提交
2534 2535 2536 2537 2538 2539 2540 2541 2542
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 已提交
2543
### start
N
nikhilraut 已提交
2544

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

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

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

W
wusongqing 已提交
2551
**Return value**
N
nikhilraut 已提交
2552

W
wusongqing 已提交
2553 2554 2555
| Type          | Description                       |
| -------------- | --------------------------- |
| Promise<void\> | Promise used to return the result.|
N
nikhilraut 已提交
2556 2557 2558 2559


**Example**

W
wusongqing 已提交
2560
```js
N
nikhilraut 已提交
2561 2562 2563 2564 2565
videoOutput.start().then(() => {
    console.log('Promise returned to indicate that start method execution success.');
})
```

W
wusongqing 已提交
2566
### stop
N
nikhilraut 已提交
2567

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

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

W
wusongqing 已提交
2572
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
2573 2574 2575

**Parameters**

W
wusongqing 已提交
2576 2577 2578
| Name    | Type                | Mandatory| Description                    |
| -------- | -------------------- | ---- | ------------------------ |
| callback | AsyncCallback<void\> | Yes  | Callback used to return the result.|
N
nikhilraut 已提交
2579 2580 2581

**Example**

W
wusongqing 已提交
2582
```js
N
nikhilraut 已提交
2583 2584 2585 2586 2587 2588 2589 2590 2591
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 已提交
2592
### stop
N
nikhilraut 已提交
2593

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

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

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

W
wusongqing 已提交
2600
**Return value**
N
nikhilraut 已提交
2601

W
wusongqing 已提交
2602 2603 2604
| Type          | Description                       |
| -------------- | --------------------------- |
| Promise<void\> | Promise used to return the result.|
N
nikhilraut 已提交
2605 2606 2607

**Example**

W
wusongqing 已提交
2608
```js
N
nikhilraut 已提交
2609 2610 2611 2612 2613
videoOutput.start().then(() => {
    console.log('Promise returned to indicate that stop method execution success.');
})
```

W
wusongqing 已提交
2614
### release
N
nikhilraut 已提交
2615

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

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

W
wusongqing 已提交
2620
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
2621 2622 2623

**Parameters**

W
wusongqing 已提交
2624 2625 2626
| Name    | Type                | Mandatory| Description                    |
| -------- | -------------------- | ---- | ------------------------ |
| callback | AsyncCallback<void\> | Yes  | Callback used to return the result.|
N
nikhilraut 已提交
2627 2628 2629

**Example**

W
wusongqing 已提交
2630
```js
N
nikhilraut 已提交
2631 2632 2633 2634 2635 2636 2637 2638 2639
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 已提交
2640
### release
N
nikhilraut 已提交
2641

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

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

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

W
wusongqing 已提交
2648
**Return value**
N
nikhilraut 已提交
2649

W
wusongqing 已提交
2650 2651 2652
| Type          | Description                       |
| -------------- | --------------------------- |
| Promise<void\> | Promise used to return the result.|
N
nikhilraut 已提交
2653 2654 2655 2656


**Example**

W
wusongqing 已提交
2657
```js
N
nikhilraut 已提交
2658 2659 2660
videoOutput.release().then(() => {
    console.log('Promise returned to indicate that the VideoOutput instance is released successfully.');
})
N
nikhilraut 已提交
2661 2662
```

W
wusongqing 已提交
2663
### on('frameStart')
N
nikhilraut 已提交
2664

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

W
wusongqing 已提交
2667
Listens for video frame start events. This API uses an asynchronous callback to return the event information.
N
nikhilraut 已提交
2668

W
wusongqing 已提交
2669
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
2670 2671 2672

**Parameters**

W
wusongqing 已提交
2673 2674 2675 2676
| 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 已提交
2677 2678 2679

**Example**

W
wusongqing 已提交
2680
```js
N
nikhilraut 已提交
2681 2682 2683 2684 2685
videoOutput.on('frameStart', () => {
    console.log('Video frame started');
})
```

W
wusongqing 已提交
2686 2687 2688
### on('frameEnd')

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

W
wusongqing 已提交
2690
Listens for video frame end events. This API uses an asynchronous callback to return the event information.
W
wusongqing 已提交
2691 2692

**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
2693 2694 2695

**Parameters**

W
wusongqing 已提交
2696 2697 2698 2699
| 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 已提交
2700 2701 2702

**Example**

W
wusongqing 已提交
2703
```js
N
nikhilraut 已提交
2704 2705 2706 2707 2708
videoOutput.on('frameEnd', () => {
    console.log('Video frame ended');
})
```

W
wusongqing 已提交
2709 2710 2711
### on('error')

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

W
wusongqing 已提交
2713 2714 2715
Listens for **VideoOutput** errors. This API uses a callback to return the errors.

**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
2716 2717 2718

**Parameters**

W
wusongqing 已提交
2719 2720 2721 2722
| 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](#videooutputerror)\> | Yes  | Callback used to return the error information.                 |
N
nikhilraut 已提交
2723 2724 2725

**Example**

W
wusongqing 已提交
2726
```js
N
nikhilraut 已提交
2727 2728 2729
videoOutput.on('error', (VideoOutputError) => {
    console.log('Video output error code: ' + VideoOutputError.code);
})
W
wusongqing 已提交
2730
```
2731 2732 2733

## VideoOutputErrorCode

W
wusongqing 已提交
2734
Enumerates the **VideoOutput** error codes.
2735 2736 2737

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

W
wusongqing 已提交
2738 2739 2740
| Name         | Value  | Description      |
| ------------- | ---- | ---------- |
| ERROR_UNKNOWN | -1   | Unknown error.|
2741

W
wusongqing 已提交
2742
##  VideoOutputError
2743

W
wusongqing 已提交
2744
Defines a **VideoOutput** error object.
2745 2746 2747

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

W
wusongqing 已提交
2748 2749 2750
| Name| Type                                 | Description                   |
| ---- | ------------------------------------- | ----------------------- |
| code | [PhotoOutputError](#photooutputerror) | **VideoOutput** error code.|