diff --git a/en/application-dev/media/Readme-EN.md b/en/application-dev/media/Readme-EN.md index d377c32ef7a1c7425d856ad9faf0625c4101ecf4..e1997f5069c591019217fc68858c866318daecbe 100755 --- a/en/application-dev/media/Readme-EN.md +++ b/en/application-dev/media/Readme-EN.md @@ -3,13 +3,16 @@ - Audio - [Audio Overview](audio-overview.md) -- [Audio Playback Development](audio-playback.md) + - [Audio Playback Development](audio-playback.md) + - [Audio Recording Development](audio-recorder.md) -- [Audio Rendering Development](audio-renderer.md) + - [Audio Rendering Development](audio-renderer.md) + - [Audio Capture Development](audio-capturer) - Video - [Video Playback Development](video-playback.md) + - [Video Recording Development](video-recorder.md) - Image - [Image Development](image.md) diff --git a/en/application-dev/media/video-recorder.md b/en/application-dev/media/video-recorder.md new file mode 100644 index 0000000000000000000000000000000000000000..dc036c1240e48732e063e45841d93a4c1f766f9f --- /dev/null +++ b/en/application-dev/media/video-recorder.md @@ -0,0 +1,147 @@ +# Video Recording Development + +## When to Use + +During video recording, audio and video signals are captured, encoded, and saved to files. You can specify parameters such as the encoding format, encapsulation format, and file path for video recording. + +**Figure 1** Video recording state transition + +![en-us_image_video_recorder_state_machine](figures/en-us_image_video_recorder_state_machine.png) + + + +**Figure 2** Layer 0 diagram of video recording + +![en-us_image_video_recorder_zero](figures/en-us_image_video_recorder_zero.png) + +## How to Develop + +For details about the APIs used for video recording, see [VideoRecorder in the Media API](../reference/apis/js-apis-media.md). + +### Full-Process Scenario + +The full video recording process includes creating an instance, setting recording parameters, recording video, pausing, resuming, and stopping recording, and releasing resources. + +```js +import media from '@ohos.multimedia.media' +import mediaLibrary from '@ohos.multimedia.mediaLibrary' + +let testFdNumber; + +// pathName indicates the passed recording file name, for example, 01.mp4. The generated file address is /storage/media/100/local/files/Movies/01.mp4. +// To use the media library, declare the following permissions: ohos.permission.MEDIA_LOCATION, ohos.permission.WRITE_MEDIA, and ohos.permission.READ_MEDIA. +async function getFd(pathName) { + let displayName = pathName; + const mediaTest = mediaLibrary.getMediaLibrary(); + let fileKeyObj = mediaLibrary.FileKey; + let mediaType = mediaLibrary.MediaType.VIDEO; + let publicPath = await mediaTest.getPublicDirectory(mediaLibrary.DirectoryType.DIR_VIDEO); + let dataUri = await mediaTest.createAsset(mediaType, displayName, publicPath); + if (dataUri != undefined) { + let args = dataUri.id.toString(); + let fetchOp = { + selections : fileKeyObj.ID + "=?", + selectionArgs : [args], + } + let fetchFileResult = await mediaTest.getFileAssets(fetchOp); + let fileAsset = await fetchFileResult.getAllObject(); + let fdNumber = await fileAsset[0].open('Rw'); + fdNumber = "fd://" + fdNumber.toString(); + testFdNumber = fdNumber; + } +} + +await getFd('01.mp4'); + +let videoProfile = { + audioBitrate : 48000, + audioChannels : 2, + audioCodec : 'audio/mp4a-latm', + audioSampleRate : 48000, + fileFormat : 'mp4', + videoBitrate : 48000, + videoCodec : 'video/mp4v-es', + videoFrameWidth : 640, + videoFrameHeight : 480, + videoFrameRate : 30 +} + +let videoConfig = { + audioSourceType : 1, + videoSourceType : 0, + profile : videoProfile, + url: testFdNumber, // testFdNumber is generated by getFd. + orientationHint : 0, + location : { latitude : 30, longitude : 130 }, +} + +// Error callback triggered in the case of an error +function failureCallback(error) { + console.info('error happened, error name is ' + error.name); + console.info('error happened, error code is ' + error.code); + console.info('error happened, error message is ' + error.message); +} + +// Error callback triggered in the case of an exception +function catchCallback(error) { + console.info('catch error happened, error name is ' + error.name); + console.info('catch error happened, error code is ' + error.code); + console.info('catch error happened, error message is ' + error.message); +} + +let videoRecorder = null; // videoRecorder is an empty object and assigned with a value after createVideoRecorder is successfully called. +let surfaceID = null; // Used to save the surface ID returned by getInputSurface. + +// Create a VideoRecorder object. +await media.createVideoRecorder().then((recorder) => { + console.info('case createVideoRecorder called'); + if (typeof (recorder) != 'undefined') { + videoRecorder = recorder; + console.info('createVideoRecorder success'); + } else { + console.info('createVideoRecorder failed'); + } +}, failureCallback).catch(catchCallback); + +// Obtain the surface ID, save it, and pass it to camera-related interfaces. +await videoRecorder.getInputSurface().then((surface) => { + console.info('getInputSurface success'); + surfaceID = surface; +}, failureCallback).catch(catchCallback); + +// Video recording depends on camera-related interfaces. The following operations can be performed only after the video output start interface is invoked. + +// Start video recording. +await videoRecorder.start().then(() => { + console.info('start success'); +}, failureCallback).catch(catchCallback); + +// Pause video playback before the video output stop interface is invoked. +await videoRecorder.pause().then(() => { + console.info('pause success'); +}, failureCallback).catch(catchCallback); + +// Resume video playback after the video output start interface is invoked. +await videoRecorder.resume().then(() => { + console.info('resume success'); +}, failureCallback).catch(catchCallback); + +// Stop video recording after the video output stop interface is invoked. +await videoRecorder.stop().then(() => { + console.info('stop success'); +}, failureCallback).catch(catchCallback); + +// Reset the recording configuration. +await videoRecorder.reset().then(() => { + console.info('reset success'); +}, failureCallback).catch(catchCallback); + +// Release the video recording resources and camera object resources. +await videoRecorder.release().then(() => { + console.info('release success'); +}, failureCallback).catch(catchCallback); + +// Set the related object to null. +videoRecorder = null; +surfaceID = null; +``` diff --git a/en/application-dev/reference/apis/js-apis-application-DataShareExtensionAbility.md b/en/application-dev/reference/apis/js-apis-application-DataShareExtensionAbility.md new file mode 100644 index 0000000000000000000000000000000000000000..82d2edfd07edcca9045fd790eae45eb33419a4b9 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-application-DataShareExtensionAbility.md @@ -0,0 +1,348 @@ +# DataShareExtensionAbility + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> +> The APIs of this module are supported since API version 9. The APIs of API version 9 is of the Canary version and are for trial use only. The API call may be unstable. + + +Provides the Extension ability for data sharing. + + +## Modules to Import + + +``` +import DataShareExtensionAbility from '@ohos.application.DataShareExtensionAbility'; +``` + +## Attributes + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Provider + +| Name| Readable| Writable| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | -------- | -------- | +| context | Yes| No| ExtensionContext | No| Context of the Data Share Extension ability.| + + +## DataShareExtensionAbility.onCreate + +onCreate?(want: Want): void; + +Called when the Data Share Extension ability is initialized. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Provider + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| want | Want | Yes| Connection information about the Data Share Extension ability.| + +**Example** + + ```js + class myAbility extends DataShareExtensionAbility { + onCreate(want) { + console.log('onCreate, want:' + want.abilityName); + } + } + ``` + +## DataShareExtensionAbility.getFileTypes + +getFileTypes?(uri: string, mimeTypeFilter: string, callback: AsyncCallback>): void + +Obtains the supported MIME types of a specified file. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Provider + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------------- | ------------------------------ | ---- | ---------------------------------- | +| uri | string | Yes | URI of the file. | +| mimeTypeFilter | string | Yes | MIME type of the file. | +| callback | AsyncCallback\> | Yes | Callback used to return the supported MIME types.| + +**Example** + +```js +import featureAbility from '@ohos.ability.featureAbility' +var DAHelper = featureAbility.acquireDataAbilityHelper( + "dataability:///com.example.DataAbility" +); +DAHelper.getFileTypes( + "dataability:///com.example.DataAbility", + "image/*", + (err, data) => { + console.info("==========================>Called=======================>"); +}); +``` + +## DataShareExtensionAbility.insert + +insert?(uri: string, valueBucket: rdb.ValuesBucket, callback: AsyncCallback\): void + +Inserts a single data record into the database. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Provider + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------------ | ---------------------- | ---- | ------------------------------------------------------ | +| uri | string | Yes | URI of the data to insert. | +| valuesBucket | rdb.ValuesBucket | Yes | Data record to insert. If this parameter is **null**, a blank row will be inserted.| +| callback | AsyncCallback\ | Yes | Callback used to return the index of the inserted data record. | + +**Example** + +```js +import featureAbility from '@ohos.ability.featureAbility' +var DAHelper = featureAbility.acquireDataAbilityHelper( + "dataability:///com.example.DataAbility" +); +const valueBucket = { + "name": "rose", + "age": 22, + "salary": 200.5, + "blobType": u8, +} +DAHelper.insert( + "dataability:///com.example.DataAbility", + valueBucket, + (err, data) => { + console.info("==========================>Called=======================>"); +}); +``` + +## DataShareExtensionAbility.update + +update?(uri: string, valueBucket: rdb.ValuesBucket, predicates: dataAbility.DataAbilityPredicates, callback: AsyncCallback\): void + +Updates one or more data records in the database. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Provider + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------------ | --------------------------------- | ---- | ------------------------------------------------ | +| uri | string | Yes | URI of the data to update. | +| valuesBucket | rdb.ValuesBucket | Yes | New data. | +| predicates | dataAbility.DataAbilityPredicates | Yes | Filter criteria. You should define the processing logic when this parameter is **null**.| +| callback | AsyncCallback\ | Yes | Callback used to return the number of updated data records. | + +**Example** + +```js +import featureAbility from '@ohos.ability.featureAbility' +import ohos_data_ability from '@ohos.data.dataability' +var DAHelper = featureAbility.acquireDataAbilityHelper( + "dataability:///com.example.DataAbility" +); +const va = { + "name": "roe1", + "age": 21, + "salary": 20.5, + "blobType": u8, +} +let da = new ohos_data_ability.DataAbilityPredicates() +DAHelper.update( + "dataability:///com.example.DataAbility", + va, + da, + (err, data) => { + console.info("==========================>Called=======================>"); +}); +``` + +## DataShareExtensionAbility.delete + +delete?(uri: string, predicates: dataAbility.DataAbilityPredicates, callback: AsyncCallback\): void + +Deletes one or more data records from the database. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Provider + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------------ | --------------------------------- | ---- | ------------------------------------------------ | +| uri | string | Yes | URI of the data to delete. | +| valuesBucket | dataAbility.DataAbilityPredicates | Yes | Filter criteria. You should define the processing logic when this parameter is **null**.| +| callback | AsyncCallback\ | Yes | Callback used to return the number of deleted data records. | + +**Example** + +```js +import featureAbility from '@ohos.ability.featureAbility' +import ohos_data_ability from '@ohos.data.dataability' +var DAHelper = featureAbility.acquireDataAbilityHelper( + "dataability:///com.example.DataAbility" +); +let da = new ohos_data_ability.DataAbilityPredicates() +DAHelper.delete( + "dataability:///com.example.DataAbility", + da, + (err, data) => { + console.info("==========================>Called=======================>"); +}); +``` + +## DataShareExtensionAbility.query + +query?(uri: string, columns: Array\, predicates: dataAbility.DataAbilityPredicates, callback: AsyncCallback\): void + +Queries data in the database. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Provider + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------- | --------------------------------- | ---- | ------------------------------------------------ | +| uri | string | Yes | URI of the data to query. | +| columns | rdb.ValuesBucket | Yes | Columns to query. If this parameter is **null**, all columns will be queried. | +| predicates | dataAbility.DataAbilityPredicates | Yes | Filter criteria. You should define the processing logic when this parameter is **null**.| +| callback | AsyncCallback\ | Yes | Callback used to return the query result. | + +**Example** + +```js +import featureAbility from '@ohos.ability.featureAbility' +import ohos_data_ability from '@ohos.data.dataability' +var DAHelper = featureAbility.acquireDataAbilityHelper( + "dataability:///com.example.DataAbility" +); +var cars=new Array("value1", "value2", "value3", "value4"); +let da = new ohos_data_ability.DataAbilityPredicates() +DAHelper.query( + "dataability:///com.example.DataAbility", + cars, + da, + (err, data) => { + console.info("==========================>Called=======================>"); +}); +``` + +## DataShareExtensionAbility.getType + +getType?(uri: string, callback: AsyncCallback\): void + +Obtains the MIME type of the data specified by a given URI. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Provider + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ---------------------- | ---- | --------------------------------------------- | +| uri | string | Yes | URI of the data. | +| callback | AsyncCallback\ | Yes | Callback used to return the MIME type.| + +**Example** + +```js +import featureAbility from '@ohos.ability.featureAbility' +var DAHelper = featureAbility.acquireDataAbilityHelper( + "dataability:///com.example.DataAbility" +); +DAHelper.getType( + "dataability:///com.example.DataAbility", + (err, data) => { + console.info("==========================>Called=======================>"); +}); +``` + +## DataShareExtensionAbility.batchInsert + +batchInsert?(uri: string, valueBuckets: Array, callback: AsyncCallback\): void + +Inserts multiple data records into the database. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Provider + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------------ | ----------------------- | ---- | -------------------------------- | +| uri | string | Yes | URI of the data to insert. | +| valuesBucket | Array | Yes | Data record to insert. | +| callback | AsyncCallback\ | Yes | Callback used to return the number of inserted data records.| + +**Example** + +```js +import featureAbility from '@ohos.ability.featureAbility' +var DAHelper = featureAbility.acquireDataAbilityHelper( + "dataability:///com.example.DataAbility" +); +var cars = new Array({"name": "roe11", "age": 21, "salary": 20.5, "blobType": u8,}, + {"name": "roe12", "age": 21, "salary": 20.5, "blobType": u8,}, + {"name": "roe13", "age": 21, "salary": 20.5, "blobType": u8,}) +DAHelper.batchInsert( + "dataability:///com.example.DataAbility", + cars, + (err, data) => { + console.info("==========================>Called=======================>"); +}); +``` + +## DataShareExtensionAbility.normalizeUri + +normalizeUri?(uri: string, callback: AsyncCallback\): void + +Converts the URI that refers to the Data ability into a normalized URI. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Provider + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ---------------------- | ---- | ------------------------------------------------------------ | +| uri | string | Yes | URI object to normalize. | +| callback | AsyncCallback\ | Yes | Callback used to return the normalized URI object if the Data ability supports URI normalization. If the Data ability does not support URI normalization, **null** is returned.| + +**Example** + +```js +import featureAbility from '@ohos.ability.featureAbility' +var DAHelper = featureAbility.acquireDataAbilityHelper( + "dataability:///com.example.DataAbility" +); +DAHelper.normalizeUri( + "dataability:///com.example.DataAbility", + (err, data) => { + console.info("==========================>Called=======================>"); +}); +``` + +## DataShareExtensionAbility.denormalizeUri + +denormalizeUri?(uri: string, callback: AsyncCallback\): void + +Converts a normalized URI generated by **normalizeUri** to a denormalized one. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Provider + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ---------------------- | ---- | --------------------------------------------------- | +| uri | string | Yes | URI object to denormalize. | +| callback | AsyncCallback\ | Yes | Callback used to return the denormalized URI object.| + +**Example** + +```js +import featureAbility from '@ohos.ability.featureAbility' +var DAHelper = featureAbility.acquireDataAbilityHelper( + "dataability:///com.example.DataAbility" +); +DAHelper.denormalizeUri( + "dataability:///com.example.DataAbility", + (err, data) => { + console.info("==========================>Called=======================>"); +}); +``` diff --git a/en/application-dev/reference/apis/js-apis-application-StartOptions.md b/en/application-dev/reference/apis/js-apis-application-StartOptions.md new file mode 100644 index 0000000000000000000000000000000000000000..de6177d85701c479caf172155a7cab3ebc42e917 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-application-StartOptions.md @@ -0,0 +1,26 @@ +# StartOptions + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> +> The initial APIs of this module are supported since API version 9. The APIs of API version 9 is of the Canary version and are for trial use only. The API call may be unstable. + + +**StartOptions** is the basic communication component of the system. + + +## Modules to Import + + +``` +import StartOptions from '@ohos.application.StartOptions'; +``` + +## Attributes + +**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore + +| Name| Readable| Writable| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | -------- | -------- | +| windowMode | Yes| No| number | No| Window mode.| +| displayId | Yes| No| number | No| Display ID.| + diff --git a/en/application-dev/reference/apis/js-apis-camera.md b/en/application-dev/reference/apis/js-apis-camera.md new file mode 100644 index 0000000000000000000000000000000000000000..6495d3cd2e44ebe1ed618620d60276d7f57f3ef6 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-camera.md @@ -0,0 +1,2799 @@ +# Camera + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> +> The initial APIs of this module are supported since API version 9. The APIs of API version 9 is of the Canary version and are for trial use only. The API call may be unstable. + +## Modules to Import + +``` +import camera from '@ohos.multimedia.camera'; +``` + +## Required Permissions + +``` +ohos.permission.CAMERA +``` +## getCameraManager(context: Context, callback: AsyncCallback): void; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Gets a **CameraManager** instance. This method uses an asynchronous callback to return the result. + +**Parameters** + +| Name | Type | Mandatory | Description | +|----------|-------------------------------|-----------|-----------------------------------------------------| +| context | Context | Yes | Application context | +| callback | AsyncCallback | Yes | Callback used to return the CameraManager instance | + +**Example** + +``` +camera.getCameraManager(context, (err, cameraManager) => { + if (err) { + console.error('Failed to get the CameraManager instance ${err.message}'); + return; + } + console.log('Callback returned with the CameraManager instance'); +}); +``` + +## getCameraManager(context: Context): Promise; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Gets a **CameraManager** instance. This method uses a promise to return the result. + +**Parameters** + +| Name | Type | Mandatory | Description | +|----------|----------------------|-----------|----------------------------| +| context | Context | Yes | Application context | + +**Return values** + +| Type | Description | +|-------------------------|--------------------------------------------------------| +| Promise | Promise used to return the **CameraManager** instance | + +**Example** + +``` +camera.getCameraManager(context).then((cameraManger) => { + console.log('Promise returned with the CameraManager instance.'); +}) +``` + +## CameraStatus + +Enumerates camera status types. + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +| Name | Default Value | Description | +|---------------------------|---------------|--------------------| +| CAMERA_STATUS_APPEAR | 0 | Camera appear | +| CAMERA_STATUS_DISAPPEAR | 1 | Camera disappear | +| CAMERA_STATUS_AVAILABLE | 2 | Camera available | +| CAMERA_STATUS_UNAVAILABLE | 3 | Camera unavailable | + + +## CameraPosition + +Enumerates the camera positions. + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +| Name | Default value | Description | +|-----------------------------|---------------|-----------------------| +| CAMERA_POSITION_UNSPECIFIED | 0 | Unspecified position | +| CAMERA_POSITION_BACK | 1 | Rear camera | +| CAMERA_POSITION_FRONT | 2 | Front camera | + +## CameraType + +Enumerates the camera types. + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +| Name | Default value | Description | +|-------------------------|---------------|-------------------------| +| CAMERA_TYPE_UNSPECIFIED | 0 | Unspecified camera type | +| CAMERA_TYPE_WIDE_ANGLE | 1 | Wide camera | +| CAMERA_TYPE_ULTRA_WIDE | 2 | Ultra wide camera | +| CAMERA_TYPE_TELEPHOTO | 3 | Telephoto camera | +| CAMERA_TYPE_TRUE_DEPTH | 4 | True depth camera | + + +## ConnectionType + +Enumerates camera connection types. + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +| Name | Default value | Description | +|------------------------------|---------------|----------------------------| +| CAMERA_CONNECTION_BUILT_IN | 0 | Built-in camera | +| CAMERA_CONNECTION_USB_PLUGIN | 1 | Camera connected using USB | +| CAMERA_CONNECTION_REMOTE | 2 | Remote camera | + +## CameraManager + +Implements camera management, including getting supported cameras and creating **CameraInput** instances. + +### getCameras(callback: AsyncCallback\>): void; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Gets all cameras supported by the device. This method uses an asynchronous callback to return the array of supported cameras. + +**Parameters** + +| Name | Type | Mandatory | Description | +|----------|--------------------------------|-----------|---------------------------------------------------------| +| callback | AsyncCallback\> | Yes | Callback used to return the array of supported cameras. | + +**Example** + +``` +cameraManager.getCameras((err, cameras) => { + if (err) { + console.error('Failed to get the cameras. ${err.message}'); + return; + } + console.log('Callback returned with an array of supported cameras: ' + cameras.length); +}) +``` + +### getCameras(): Promise\>; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Gets all cameras supported by the device. This method uses a promise to return the array of supported cameras. + +**Return values** + +| Type | Description | +|------------------------|--------------------------------------------------------| +| Promise\> | Promise used to return an array of supported cameras | + + +**Example** + +``` +cameraManager.getCameras().then((cameraArray) => { + console.log('Promise returned with an array of supported cameras: ' + cameraArray.length); +}) +``` + +### createCameraInput(cameraId: string, callback: AsyncCallback): void; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Creates a **CameraInput** instance with the specified camera ID. This method uses an asynchronous callback to return the instance. + +**Parameters** + +| Name | Default value | Mandatory | Description | +|----------|------------------------------|-----------|--------------------------------------------------| +| cameraId | string | Yes | Camera ID used to create the instance | +| callback | AsyncCallback | Yes | Callback used to return the CameraInput instance | + +**Example** + +``` +cameraManager.createCameraInput(cameraId, (err, cameraInput) => { + if (err) { + console.error('Failed to create the CameraInput instance. ${err.message}'); + return; + } + console.log('Callback returned with the CameraInput instance.'); +}) +``` + +### createCameraInput(cameraId: string): Promise; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Creates a **CameraInput** instance with the specified camera ID. This method uses a promise to return the instance. + +**Parameters** + +| Name | Default value | Mandatory | Description | +|----------|-----------------------------|-----------|------------------------------------------| +| cameraId | string | Yes | Camera ID used to create the instance | + +**Return values** + +| Type | Description | +|-------------------------|-------------------------------------------------| +| Promise | Promise used to return the CameraInput instance | + +**Example** + +``` +cameraManager.createCameraInput(cameraId).then((cameraInput) => { + console.log('Promise returned with the CameraInput instance'); +}) +``` + +### createCameraInput(position: CameraPosition, type: CameraType, callback: AsyncCallback): void; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Creates a **CameraInput** instance with the specified camera position and camera type. This method uses an asynchronous callback to return the instance. + +**Parameters** + +| Name | Type | Mandatory | Description | +|----------|-----------------------------|-----------|---------------------------------------------------| +| position | CameraPosition | Yes | Camera position | +| type | CameraType | Yes | Camera type | +| callback | AsyncCallback | Yes | Callback used to return the CameraInput instance | + +**Example** + +``` +cameraManager.createCameraInput(cameraPosition, cameraType, (err, cameraInput) => { + if (err) { + console.error('Failed to create the CameraInput instance. ${err.message}'); + return; + } + console.log('Callback returned with the CameraInput instance'); +}) +``` + +### createCameraInput(position: CameraPosition, type: CameraType): Promise; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Creates a **CameraInput** instance with the specified camera position and camera type. This method uses a promise to return the instance. + +**Parameters** + +| Name | Type | Mandatory | Description | +|----------|----------------------------|-----------|----------------------------------------| +| position | CameraPosition | Yes | Camera position | +| type | CameraType | Yes | Camera type | + +**Return values** + +| Type | Description | +|-------------------------|-------------------------------------------------| +| Promise | Promise used to return the CameraInput instance | + +**Example** + +``` +cameraManager.createCameraInput(cameraPosition, cameraType).then((cameraInput) => { + console.log('Promise returned with the CameraInput instance.'); +}) +``` + +### on(type: 'cameraStatus', callback: Callback): void; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Listens for camera status changes. This method uses a callback to get camera status changes. + +**Parameters** + +| Name | Type | Mandatory | Description | +| :------- | :--------------------- | :-------- | :--------------------------------------------------- | +| type | string | Yes | Camera status event. | +| callback | Callback | Yes | Callback used to get the camera status change. | + +**Example** + +``` +cameraManager.on('cameraStatus', (cameraStatusInfo) => { + console.log('camera : ' + cameraStatusInfo.camera.cameraId); + console.log('status: ' + cameraStatusInfo.status); +}) +``` + +## Camera + +when we call *cameraManager.getCameras()* API, then it will return the **Camera** class which will have all camera-related metadata such as *cameraId, cameraPosition, cameraType & connectionType*. + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Fields** + +| Name | Type | Access | Description | +|----------------|----------------|----------|------------------------| +| cameraId | string | readonly | Camera ID | +| cameraPosition | cameraPosition | readonly | Camera position | +| cameraType | cameraType | readonly | Camera type | +| connectionType | connectionType | readonly | Camera connection type | + +``` +async function getCameraInfo() { + var cameraManager = await camera.getCameraManager(); + var cameras = await cameraManager.getCameras(); + var cameraObj = cameras[0]; + var cameraId = cameraObj.cameraId; + var cameraPosition = cameraObj.cameraPosition; + var cameraType = cameraObj.cameraType; + var cameraId = cameraObj.connectionType; +} + +``` + +## CameraStatusInfo + +This interface is a CameraManager callback API return. **CameraStatusInfo** will have *Camera* class & *CameraStatus* predefine constants.From *Camera* class, we can have all camera-related metadata & from *CameraStatus* constants, we will have information such as *APPEAR, DISAPPEAR, AVAILABLE & UNAVAILABLE*. + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Fields** + +| Name | Type | Description | +|----------------|----------------|------------------| +| camera | Camera | Camera object | +| status | CameraStatus | Camera status | + + +## CameraInput + +Implements a **CameraInput** instance. + +### getCameraId(callback: AsyncCallback\): void; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Gets the camera ID based on which this **CameraInput** instance is created. This method uses an asynchronous callback to return the camera ID. + +**Parameters** + +| Name | Type | Mandatory | Description | +|----------|------------------------|-----------|---------------------------------------| +| callback | AsyncCallback | Yes | Callback used to return the camera ID | + +``` +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); +}) +``` + +### getCameraId(): Promise; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Gets the camera ID based on which this **CameraInput** instance is created. This method uses a promise to return the camera ID. + +**Return values** + +| Type | Description | +|------------------------|--------------------------------------| +| Promise | Promise used to return the camera ID | + +**Example** + +``` +cameraInput.getCameraId().then((cameraId) => { + console.log('Promise returned with the camera ID:' + cameraId); +}) +``` + +### hasFlash(callback: AsyncCallback): void; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Checks whether the device has flash light. This method uses an asynchronous callback to return the result. + +**Parameters** + +| Name | Type | Mandatory | Description | +|----------|-------------------------|-----------|----------------------------------------------------| +| callback | AsyncCallback | Yes | Callback used to return the flash light support status | + +**Example** + +``` +cameraInput.hasFlash((err, status) => { + if (err) { + console.error('Failed to check whether the device has flash light. ${err.message}'); + return; + } + console.log('Callback returned with flash light support status: ' + status); +}) +``` + +### hasFlash(): Promise; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Checks whether the device has flash light. This method uses a promise to return the result. + +**Return values** + +| Type | Description | +|-----------------------|--------------------------------------------------------| +| Promise | Promise used to return the flash light support status | + +**Example** + +``` +cameraInput.hasFlash().then((status) => { + console.log('Promise returned with the flash light support status:' + status); +}) +``` + +### isFlashModeSupported(flashMode: FlashMode, callback: AsyncCallback): void; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Checks whether a specified flash mode is supported. This method uses an asynchronous callback to return the result. + +**Parameters** + +| Name | Type | Mandatory | Description | +|-----------|------------------------|-----------|----------------------------------------------------| +| flashMode | FlashMode | Yes | Flash mode | +| callback | AsyncCallback | Yes | Callback used to return the device flash support status | + +**Example** + +``` +cameraInput.isFlashModeSupported(flashMode, (err, status) => { + if (err) { + console.error('Failed to check whether the flash mode is supported. ${err.message}'); + return; + } + console.log('Callback returned with the flash mode support status: ' + status); +}) +``` + +### isFlashModeSupported(flashMode: FlashMode): Promise; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Checks whether a specified flash mode is supported. This method uses a promise to return the result. + +**Parameters** + +| Name | Type | Mandatory | Description | +|-----------|------------------------|-----------|----------------------------------------------------| +| flashMode | FlashMode | Yes | Flash mode | + +**Return values** + +| Type | Description | +|-----------------------|---------------------------------------------------| +| Promise | Promise used to return flash mode support status. | + +**Example** + +``` +cameraInput.isFlashModeSupported(flashMode).then((status) => { + console.log('Promise returned with flash mode support status.' + status); +}) +``` + +### setFlashMode(flashMode: FlashMode, callback: AsyncCallback): void; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Sets flash mode. This method uses an asynchronous callback to return the result. + +Note: Before setting the flash mode, check the support for the flash light (hasFlash method) and flash mode support (isFlashModeSupported method); + +**Parameters** + +| Name | Type | Mandatory | Description | +|-----------|------------------------|-----------|----------------------------------------------------| +| flashMode | FlashMode | Yes | Flash mode | +| callback | AsyncCallback | Yes | Callback used to return the result | + +**Example** + +``` +cameraInput.setFlashMode(flashMode, (err) => { + if (err) { + console.error('Failed to set the flash mode ${err.message}'); + return; + } + console.log('Callback returned with the successful execution of setFlashMode.'); +}) +``` + +### setFlashMode(flashMode: FlashMode): Promise; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Sets flash mode. This method uses a promise to return the result. + +Note: Before setting the flash mode, check the support for the flash light (hasFlash method) and flash mode support (isFlashModeSupported method); + +**Parameters** + +| Name | Type | Mandatory | Description | +|-----------|------------------------|-----------|----------------------------------------------------| +| flashMode | FlashMode | Yes | Flash mode | + +**Return values** + +| Type | Description | +|-----------------------|-----------------------------------------| +| Promise | Promise used to return the result | + +**Example** + +``` +cameraInput.setFlashMode(flashMode).then(() => { + console.log('Promise returned with the successful execution of setFlashMode.'); +}) +``` + +### getFlashMode(callback: AsyncCallback): void; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Gets current flash mode. This method uses an asynchronous callback to return the result. + +**Parameters** + +| Name | Type | Mandatory | Description | +|-----------|---------------------------|-----------|------------------------------------------------| +| callback | AsyncCallback | Yes | Callback used to return the current flash mode | + +**Example** + +``` +cameraInput.getFlashMode((err, flashMode) => { + if (err) { + console.error('Failed to get the flash mode ${err.message}'); + return; + } + console.log('Callback returned with current flash mode: ' + flashMode); +}) +``` + +### getFlashMode(): Promise; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Gets current flash mode. This method uses a promise to return the result. + +**Return values** + +| Type | Description | +|-----------------------|---------------------------------------------------| +| Promise | Promise used to return the flash mode | + +**Example** + +``` +cameraInput.getFlashMode().then((flashMode) => { + console.log('Promise returned with current flash mode : ' + flashMode); +}) +``` + +### isFocusModeSupported(afMode: FocusMode, callback: AsyncCallback): void; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Checks whether a specified focus mode is supported. This method uses an asynchronous callback to return the result. + +**Parameters** + +| Name | Type | Mandatory | Description | +|-----------|------------------------|-----------|----------------------------------------------------| +| afMode | FocusMode | Yes | Focus mode | +| callback | AsyncCallback | Yes | Callback used to return the device focus support status | + +**Example** + +``` +cameraInput.isFocusModeSupported(afMode, (err, status) => { + if (err) { + console.error('Failed to check whether the focus mode is supported. ${err.message}'); + return; + } + console.log('Callback returned with the focus mode support status: ' + status); +}) +``` + +### isFocusModeSupported(afMode: FocusMode): Promise; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Checks whether a specified focus mode is supported. This method uses a promise to return the result. + +**Parameters** + +| Name | Type | Mandatory | Description | +|-----------|----------------------------------------|-----------|-------------| +| afMode | FocusMode | Yes | Focus mode | + +**Return values** + +| Type | Description | +|-----------------------|---------------------------------------------------| +| Promise | Promise used to return the focus mode support status. | + +**Example** + +``` +cameraInput.isFocusModeSupported(afMode).then((status) => { + console.log('Promise returned with focus mode support status.' + status); +}) +``` + +### setFocusMode(afMode: FocusMode, callback: AsyncCallback): void; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Sets focus mode. This method uses an asynchronous callback to return the result. + +Note: Before setting the focus mode, check focus mode support (isFocusModeSupported method); + +**Parameters** + +| Name | Type | Mandatory | Description | +|-----------|------------------------|-----------|------------------------------------| +| afMode | FocusMode | Yes | Focus mode | +| callback | AsyncCallback | Yes | Callback used to return the result | + +**Example** + +``` +cameraInput.setFocusMode(afMode, (err) => { + if (err) { + console.error('Failed to set the focus mode ${err.message}'); + return; + } + console.log('Callback returned with the successful execution of setFocusMode.'); +}) +``` + +### setFocusMode(afMode: FocusMode): Promise; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Sets focus mode. This method uses a promise to return the result. + +Note: Before setting the focus mode, check focus mode support (isFocusModeSupported method); + +**Parameters** + +| Name | Type | Mandatory | Description | +|-----------|-----------------------------------------|-----------|-------------| +| afMode | FocusMode | Yes | Focus mode | + +**Return values** + +| Type | Description | +|-----------------------|-----------------------------------------| +| Promise | Promise used to return the result | + +**Example** + +``` +cameraInput.setFocusMode(afMode).then(() => { + console.log('Promise returned with the successful execution of setFocusMode.'); +}) +``` + +### getFocusMode(callback: AsyncCallback): void; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Gets the current focus mode. This method uses an asynchronous callback to return the result. + +**Parameters** + +| Name | Type | Mandatory | Description | +|-----------|---------------------------|-----------|------------------------------------------------| +| callback | AsyncCallback | Yes | Callback used to return the current focus mode | + +**Example** + +``` +cameraInput.getFocusMode((err, afMode) => { + if (err) { + console.error('Failed to get the focus mode ${err.message}'); + return; + } + console.log('Callback returned with current focus mode: ' + afMode); +}) +``` + +### getFocusMode(): Promise; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Gets the current focus mode. This method uses a promise to return the result. + +**Return values** + +| Type | Description | +|-----------------------|---------------------------------------------------| +| Promise | Promise used to return the focus mode | + +**Example** + +``` +cameraInput.getFocusMode().then((afMode) => { + console.log('Promise returned with current focus mode : ' + afMode); +}) +``` + +### getZoomRatioRange\(callback: AsyncCallback\>\): void; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Gets the zoom ratios of all zoom values. This method uses an asynchronous callback to return the result. + +**Parameters** + +| Name | Type | Mandatory | Description | +|----------|--------------------------------|-----------|-------------------------------------------------| +| callback | AsyncCallback\> | Yes | Callback used to return the zoom ratio range | + +**Example** + +``` +cameraInput.getZoomRatioRange((err, zoomRatioRange) => { + if (err) { + console.error('Failed to get the zoom ratio range. ${err.message}'); + return; + } + console.log('Callback returned with zoom ratio range: ' + zoomRatioRange.length); +}) +``` + +### getZoomRatioRange\(\): Promise\>; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Gets the zoom ratios of all zoom values. This method uses a promise to return the result. + +**Return values** + +| Type | Description | +|------------------------|---------------------------------------------| +| Promise\> | Promise used to return the zoom ratio range | + +**Example** + +``` +cameraInput.getZoomRatioRange().then((zoomRatioRange) => { + console.log('Promise returned with zoom ratio range: ' + zoomRatioRange.length); +}) +``` + +### setZoomRatio(zoomRatio: number, callback: AsyncCallback): void; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Sets a zoom ratio. This method uses an asynchronous callback to return the result. + +**Parameters** + +| Name | Type | Mandatory | Description | +|-----------|------------------------|-----------|------------------------------------| +| zoomRatio | number | Yes | Zoom ratio | +| callback | AsyncCallback | Yes | Callback used to return the result | + +**Example** + +``` +cameraInput.setZoomRatio(zoomRatio, (err) => { + if (err) { + console.error('Failed to set the zoom ratio value ${err.message}'); + return; + } + console.log('Callback returned with the successful execution of setZoomRatio.'); +}) +``` + +### setZoomRatio(zoomRatio: number): Promise; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Sets a zoom ratio. This method uses a promise to return the result. + +**Parameters** + +| Name | Type | Mandatory | Description | +|-----------|----------|-----------|-------------| +| zoomRatio | number | Yes | zoom ratio | + +**Return values** + +| Type | Description | +|-----------------------|-----------------------------------------| +| Promise | Promise used to return the result | + +**Example** + +``` +cameraInput.setZoomRatio(zoomRatio).then(() => { + console.log('Promise returned with the successful execution of setZoomRatio.'); +}) +``` + +### getZoomRatio(callback: AsyncCallback): void; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Gets current zoom ratio value. This method uses an asynchronous callback to return the result. + +**Parameters** + +| Name | Type | Mandatory | Description | +|-----------|---------------------------|-----------|------------------------------------------------------| +| callback | AsyncCallback | Yes | Callback used to return the current zoom ratio value | + +**Example** + +``` +cameraInput.getZoomRatio((err, zoomRatio) => { + if (err) { + console.error('Failed to get the zoom ratio ${err.message}'); + return; + } + console.log('Callback returned with current zoom ratio: ' + zoomRatio); +}) +``` + +### getZoomRatio(): Promise; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Gets current zoom ratio value. This method uses a promise to return the result. + +**Return values** + +| Type | Description | +|-----------------------|---------------------------------------------------| +| Promise | Promise used to return the zoom ratio vaule | + +**Example** + +``` +cameraInput.getZoomRatio().then((zoomRatio) => { + console.log('Promise returned with current zoom ratio : ' + zoomRatio); +}) +``` + +### release\(callback: AsyncCallback\): void; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Releases this **CameraInput** instance. This method uses an asynchronous callback to return the result. + +**Parameters** + +| Name | Type | Mandatory | Description | +|----------|----------------------|-----------|------------------------------------| +| callback | AsyncCallback | Yes | Callback used to return the result | + +**Example** + +``` +cameraInput.release((err) => { + 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.'); +}); +``` + +### release(): Promise; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Releases this **CameraInput** instance. This method uses a promise to return the result. + +**Return values** + +| Type | Description | +|----------------|---------------------------------------------| +| Promise | Promise used to return the result | + +**Example** + +``` +cameraInput.release().then(() => { + console.log('Promise returned to indicate that the CameraInput instance is released successfully.'); +}) +``` + +### on(type: 'focusStateChange', callback: Callback): void; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Listens for focus state changes. This method uses a callback to get focus state changes. + +**Parameters** + +| Name | Type | Mandatory | Description | +| :------- | :--------------------- | :-------- | :-----------------------------------------------| +| type | string | Yes | Name of the event to listen for. | +| callback | Callback | Yes | Callback used to get the focus state change. | + +**Example** + +``` +cameraInput.on('focusStateChange', (focusState) => { + console.log('Focus state : ' + focusState); +}) +``` + +### on(type: 'error', callback: Callback): void; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Listens for **CameraInput** errors. This method uses a callback to get errors. + +**Parameters** + +| Name | Type | Mandatory | Description | +| :------- | :--------------------- | :-------- | :-----------------------------------------------| +| type | string | Yes | Camera input error event. | +| callback | Callback | Yes | Callback used to get the camera input errors. | + +**Example** + +``` +cameraInput.on('error', (cameraInputError) => { + console.log('Camera input error code: ' + cameraInputError.code); +}) +``` + +## FlashMode + +Enumerates the flash modes. + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +| Name | Default value | Description | +|------------------------|---------------|------------------------| +| FLASH_MODE_CLOSE | 0 | Flash mode close | +| FLASH_MODE_OPEN | 1 | Flash mode open | +| FLASH_MODE_AUTO | 2 | Flash mode auto | +| FLASH_MODE_ALWAYS_OPEN | 3 | Flash mode always open | + +## FocusMode + +Enumerates the focus modes. + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +| Name | Default value | Description | +|----------------------------|---------------|----------------------------| +| FOCUS_MODE_MANUAL | 0 | Focus mode manual | +| FOCUS_MODE_CONTINUOUS_AUTO | 1 | Focus mode continuous auto | +| FOCUS_MODE_AUTO | 2 | Focus mode auto | +| FOCUS_MODE_LOCKED | 3 | Focus mode locked | + +## createCaptureSession\(context: Context, callback: AsyncCallback\): void; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Creates a **CaptureSession** instance. This method uses an asynchronous callback to return the instance. + +**Parameters** + +| Name | Type | Mandatory | Description | +|----------|--------------------------------|-----------|-----------------------------------------------------| +| context | Context | Yes | Application context | +| callback | AsyncCallback | Yes | Callback used to return the CaptureSession instance | + +**Example** + +``` +captureSession.createCaptureSession((context), (err, captureSession) => { + if (err) { + console.error('Failed to create the CaptureSession instance. ${err.message}'); + return; + } + console.log('Callback returned with the CaptureSession instance.' + captureSession); +}); +``` + +## createCaptureSession(context: Context\): Promise; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Creates a **CaptureSession** instance. This method uses a promise to return the instance. + +**Parameters** + +| Name | Type | Mandatory | Description | +|----------|-------------------------------|-----------|-----------------------------------------------------| +| context | Context | Yes | Application context | + +**Return values** + +| Type | Description | +|---------------------------|---------------------------------------------------| +| Promise | Promise used to return the CaptureSession instance. | + +**Example** + +``` +captureSession.createCaptureSession(context).then((captureSession) => { + console.log('Promise returned with the CaptureSession instance'); +}) +``` + +## CaptureSession + +Implements session capture. + +### beginConfig\(callback: AsyncCallback\): void; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Starts configuration for this CaptureSession instance. This method uses an asynchronous callback to return the result. + +**Parameters** + +| Name | Type | Mandatory | Description | +|----------|----------------------|-----------|----------------------------------------------| +| callback | AsyncCallback | Yes | Callback used to return the result | + +**Example** + +``` +captureSession.beginConfig((err) => { + if (err) { + console.error('Failed to start the configuration. ${err.message}'); + return; + } + console.log('Callback invoked to indicate the begin config success.'); +}); +``` + +### beginConfig\(\): Promise; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Starts configuration for this CaptureSession instance. This method uses a promise to return the result. + +**Return values** + +| Type | Description | +|---------------|---------------------------------------------| +| Promise | Promise used to return the result | + + +**Example** + +``` +captureSession.beginConfig().then(() => { + console.log('Promise returned to indicate the begin config success.'); +}) +``` + +### commitConfig\(callback: AsyncCallback\): void; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Commits the configuration for this CaptureSession instance. This method uses an asynchronous callback to return the result. + +**Parameters** + +| Name | Type | Mandatory | Description | +|----------|---------------------|-----------|----------------------------------------------| +| callback | AsyncCallback | Yes | Callback used to return the result | + +**Example** + +``` +captureSession.commitConfig((err) => { + if (err) { + console.error('Failed to commit the configuration. ${err.message}'); + return; + } + console.log('Callback invoked to indicate the commit config success.'); +}); +``` + +### commitConfig\(\): Promise; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Commits the configuration for this CaptureSession instance. This method uses a promise to return the result. + +**Return values** + +| Type | Description | +|---------------|---------------------------------------------| +| Promise | Promise used to return the result | + +**Example** + +``` +captureSession.commitConfig().then(() => { + console.log('Promise returned to indicate the commit config success.'); +}) +``` + +### addInput\(cameraInput: CameraInput, callback: AsyncCallback\): void; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Add a CameraInput instance to this CaptureSession instance. This method uses an asynchronous callback to return the result. + +**Parameters** + +| Name | Type | Mandatory | Description | +|-------------|----------------------|-----------|---------------------------------------------| +| cameraInput | CameraInput | Yes | CameraInput instance to add | +| callback | AsyncCallback | Yes | Callback used to return the result | + +**Example** + +``` +captureSession.addInput(cameraInput, (err) => { + if (err) { + console.error('Failed to add the CameraInput instance. ${err.message}'); + return; + } + console.log('Callback invoked to indicate that the CameraInput instance is added.'); +}); +``` + +### addInput\(cameraInput: CameraInput\): Promise; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Add a CameraInput instance to this CaptureSession instance. This method uses a promise to return the result. + +**Parameters** + +| Name | Type | Mandatory | Description | +|-------------|---------------------|-----------|-------------------------------| +| cameraInput | CameraInput | Yes | CameraInput instance to add | + +**Return values** + +| Type | Description | +|----------------|------------------------------------| +| Promise | Promise used to return the result | + +**Example** + +``` +captureSession.addInput(cameraInput).then(() => { + console.log('Promise used to indicate that the CameraInput instance is added.'); +}) +``` + +### addOutput\(previewOutput: PreviewOutput, callback: AsyncCallback\): void; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Add a PreviewOutput instance to this CaptureSession instance. This method uses an asynchronous callback to return the result. + +**Parameters** + +| Name | Type | Mandatory | Description | +|---------------|----------------------|-----------|-------------------------------------| +| previewOutput | PreviewOutput | Yes | PreviewOutput instance to add | +| callback | AsyncCallback | Yes | Callback used to return the result | + +**Example** + +``` +captureSession.addOutput(previewOutput, (err) => { + if (err) { + console.error('Failed to add the PreviewOutput instance ${err.message}'); + return; + } + console.log('Callback invoked to indicate that the PreviewOutput instance is added.'); +}); +``` + +### addOutput\(previewOutput: PreviewOutput\): Promise; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Add a PreviewOutput instance to this CaptureSession instance. This method uses a promise to return the result. + +**Parameters** + +| Name | Type | Mandatory | Description | +|---------------|---------------------|-----------|--------------------------------| +| previewOutput | PreviewOutput | Yes | PreviewOutput instance to add | + +**Return values** + +| Type | Description | +|----------------|-----------------------------------| +| Promise | Promise used to return the result | + +**Example** + +``` +captureSession.addOutput(previewOutput).then(() => { + console.log('Promise used to indicate that the PreviewOutput instance is added.'); +}) +``` + +### addOutput\(photoOutput: PhotoOutput, callback: AsyncCallback\): void; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Add a PhotoOutput instance to this CaptureSession instance. This method uses an asynchronous callback to return the result. + +**Parameters** + +| Name | Type | Mandatory | Description | +|---------------|---------------------|-----------|-------------------------------------| +| photoOutput | PhotoOutput | Yes | PhotoOutput instance to add | +| callback | AsyncCallback | Yes | Callback used to return the result | + +**Example** + +``` +captureSession.addOutput(photoOutput, (err) => { + if (err) { + console.error('Failed to add the PhotoOutput instance ${err.message}'); + return; + } + console.log('Callback invoked to indicate that the PhotoOutput instance is added.'); +}); +``` + +### addOutput\(photoOutput: PhotoOutput\): Promise; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Add a PhotoOutput instance to this CaptureSession instance. This method uses a promise to return the result. + +**Parameters** + +| Name | Type | Mandatory | Description | +|---------------|---------------------|-----------|--------------------------------| +| photoOutput | PhotoOutput | Yes | PhotoOutput instance to add | + +**Return values** + +| Type | Description | +|---------------|-----------------------------------| +| Promise | Promise used to return the result | + +**Example** + +``` +captureSession.addOutput(photoOutput).then(() => { + console.log('Promise used to indicate that the PhotoOutput instance is added.'); +}) +``` + +### addOutput\(videoOutput: VideoOutput, callback: AsyncCallback\): void; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Add a VideoOutput instance to this CaptureSession instance. This method uses an asynchronous callback to return the result. + +**Parameters** + +| Name | Type | Mandatory | Description | +|---------------|---------------------|-----------|-------------------------------------| +| videoOutput | VideoOutput | Yes | VideoOutput instance to add | +| callback | AsyncCallback | Yes | Callback used to return the result | + +**Example** + +``` +captureSession.addOutput(videoOutput, (err) => { + 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.'); +}); +``` + +### addOutput\(videoOutput: VideoOutput\): Promise; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Add a VideoOutput instance to this CaptureSession instance. This method uses a promise to return the result. + +**Parameters** + +| Name | Type | Mandatory | Description | +|---------------|---------------------|-----------|--------------------------------| +| videoOutput | VideoOutput | Yes | VideoOutput instance to add | + +**Return values** + +| Type | Description | +|----------------|-----------------------------------| +| Promise | Promise used to return the result | + +**Example** + +``` +captureSession.addOutput(videoOutput).then(() => { + console.log('Promise used to indicate that the VideoOutput instance is added.'); +}) +``` + +### removeInput\(cameraInput: CameraInput, callback: AsyncCallback\): void; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Removes a **CameraInput** instance from this **CaptureSession** instance. This method uses an asynchronous callback to return the result. + +**Parameters** + +| Name | Type | Mandatory | Description | +|-------------|----------------------|-----------|------------------------------------| +| cameraInput | CameraInput | Yes | CameraInput instance to remove | +| callback | AsyncCallback | Yes | Callback used to return the result | + +**Example** + +``` +captureSession.removeInput(cameraInput, (err) => { + 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.'); +}); +``` + +### removeInput\(cameraInput: CameraInput\): Promise; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Removes a **CameraInput** instance from this **CaptureSession** instance. This method uses a promise to return the result. + +**Parameters** + +| Name | Type | Mandatory | Description | +|-------------|---------------------|-----------|---------------------------------| +| cameraInput | CameraInput | Yes | CameraInput instance to remove | + +**Return values** + +| Type | Description | +|----------------|-----------------------------------| +| Promise | Promise used to return the result | + +**Example** + +``` +captureSession.removeInput(cameraInput).then(() => { + console.log('Promise returned to indicate that the cameraInput instance is removed.'); +}) +``` + +### removeOutput\(previewOutput: PreviewOutput, callback: AsyncCallback\): void; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Removes a **PreviewOutput** instance from this **CaptureSession** instance. This method uses an asynchronous callback to return the result. + +**Parameters** + +| Name | Type | Mandatory | Description | +|---------------|----------------------|-----------|------------------------------------| +| previewOutput | PreviewOutput | Yes | PreviewOutput instance to remove | +| callback | AsyncCallback | Yes | Callback used to return the result | + +**Example** + +``` +captureSession.removeOutput(previewOutput, (err) => { + 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.'); +}); +``` + +### removeOutput(previewOutput: PreviewOutput): Promise; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Removes a **PreviewOutput** instance from this **CaptureSession** instance. This method uses a promise to return the result. + +**Parameters** + +| Name | Type | Mandatory | Description | +|---------------|---------------------|-----------|-----------------------------------| +| previewOutput | PreviewOutput | Yes | PreviewOutput instance to remove | + + +**Return values** + +| Type | Description | +|---------------|---------------------------------------------| +| Promise | Promise used to return the result | + + +**Example** + +``` +captureSession.removeOutput(previewOutput).then(() => { + console.log('Promise returned to indicate that the PreviewOutput instance is removed.'); +}) +``` + +### removeOutput(photoOutput: PhotoOutput, callback: AsyncCallback): void; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Removes a **PhotoOutput** instance from this **CaptureSession** instance. This method uses an asynchronous callback to return the result. + +**Parameters** + +| Name | Type | Mandatory | Description | +|---------------|----------------------|-----------|------------------------------------| +| photoOutput | PhotoOutput | Yes | PhotoOutput instance to remove | +| callback | AsyncCallback | Yes | Callback used to return the result | + +**Example** + +``` +captureSession.removeOutput(photoOutput, (err) => { + 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.'); +}); +``` + +### removeOutput(photoOutput: PhotoOutput): Promise; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Removes a **PhotoOutput** instance from this **CaptureSession** instance. This method uses a promise to return the result. + +**Parameters** + +| Name | Type | Mandatory | Description | +|---------------|---------------------|-----------|---------------------------------| +| photoOutput | PhotoOutput | Yes | PhotoOutput instance to remove | + + +**Return values** + +| Type | Description | +|---------------|------------------------------------| +| Promise | Promise used to return the result | + + +**Example** + +``` +captureSession.removeOutput(photoOutput).then(() => { + console.log('Promise returned to indicate that the PhotoOutput instance is removed.'); +}) +``` + +### removeOutput(videoOutput: VideoOutput, callback: AsyncCallback): void; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Removes a **VideoOutput** instance from this **CaptureSession** instance. This method uses an asynchronous callback to return the result. + +**Parameters** + +| Name | Type | Mandatory | Description | +|---------------|----------------------|-----------|------------------------------------| +| videoOutput | VideoOutput | Yes | VideoOutput instance to remove | +| callback | AsyncCallback | Yes | Callback used to return the result | + +**Example** + +``` +captureSession.removeOutput(videoOutput, (err) => { + 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.'); +}); +``` + +### removeOutput(videoOutput: VideoOutput): Promise; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Removes a **VideoOutput** instance from this **CaptureSession** instance. This method uses a promise to return the result. + +**Parameters** + +| Name | Type | Mandatory | Description | +|---------------|---------------------|-----------|---------------------------------| +| videoOutput | VideoOutput | Yes | VideoOutput instance to remove | + + +**Return values** + +| Type | Description | +|----------------|---------------------------------------------| +| Promise | Promise used to return the result | + + +**Example** + +``` +captureSession.removeOutput(videoOutput).then(() => { + console.log('Promise returned to indicate that the VideoOutput instance is removed.'); +}) +``` + +### start\(callback: AsyncCallback\): void; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Starts this **CaptureSession** instance. This method uses an asynchronous callback to return the result. + +**Parameters** + +| Name | Type | Mandatory | Description | +|----------|----------------------|-----------|----------------------------------------------| +| callback | AsyncCallback | Yes | Callback used to return the result | + +**Example** + +``` +captureSession.start((err) => { + if (err) { + console.error('Failed to start the session ${err.message}'); + return; + } + console.log('Callback invoked to indicate the session start success.'); +}); +``` + +### start\(\): Promise; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Starts this **CaptureSession** instance. This method uses a promise to return the result. + +**Return values** + +| Type | Description | +|----------------|-----------------------------------| +| Promise | Promise used to return the result | + +**Example** + +``` +captureSession.start().then(() => { + console.log('Promise returned to indicate the session start success.'); +}) +``` + +### stop\(callback: AsyncCallback\): void; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Stops this **CaptureSession** instance. This method uses an asynchronous callback to return the result. + +**Parameters** + + +| Name | Type | Mandatory | Description | +|----------|----------------------|-----------|------------------------------------| +| callback | AsyncCallback | Yes | Callback used to return the result | + +**Example** + +``` +captureSession.stop((err) => { + if (err) { + console.error('Failed to stop the session ${err.message}'); + return; + } + console.log('Callback invoked to indicate the session stop success.'); +}); +``` + +### stop(): Promise; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Stops this **CaptureSession** instance. This method uses a promise to return the result. + +**Return values** + +| Type | Description | +|----------------|-----------------------------------| +| Promise | Promise used to return the result | + +**Example** + +``` +captureSession.stop().then(() => { + console.log('Promise returned to indicate the session stop success.'); +}) +``` + +### release\(callback: AsyncCallback\): void; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Releases this **CaptureSession** instance. This method uses an asynchronous callback to return the result. + +**Parameters** + +| Name | Type | Mandatory | Description | +|----------|----------------------|-----------|------------------------------------| +| callback | AsyncCallback | Yes | Callback used to return the result | + +**Example** + +``` +captureSession.release((err) => { + 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.'); +}); +``` + +### release(): Promise; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Releases this **CaptureSession** instance. This method uses a promise to return the result. + +**Return values** + +| Type | Description | +|----------------|---------------------------------------------| +| Promise | Promise used to return the result | + +**Example** + +``` +captureSession.release().then(() => { + console.log('Promise returned to indicate that the CaptureSession instance is released successfully.'); +}) +``` + +### on(type: 'error', callback: Callback): void; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Listens for **CaptureSession** errors. This method uses a callback to get errors. + +**Parameters** + +| Name | Type | Mandatory | Description | +| :------- | :--------------------- | :-------- | :-----------------------------------------------| +| type | string | Yes | Capture session error event. | +| callback | Callback | Yes | Callback used to get the capture session errors. | + +**Example** + +``` +captureSession.on('error', (captureSessionError) => { + console.log('Capture session error code: ' + captureSessionError.code); +}) +``` + +## createPreviewOutput(surfaceId: string, callback: AsyncCallback): void; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Creates a **PreviewOutput** instance. This method uses an asynchronous callback to return the instance. + +**Parameters** + +| Name | Type | Mandatory | Description | +|------------|-------------------------------|-----------|----------------------------------------------------| +| surfaceId | string | Yes | Surface ID received from XComponent view | +| callback | AsyncCallback | Yes | Callback used to return the PreviewOutput instance | + +**Example** + +``` +camera.createPreviewOutput((surfaceId), (err, previewOutput) => { + if (err) { + console.error('Failed to create the PreviewOutput instance. ${err.message}'); + return; + } + console.log('Callback returned with previewOutput instance'); +}); +``` + +## createPreviewOutput(surfaceId: string): Promise; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Creates a **PreviewOutput** instance. This method uses a promise to return the instance. + +**Parameters** + +| Name | Type | Mandatory | Description | +|------------|-----------------|-----------|----------------------------------------------------| +| surfaceId | string | Yes | Surface ID received from XComponent view | + +**Return values** + +| Type | Description | +|-------------------------|---------------------------------------------------| +| Promise | Promise used to return the PreviewOutput instance | + +**Example** + +``` +camera.createPreviewOutput(surfaceId).then((previewOutput) => { + console.log('Promise returned with the PreviewOutput instance'); +}) +``` + +## PreviewOutput + +Implements preview output. + +### release(callback: AsyncCallback): void; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Releases this **PreviewOutput** instance. This method uses an asynchronous callback to return the result. + +**Parameters** + +| Name | Type | Mandatory | Description | +|----------|----------------------|-----------|----------------------------------------------| +| callback | AsyncCallback | Yes | Callback used to return the result | + +**Example** + +``` +previewOutput.release((err) => { + if (err) { + console.error('Failed to release the PreviewOutput instance ${err.message}'); + return; + } + console.log('Callback invoked to indicate that the PreviewOutput instance is released successfully.'); +}); +``` + +### release(): Promise; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Releases this **PreviewOutput** instance. This method uses a promise to return the result. + +**Return values** + +| Type | Description | +|----------------|-----------------------------------| +| Promise | Promise used to return the result | + + +**Example** + +``` +previewOutput.release().then(() => { + console.log('Promise returned to indicate that the PreviewOutput instance is released successfully.'); +}) +``` + +### on(type: 'frameStart', callback: Callback): void; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Listens for preview frame start events. This method uses a callback to get the event information. + +**Parameters** + +| Name | Type | Mandatory | Description | +| :------- | :---------------- | :-------- | :----------------------------------| +| type | string | Yes | Name of the event to listen for. | +| callback | Callback | Yes | Callback used to return the result | + +**Example** + +``` +previewOutput.on('frameStart', () => { + console.log('Preview frame started'); +}) +``` + +### on(type: 'frameEnd', callback: Callback): void; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Listens for preview frame end event. This method uses a callback to get the event information. + +**Parameters** + +| Name | Type | Mandatory | Description | +| :------- | :---------------- | :-------- | :----------------------------------| +| type | string | Yes | Name of the event to listen for. | +| callback | Callback | Yes | Callback used to return the result | + +**Example** + +``` +previewOutput.on('frameEnd', () => { + console.log('Preview frame ended'); +}) +``` + +### on(type: 'error', callback: Callback): void; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Listens for **PreviewOutput** errors. This method uses a callback to get errors. + +**Parameters** + +| Name | Type | Mandatory | Description | +| :------- | :--------------------- | :-------- | :-----------------------------------------------| +| type | string | Yes | Preview output error event. | +| callback | Callback | Yes | Callback used to get the preview output errors. | + +**Example** + +``` +previewOutput.on('error', (previewOutputError) => { + console.log('Preview output error code: ' + previewOutputError.code); +}) +``` + +## createPhotoOutput(surfaceId: string, callback: AsyncCallback): void; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Creates a **PhotoOutput** instance. This method uses an asynchronous callback to return the instance. + +**Parameters** + +| Name | Type | Mandatory | Description | +|------------|-------------------------------|-----------|----------------------------------------------------| +| surfaceId | string | Yes | Surface ID received from ImageReceiver | +| callback | AsyncCallback | Yes | Callback used to return the PhotoOutput instance | + +**Example** + +``` +camera.createPhotoOutput((surfaceId), (err, photoOutput) => { + if (err) { + console.error('Failed to create the PhotoOutput instance. ${err.message}'); + return; + } + console.log('Callback returned with the PhotoOutput instance.'); +}); +``` + +## createPhotoOutput(surfaceId: string): Promise; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Creates a **PhotoOutput** instance. This method uses a promise to return the PhotoOutput instance. + +**Parameters** + +| Name | Type | Mandatory | Description | +|------------|-----------------|-----------|----------------------------------------------------| +| surfaceId | string | Yes | Surface ID received from ImageReceiver | + +**Return values** + +| Type | Description | +|-------------------------|--------------------------------------------------| +| Promise | Promise used to return the PhotoOutput instance | + +**Example** + +``` +camera.createPhotoOutput(surfaceId).then((photoOutput) => { + console.log('Promise returned with PhotoOutput instance'); +}) +``` +## ImageRotation + +Enumerates the image rotation angles. + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +| Name | Default Value | Description | +|--------------|---------------|----------------------------------------| +| ROTATION_0 | 0 | The capture image rotates 0 degrees | +| ROTATION_90 | 90 | The capture image rotates 90 degrees | +| ROTATION_180 | 180 | The capture image rotates 180 degrees | +| ROTATION_270 | 270 | The capture image rotates 270 degrees | + + +## Location + +Defines the location of a captured image. + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +| Name | Type | Access | Description | +|-----------|--------|--------------|-------------| +| latitude | number | read / write | Latitude | +| longitude | number | read / write | Longitude | + +## QualityLevel + +Enumerates the image quality levels. + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +| Name | Default value | Description | +|----------------------|---------------|----------------------| +| QUALITY_LEVEL_HIGH | 0 | High image quality | +| QUALITY_LEVEL_MEDIUM | 1 | Medium image quality | +| QUALITY_LEVEL_LOW | 2 | Low image quality | + + +## PhotoCaptureSetting + +Defines the settings for image capture. + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +| Name | Type | Mandatory | Description | +|----------|---------------|-----------|---------------------| +| quality | QualityLevel | Optional | Photo image quality | +| rotation | ImageRotation | Optional | Photo rotation | + + +## PhotoOutput + +Implements photo output. + +### capture(callback: AsyncCallback): void; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Captures a photo. This method uses an asynchronous callback to return the result. + +**Parameters** + +| Name | Type | Mandatory | Description | +|----------|---------------------|-----------|----------------------------------------------| +| callback | AsyncCallback | Yes | Callback used to return the result | + +**Example** + +``` +photoOutput.capture((err) => { + if (err) { + console.error('Failed to capture the photo ${err.message}'); + return; + } + console.log('Callback invoked to indicate the photo capture request success.'); +}); +``` + +### capture(setting: PhotoCaptureSetting, callback: AsyncCallback): void; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Captures a photo with the specified capture settings. This method uses an asynchronous callback to return the result. + +**Parameters** + +| Name | Type | Mandatory | Description | +|----------|----------------------|-----------|----------------------------------------------| +| setting | PhotoCaptureSetting | Yes | Photo capture settings | +| callback | AsyncCallback | Yes | Callback used to return the result | + +**Example** + +``` +photoOutput.capture(settings, (err) => { + if (err) { + console.error('Failed to capture the photo ${err.message}'); + return; + } + console.log('Callback invoked to indicate the photo capture request success.'); +}); +``` + +### capture(setting?: PhotoCaptureSetting): Promise; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Captures a photo with the specified capture settings. This method uses a promise to return the result. + +**Parameters** + +| Name | Type | Mandatory | Description | +|----------|---------------------|-----------|----------------------------------------------| +| setting | PhotoCaptureSetting | No | Photo capture settings | + +**Return values** + +| Type | Description | +|----------------|---------------------------------------------| +| Promise | Promise used to return the result | + + +**Example** + +``` +photoOutput.capture().then(() => { + console.log('Promise returned to indicate that photo capture request success.'); +}) +``` + +### release(callback: AsyncCallback): void; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Releases this **PhotoOutput** instance. This method uses an asynchronous callback to return the result. + +**Parameters** + +| Name | Type | Mandatory | Description | +|----------|----------------------|-----------|----------------------------------------------| +| callback | AsyncCallback | Yes | Callback used to return the result | + +**Example** + +``` +photoOutput.release((err) => { + if (err) { + console.error('Failed to release the PhotoOutput instance ${err.message}'); + return; + } + console.log('Callback invoked to indicate that the PhotoOutput instance is released successfully.'); +}); +``` + +### release(): Promise; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Releases this **PhotoOutput** instance. This method uses a promise to return the result. + +**Return values** + +| Type | Description | +|----------------|---------------------------------------------| +| Promise | Promise used to return the result | + + +**Example** + +``` +photoOutput.release().then(() => { + console.log('Promise returned to indicate that the PhotoOutput instance is released successfully.'); +}) +``` + +### on(type: 'captureStart', callback: Callback): void; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Listens for photo capture start events. This method uses a callback to get the event information. + +**Parameters** + +| Name | Type | Mandatory | Description | +| :------- | :--------------------- | :-------- | :-----------------------------------------------| +| type | string | Yes | Name of the event to listen for. | +| callback | Callback | Yes | Callback used to get the capture ID. | + +**Example** + +``` +photoOutput.on('captureStart', (captureId) => { + console.log('photo capture stated, captureId : ' + captureId); +}) +``` + +### on(type: 'frameShutter', callback: Callback): void; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Listens for frame shutter events. This method uses a callback to get the event information. + +**Parameters** + +| Name | Type | Mandatory | Description | +| :------- | :--------------------- | :-------- | :-----------------------------------------------| +| type | string | Yes | Name of the event to listen for. | +| callback | Callback | Yes | Callback used to get the frame shutter information.| + +**Example** + +``` +photoOutput.on('frameShutter', (frameShutterInfo) => { + console.log('photo capture end, captureId : ' + frameShutterInfo.captureId); + console.log('Timestamp for frame : ' + frameShutterInfo.timestamp); +}) +``` + +### on(type: 'captureEnd', callback: Callback): void; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Listens for photo capture end events. This method uses a callback to get the event information. + +**Parameters** + +| Name | Type | Mandatory | Description | +| :------- | :--------------------- | :-------- | :------------------------------------------------| +| type | string | Yes | Name of the event to listen for. | +| callback | Callback | Yes | Callback used to get the capture end information | + +**Example** + +``` +photoOutput.on('captureEnd', (captureEndInfo) => { + console.log('photo capture end, captureId : ' + captureEndInfo.captureId); + console.log('frameCount : ' + captureEndInfo.frameCount); +}) +``` + +### on(type: 'error', callback: Callback): void; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Listens for **PhotoOutput** errors. This method uses a callback to get errors. + +**Parameters** + +| Name | Type | Mandatory | Description | +| :------- | :--------------------- | :-------- | :-----------------------------------------------| +| type | string | Yes | Photo output error event. | +| callback | Callback | Yes | Callback used to get the photo output errors. | + +**Example** + +``` +photoOutput.on('error', (photoOutputError) => { + console.log('Photo output error code: ' + photoOutputError.code); +}) +``` + +## createVideoOutput(surfaceId: string, callback: AsyncCallback): void; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Creates a **VideoOutput** instance. This method uses an asynchronous callback to return the instance. + +**Parameters** + +| Name | Type | Mandatory | Description | +|------------|-------------------------------|-----------|----------------------------------------------------| +| surfaceId | string | Yes | Surface ID received from VideoRecorder | +| callback | AsyncCallback | Yes | Callback used to return the VideoOutput instance | + +**Example** + +``` +camera.createVideoOutput((surfaceId), (err, videoOutput) => { + if (err) { + console.error('Failed to create the VideoOutput instance. ${err.message}'); + return; + } + console.log('Callback returned with the VideoOutput instance'); +}); +``` + +## createVideoOutput(surfaceId: string): Promise; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Creates a **VideoOutput** instance. This method uses a promise to return the VideoOutput instance. + +**Parameters** + +| Name | Type | Mandatory | Description | +|------------|-----------------|-----------|----------------------------------------------------| +| surfaceId | string | Yes | Surface ID received from VideoRecorder | + +**Return values** + +| Type | Description | +|---------------------------------------|-------------------------------------------------| +| Promise<[VideoOutput](#videooutput)\> | Promise used to return the VideoOutput instance | + +**Example** + +``` +camera.createVideoOutput(surfaceId).then((videoOutput) => { + console.log('Promise returned with the VideoOutput instance'); +}) +``` +## VideoOutput + +Implements video output. + +### start(callback: AsyncCallback): void; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Starts the video output. This method uses an asynchronous callback to return the result. + +**Parameters** + +| Name | Type | Mandatory | Description | +|----------|----------------------|-----------|----------------------------------------------| +| callback | AsyncCallback | Yes | Callback used to return the result | + +**Example** + +``` +videoOutput.start((err) => { + if (err) { + console.error('Failed to start the video output ${err.message}'); + return; + } + console.log('Callback invoked to indicate the video output start success.'); +}); +``` + +### start(): Promise; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Starts the video output. This method uses a promise to return the result. + +**Return values** + +| Type | Description | +|----------------|---------------------------------------------| +| Promise | Promise used to return the result | + + +**Example** + +``` +videoOutput.start().then(() => { + console.log('Promise returned to indicate that start method execution success.'); +}) +``` + +### stop(callback: AsyncCallback): void; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Stops the video output. This method uses an asynchronous callback to return the result. + +**Parameters** + +| Name | Type | Mandatory | Description | +|----------|----------------------|-----------|----------------------------------------------| +| callback | AsyncCallback | Yes | Callback used to return the result | + +**Example** + +``` +videoOutput.stop((err) => { + if (err) { + console.error('Failed to stop the video output ${err.message}'); + return; + } + console.log('Callback invoked to indicate the video output stop success.'); +}); +``` + +### stop(): Promise; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Stops the video output. This method uses a promise to return the result. + +**Return values** + +| Type | Description | +|----------------|---------------------------------------------| +| Promise | Promise used to return the result | + +**Example** + +``` +videoOutput.start().then(() => { + console.log('Promise returned to indicate that stop method execution success.'); +}) +``` + +### release(callback: AsyncCallback): void; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Releases this VideoOutput instance. This method uses an asynchronous callback to return the result. + +**Parameters** + +| Name | Type | Mandatory | Description | +|----------|----------------------|-----------|----------------------------------------------| +| callback | AsyncCallback | Yes | Callback used to return the result | + +**Example** + +``` +videoOutput.release((err) => { + if (err) { + console.error('Failed to release the VideoOutput instance ${err.message}'); + return; + } + console.log('Callback invoked to indicate that the VideoOutput instance is released successfully.'); +}); +``` + +### release(): Promise; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Releases this VideoOutput instance. This method uses a promise to return the result. + +**Return values** + +| Type | Description | +|----------------|---------------------------------------------| +| Promise | Promise used to return the result | + + +**Example** + +``` +videoOutput.release().then(() => { + console.log('Promise returned to indicate that the VideoOutput instance is released successfully.'); +}) +``` + +### on(type: 'frameStart', callback: Callback): void; + +**System Capabilities:** + +SystemCapability.Multimedia.Camera.Core + +**Description** + +Listens for video frame start events. This method uses a callback to get the event information. + +**Parameters** + +| Name | Type | Mandatory | Description | +| :------- | :---------------- | :-------- | :----------------------------------| +| type | string | Yes | Name of the event to listen for. | +| callback | Callback | Yes | Callback used to return the result | + +**Example** + +``` +videoOutput.on('frameStart', () => { + console.log('Video frame started'); +}) +``` + +### on(type: 'frameEnd', callback: Callback): void; + +Listens for video frame end events. This method uses a callback to get the event information. + +**Parameters** + +| Name | Type | Mandatory | Description | +| :------- | :---------------- | :-------- | :----------------------------------| +| type | string | Yes | Name of the event to listen for. | +| callback | Callback | Yes | Callback used to return the result | + +**Example** + +``` +videoOutput.on('frameEnd', () => { + console.log('Video frame ended'); +}) +``` + +### on(type: 'error', callback: Callback): void; + +Listens for **VideoOutput** errors. This method uses a callback to get errors. + +**Parameters** + +| Name | Type | Mandatory | Description | +| :------- | :--------------------- | :-------- | :-----------------------------------------------| +| type | string | Yes | Video output error event. | +| callback | Callback | Yes | Callback used to get the video output errors. | + +**Example** + +``` +videoOutput.on('error', (VideoOutputError) => { + console.log('Video output error code: ' + VideoOutputError.code); +}) +``` \ No newline at end of file diff --git a/en/release-notes/api-change/v2.2-beta2/js-apidiff-v2.2-beta2.md b/en/release-notes/api-change/v2.2-beta2/js-apidiff-v2.2-beta2.md new file mode 100644 index 0000000000000000000000000000000000000000..be13f4ac7984c6e15d3e82f617c50020f485bf90 --- /dev/null +++ b/en/release-notes/api-change/v2.2-beta2/js-apidiff-v2.2-beta2.md @@ -0,0 +1,233 @@ +# JS API Differences +This document describes the changes of APIs in OpenHarmony 2.2 Beta2 over OpenHarmony 2.0 Canary. +## Standard System API Changes + +| Module | API | Change Type | Change Description | +| -------- | -------- | -------- | -------- | + | Time, date, and digit module - Locale | constructor(locale: string, options?:options) | Added | - | + | Time, date, and digit module - Locale | toString(): string | Added | - | + | Time, date, and digit module - Locale | maximize(): Locale | Added | - | + | Time, date, and digit module - Locale | minimize(): Locale | Added | - | + | Time, date, and digit module - Locale | calendar | Added | - | + | Time, date, and digit module - Locale | caseFirst | Added | - | + | Time, date, and digit module - Locale | collation | Added | - | + | Time, date, and digit module - Locale | hourCycle | Added | - | + | Time, date, and digit module - Locale | numberingSystem | Added | - | + | Time, date, and digit module - Locale | numeric | Added | - | + | Time, date, and digit module - Locale | language | Added | - | + | Time, date, and digit module - Locale | script | Added | - | + | Time, date, and digit module - Locale | region | Added | - | + | Time, date, and digit module - Locale | baseName | Added | - | + | Time, date, and digit module - DateTimeFormat | constructor(locale: string, options?:options) | Added | - | + | Time, date, and digit module - DateTimeFormat | constructor(locale: string[], options?:options) | Added | - | + | Time, date, and digit module - DateTimeFormat | resolvedOptions(): DateTimeOptions | Added | - | + | Time, date, and digit module - DateTimeFormat | format(date: Date): string; | Added | - | + | Time, date, and digit module - DateTimeFormat | formatRange(fromDate: Date, toDate: Date): string; | Added | - | + | Time, date, and digit module - NumberFormat | constructor(locale: string, options?:options) | Added | - | + | Time, date, and digit module - NumberFormat | constructor(locale: string[], options?:options) | Added | - | + | Time, date, and digit module - NumberFormat | resolvedOptions(): NumberOptions | Added | - | + | Time, date, and digit module - NumberFormat | format(number: number): string; | Added | - | + | Time, date, and digit module - DateTimeOptions | locale | Added | - | + | Time, date, and digit module - DateTimeOptions | dateStyle | Added | - | + | Time, date, and digit module - DateTimeOptions | timeStyle | Added | - | + | Time, date, and digit module - DateTimeOptions | calendar | Added | - | + | Time, date, and digit module - DateTimeOptions | dayPeriod | Added | - | + | Time, date, and digit module - DateTimeOptions | numberingSystem | Added | - | + | Time, date, and digit module - DateTimeOptions | localeMatcher | Added | - | + | Time, date, and digit module - DateTimeOptions | timeZone | Added | - | + | Time, date, and digit module - DateTimeOptions | hour12 | Added | - | + | Time, date, and digit module - DateTimeOptions | hourCycle | Added | - | + | Time, date, and digit module - DateTimeOptions | formatMatcher | Added | - | + | Time, date, and digit module - DateTimeOptions | weekday | Added | - | + | Time, date, and digit module - DateTimeOptions | era | Added | - | + | Time, date, and digit module - DateTimeOptions | year | Added | - | + | Time, date, and digit module - DateTimeOptions | month | Added | - | + | Time, date, and digit module - DateTimeOptions | day | Added | - | + | Time, date, and digit module - DateTimeOptions | hour | Added | - | + | Time, date, and digit module - DateTimeOptions | minute | Added | - | + | Time, date, and digit module - DateTimeOptions | second | Added | - | + | Time, date, and digit module - DateTimeOptions | timeZoneName | Added | - | + | Time, date, and digit module - NumberOptions | locale | Added | - | + | Time, date, and digit module - NumberOptions | compactDisplay | Added | - | + | Time, date, and digit module - NumberOptions | currency | Added | - | + | Time, date, and digit module - NumberOptions | currencyDisplay | Added | - | + | Time, date, and digit module - NumberOptions | currencySign | Added | - | + | Time, date, and digit module - NumberOptions | localeMatcher | Added | - | + | Time, date, and digit module - NumberOptions | notation | Added | - | + | Time, date, and digit module - NumberOptions | numberingSystem | Added | - | + | Time, date, and digit module - NumberOptions | signDisplay | Added | - | + | Time, date, and digit module - NumberOptions | style | Added | - | + | Time, date, and digit module - NumberOptions | unit | Added | - | + | Time, date, and digit module - NumberOptions | unitDisplay | Added | - | + | Time, date, and digit module - NumberOptions | useGrouping | Added | - | + | Time, date, and digit module - NumberOptions | minimumIntegerDigits | Added | - | + | Time, date, and digit module - NumberOptions | minimumFractionDigits | Added | - | + | Time, date, and digit module - NumberOptions | maximumFractionDigits | Added | - | + | Time, date, and digit module - NumberOptions | minimumSignificantDigits | Added | - | + | Time, date, and digit module - NumberOptions | maximumSignificantDigits | Added | - | +|File storage - system.file|mkdir|Added|-| +|File storage - system.file|rmdir|Added|-| +|File storage - system.file|get|Added|-| +|File storage - system.file|list|Added|-| +|File storage - system.file|copy|Added|-| +|File storage - system.file|move|Added|-| +|File storage - system.file|delete|Added|-| +|File storage - system.file|access|Added|-| +|File storage - system.file|writeText|Added|-| +|File storage - system.file|writeArrayBuffer|Added|-| +|File storage - system.file|readText|Added|-| +|File storage - system.file|readArrayBuffer|Added|-| +|File storage - fileio|Dir.readSync|Added|-| +|File storage - fileio|Dir.closeSync|Added|-| +|File storage - fileio|dirent.name|Added|-| +|File storage - fileio|dirent.isBlockDevice()|Added|-| +|File storage - fileio|dirent.isCharacterDevice()|Added|-| +|File storage - fileio|dirent.isDirectory()|Added|-| +|File storage - fileio|dirent.isFIFO()|Added|-| +|File storage - fileio|dirent.isFile()|Added|-| +|File storage - fileio|dirent.isSocket()|Added|-| +|File storage - fileio|dirent.isSymbolicLink()|Added|-| +|File storage - fileio|stat.dev|Added|-| +|File storage - fileio|stat.ino|Added|-| +|File storage - fileio|stat.mode|Added|-| +|File storage - fileio|stat.nlink|Added|-| +|File storage - fileio|stat.uid|Added|-| +|File storage - fileio|stat.gid|Added|-| +|File storage - fileio|stat.rdev|Added|-| +|File storage - fileio|stat.size|Added|-| +|File storage - fileio|stat.blocks|Added|-| +|File storage - fileio|stat.atime|Added|-| +|File storage - fileio|stat.mtime|Added|-| +|File storage - fileio|stat.ctime|Added|-| +|File storage - fileio|stat.isBlockDevice()|Added|-| +|File storage - fileio|stat.isCharacterDevice()|Added|-| +|File storage - fileio|stat.isDirectory()|Added|-| +|File storage - fileio|stat.isFIFO()|Added|-| +|File storage - fileio|stat.isFile()|Added|-| +|File storage - fileio|stat.isSocket()|Added|-| +|File storage - fileio|stat.isSymbolicLink()|Added|-| +|File storage - fileio|Stream.flushSync()|Added|-| +|File storage - fileio|Stream.writeSync()|Added|-| +|File storage - fileio|Stream.readSync()|Added|-| +|File storage - fileio|Stream.closeSync()|Added|-| +|File storage - fileio|fileio.accessSync()|Added|-| +|File storage - fileio|fileio.chmodSync()|Added|-| +|File storage - fileio|fileio.chownSync()|Added|-| +|File storage - fileio|fileio.closeSync()|Added|-| +|File storage - fileio|fileio.copyFileSync()|Added|-| +|File storage - fileio|fileio.createStreamSync()|Added|-| +|File storage - fileio|fileio.fchmodSync()|Added|-| +|File storage - fileio|fileio.fchownSync()|Added|-| +|File storage - fileio|fileio.fdopenStreamSync()|Added|-| +|File storage - fileio|fileio.fstatSync()|Added|-| +|File storage - fileio|fileio.fsyncSync()|Added|-| +|File storage - fileio|fileio.ftruncateSync()|Added|-| +|File storage - fileio|fileio.mkdirSync()|Added|-| +|File storage - fileio|fileio.openSync()|Added|-| +|File storage - fileio|fileio.opendirSync()|Added|-| +|File storage - fileio|fileio.readSync()|Added|-| +|File storage - fileio|fileio.renameSync()|Added|-| +|File storage - fileio|fileio.rmdirSync()|Added|-| +|File storage - fileio|fileio.statSync()|Added|-| +|File storage - fileio|fileio.truncateSync()|Added|-| +|File storage - fileio|fileio.unlinkSync()|Added|-| +|File storage - fileio|fileio.writeSync()|Added|-| +|Device management - DeviceManager|DeviceInfo|Added|-| +|Device management - DeviceManager|DeviceType|Added|-| +|Device management - DeviceManager|DeviceStateChangeAction|Added|-| +|Device management - DeviceManager|SubscribeInfo|Added|-| +|Device management - DeviceManager|DiscoverMode|Added|-| +|Device management - DeviceManager|ExchangeMedium|Added|-| +|Device management - DeviceManager|ExchangeFreq|Added|-| +|Device management - DeviceManager|SubscribeCap|Added|-| +|Device management - DeviceManager|createDeviceManager(bundleName: string, callback: AsyncCallback): void|Added|-| +|Device management - DeviceManager|release(): void|Added|-| +|Device management - DeviceManager|getTrustedDeviceListSync(): Array|Added|-| +|Device management - DeviceManager|startDeviceDiscovery(subscribeInfo: SubscribeInfo): void|Added|-| +|Device management - DeviceManager|stopDeviceDiscovery(subscribeId: number): void|Added|-| +|Device management - DeviceManager|authenticateDevice(deviceInfo: DeviceInfo): void|Added|-| +|Device management - DeviceManager|on(type: 'deviceStateChange', callback: Callback<{ action: DeviceStateChangeAction, device: DeviceInfo }>): void|Added|-| +|Device management - DeviceManager|off(type: 'deviceStateChange', callback?: Callback<{ action: DeviceStateChangeAction, device: DeviceInfo }>): void|Added|-| +|Device management - DeviceManager|on(type: 'deviceFound', callback: Callback<{ subscribeId: number, device: DeviceInfo }>): void|Added|-| +|Device management - DeviceManager|off(type: 'deviceFound', callback?: Callback<{ subscribeId: number, device: DeviceInfo }>): void|Added|-| +|Device management - DeviceManager|on(type: 'discoverFail', callback: Callback<{ subscribeId: number, reason: number }>): void|Added|-| +|Device management - DeviceManager|off(type: 'discoverFail', callback?: Callback<{ subscribeId: number, reason: number }>): void|Added|-| +|Device management - DeviceManager|on(type: 'authResult', callback: Callback<{ deviceId: string, status: number, reason: number }>): void|Added|-| +|Device management - DeviceManager|off(type: 'authResult', callback?: Callback<{ deviceId: string, status: number, reason: number }>): void|Added|-| +|Device management - DeviceManager|on(type: 'serviceDie', callback: () => void): void|Added|-| +|Device management - DeviceManager|off(type: 'serviceDie', callback?: () => void): void|Added|-| +|Playback and recording|createAudioPlayer(): AudioPlayer|Added|-| +|Playback and recording|AudioState|Added|-| +|Playback and recording|play(): void|Added|-| +|Playback and recording|pause(): void|Added|-| +|Playback and recording|stop(): void|Added|-| +|Playback and recording|seek(timeMs: number): void|Added|-| +|Playback and recording|setVolume(vol: number): void|Added|-| +|Playback and recording|reset(): void|Added|-| +|Playback and recording|release(): void|Added|-| +|Playback and recording|src: string|Added|-| +|Playback and recording|loop: boolean|Added|-| +|Playback and recording|readonly currentTime: number|Added|-| +|Playback and recording|readonly duration: number|Added|-| +|Playback and recording|readonly state: AudioState|Added|-| +|Playback and recording|on(type: 'play' / 'pause' / 'stop' / 'reset' / 'dataLoad' / 'finish' / 'volumeChange', callback: () => void): void|Added|-| +|Playback and recording|on(type: 'timeUpdate', callback: Callback): void|Added|-| +|Playback and recording|on(type: 'error', callback: ErrorCallback): void|Added|-| +|Audio management|getAudioManager(): AudioManager|Added|-| +|Audio management|AudioVolumeType|Added|-| +|Audio management|MEDIA|Added|-| +|Audio management|RINGTONE|Added|-| +|Audio management|DeviceFlag|Added|-| +|Audio management|OUTPUT_DEVICES_FLAG|Added|-| +|Audio management|INPUT_DEVICES_FLAG |Added|-| +|Audio management|ALL_DEVICES_FLAG |Added|-| +|Audio management|DeviceRole |Added|-| +|Audio management|INPUT_DEVICE |Added|-| +|Audio management|OUTPUT_DEVICE |Added|-| +|Audio management|DeviceType |Added|-| +|Audio management|INVALID |Added|-| +|Audio management|SPEAKER |Added|-| +|Audio management|WIRED_HEADSET |Added|-| +|Audio management|BLUETOOTH_SCO |Added|-| +|Audio management|BLUETOOTH_A2DP |Added|-| +|Audio management|MIC|Added|-| +|Audio management|AudioRingMode |Added|-| +|Audio management|RINGER_MODE_NORMAL |Added|-| +|Audio management|RINGER_MODE_SILENT|Added|-| +|Audio management|RINGER_MODE_VIBRATE |Added|-| +|Audio management|setVolume(audioType: AudioVolumeType, volume: number,callback: AsyncCallback): void|Added|-| +|Audio management|setVolume(audioType: AudioVolumeType, volume: number): Promise|Added|-| +|Audio management|getVolume(audioType: AudioVolumeType, callback: AsyncCallback): void|Added|-| +|Audio management|getVolume(audioType: AudioVolumeType): Promise|Added|-| +|Audio management|getMinVolume(audioType: AudioVolumeType, callback: AsyncCallback): void|Added|-| +|Audio management|getMinVolume(audioType: AudioVolumeType): Promise|Added|-| +|Audio management|getMaxVolume(audioType: AudioVolumeType, callback: AsyncCallback): void|Added|-| +|Audio management|getMaxVolume(audioType: AudioVolumeType): Promise|Added|-| +|Audio management|getDevices(deviceFlag: DeviceFlag, callback: AsyncCallback): void|Added|-| +|Audio management|getDevices(deviceFlag: DeviceFlag): Promise|Added|-| +|Audio management|getRingerMode(callback: AsyncCallback): void|Added|-| +|Audio management|getRingerMode(): Promise|Added|-| +|Audio management|setRingerMode(mode: AudioRingMode, callback: AsyncCallback): void|Added|-| +|Audio management|setRingerMode(mode: AudioRingMode): Promise|Added|-| +|Audio management|isMute(volumeType: AudioVolumeType, callback: AsyncCallback): void|Added|-| +|Audio management|isMute(volumeType: AudioVolumeType): Promise|Added|-| +|Audio management|isActive(volumeType: AudioVolumeType, callback: AsyncCallback): void|Added|-| +|Audio management|isActive(volumeType: AudioVolumeType): Promise|Added|-| +|Audio management|isMicrophoneMute(callback: AsyncCallback): void|Added|-| +|Audio management|isMicrophoneMute(): Promise|Added|-| +|Audio management|mute(volumeType: AudioVolumeType, mute: boolean, callback: AsyncCallback) : void|Added|-| +|Audio management|mute(volumeType: AudioVolumeType, mute: boolean): Promise|Added|-| +|Audio management|setMicrophoneMute(mute: boolean, callback: AsyncCallback): void|Added|-| +|Audio management|setMicrophoneMute(mute: boolean): Promise|Added|-| +|Audio management|isDeviceActive(deviceType: DeviceType, callback: AsyncCallback): void|Added|-| +|Audio management|isDeviceActive(deviceType: DeviceType): Promise|Added|-| +|Audio management|setDeviceActive(deviceType: DeviceType, active: boolean, callback: AsyncCallback): void|Added|-| +|Audio management|setDeviceActive(deviceType: DeviceType, active: boolean): Promise|Added|-| +|Audio management|getAudioParameter(key: string, callback: AsyncCallback): void|Added|-| +|Audio management|getAudioParameter(key: string): Promise|Added|-| +|Audio management|setAudioParameter(key: string, value: string, callback: AsyncCallback): void|Added|-| +|Audio management|setAudioParameter(key: string, value: string): Promise|Added|-| +|Audio management|AudioDeviceDescriptor|Added|-| +|Audio management|readonly deviceRole: DeviceRole|Added|-| +|Audio management|readonly deviceType: DeviceType|Added|-| +|Audio management|AudioDeviceDescriptors |Added|-| diff --git a/en/release-notes/api-change/v2.2-beta2/native-apidiff-v2.2-beta2.md b/en/release-notes/api-change/v2.2-beta2/native-apidiff-v2.2-beta2.md new file mode 100644 index 0000000000000000000000000000000000000000..67c1604f9da3a96ee0cb533df45da6b735034490 --- /dev/null +++ b/en/release-notes/api-change/v2.2-beta2/native-apidiff-v2.2-beta2.md @@ -0,0 +1,19 @@ +# Native API Differences +This document describes the changes of APIs in OpenHarmony 2.2 Beta2 over OpenHarmony 2.0 Canary. +## Mini System API Changes + +| Module | API | Change Type | Change Type | +| -------- | -------- | -------- | -------- | +| global_i18n_lite | static LocaleInfo LocaleInfo ::ForLanguageTag(const char *languageTag, I18nStatus &status); | Added | API added. | +| global_i18n_lite | const char LocaleInfo ::*GetExtension(const char *key); | Added | API added. | +| global_i18n_lite | WeekInfo::WeekInfo(const LocaleInfo &localeInfo, I18nStatus &status); | Added | API added. | +| global_i18n_lite | uint8_t WeekInfo::GetFirstDayOfWeek(); | Added | API added. | +| global_i18n_lite | uint8_t WeekInfo::GetMinimalDaysInFirstWeek(); | Added | API added. | +| global_i18n_lite | uint8_t WeekInfo::GetFirstDayOfWeekend(); | Added | API added. | +| global_i18n_lite | uint8_t WeekInfo::GetLastDayOfWeekend(); | Added | API added. | +| global_i18n_lite | int PluralFormat::GetPluralRuleIndex(double number, I18nStatus status); | Added | API added. | +| powermgr_powermgr_lite | const RunningLock *CreateRunningLock(const char *name, RunningLockType type, RunningLockFlag flag); | Added | API added. | +| powermgr_powermgr_lite | void DestroyRunningLock(const RunningLock *lock); | Added | API added. | +| powermgr_powermgr_lite | BOOL AcquireRunningLock(const RunningLock *lock); | Added | API added. | +| powermgr_powermgr_lite | BOOL ReleaseRunningLock(const RunningLock *lock); | Added | API added. | +| powermgr_powermgr_lite | BOOL IsRunningLockHolding(const RunningLock *lock); | Added | API added. |