diff --git a/en/Legal-Notices.md b/en/Legal-Notices.md
new file mode 100644
index 0000000000000000000000000000000000000000..80d301770e502de109fbcf861fe456168cd23ab1
--- /dev/null
+++ b/en/Legal-Notices.md
@@ -0,0 +1,21 @@
+# Legal Notices
+
+**Copyright (c) 2020-2022 OpenAtom OpenHarmony. All rights reserved.**
+
+## Copyright
+
+All copyrights of the OpenHarmony documents are reserved by OpenAtom OpenHarmony.
+
+The OpenHarmony documents are licensed under Creative Commons Attribution 4.0 International (CC BY 4.0). For easier understanding, you can visit [Creative Commons](https://creativecommons.org/licenses/by/4.0/) to get a human-readable summary of the license. For the complete content, see [Creative Commons Attribution 4.0 International Public License](https://creativecommons.org/licenses/by/4.0/legalcode).
+
+## Trademarks and Permissions
+
+No content provided in the OpenHarmony documentation shall be deemed as a grant of the approval or right to use any trademark, name, or logo of the OpenAtom Foundation and OpenAtom OpenHarmony. No third parties shall use any of the aforementioned trademarks, names, or logos in any way without explicit prior written permission of the OpenAtom Foundation.
+
+## Disclaimer
+
+The information in the OpenHarmony documents is subject to change without notice.
+
+The OpenHarmony documents are provided without any express or implied warranty. In any case, the OpenAtom Foundation or the copyright owner is not liable for any direct or indirect loss arising from the use of the OpenHarmony documents, regardless of the cause or legal theory, even if the OpenHarmony documents have stated that there is a possibility of such loss.
+
+
\ No newline at end of file
diff --git a/en/OpenHarmony-Overview.md b/en/OpenHarmony-Overview.md
index 1331ac52206cf1980ce59a7def62bfd32c27e406..75dc8b66607121be43c3bcfa13398ecee5b76401 100644
--- a/en/OpenHarmony-Overview.md
+++ b/en/OpenHarmony-Overview.md
@@ -150,7 +150,7 @@ Currently, the OpenHarmony community supports 17 types of development boards, wh
| System Type| Board Model| Chip Model|
Function Description and Use Case
| Application Scenario| Code Repository |
| -------- | -------- | -------- | -------- | -------- | -------- |
-| Standard system| Runhe HH-SCDAYU200| RK3568 | Function description:
Bolstered by the Rockchip RK3568, the HH-SCDAYU200 development board integrates the dual-core GPU and efficient NPU. Its quad-core 64-bit Cortex-A55 processor uses the advanced 22 nm fabrication process and is clocked at up to 2.0 GHz. The board is packed with Bluetooth, Wi-Fi, audio, video, and camera features, with a wide range of expansion ports to accommodate various video input and outputs. It comes with dual GE auto-sensing RJ45 ports, so it can be used in multi-connectivity products, such as network video recorders (NVRs) and industrial gateways.
Use case:
[DAYU200 Use Case](device-dev/porting/porting-dayu200-on_standard-demo.md)
| Entertainment, easy travel, and smart home, such as kitchen hoods, ovens, and treadmills.| [device_soc_rockchip](https://gitee.com/openharmony/device_soc_rockchip)
[device_board_hihope](https://gitee.com/openharmony/device_board_hihope)
[vendor_hihope](https://gitee.com/openharmony/vendor_hihope)
|
+| Standard system| Runhe HH-SCDAYU200| RK3568 | Function description:
Bolstered by the Rockchip RK3568, the HH-SCDAYU200 development board integrates the dual-core GPU and efficient NPU. Its quad-core 64-bit Cortex-A55 processor uses the advanced 22 nm fabrication process and is clocked at up to 2.0 GHz. The board is packed with Bluetooth, Wi-Fi, audio, video, and camera features, with a wide range of expansion ports to accommodate various video input and outputs. It comes with dual GE auto-sensing RJ45 ports, so it can be used in multi-connectivity products, such as network video recorders (NVRs) and industrial gateways.
| Entertainment, easy travel, and smart home, such as kitchen hoods, ovens, and treadmills.| [device_soc_rockchip](https://gitee.com/openharmony/device_soc_rockchip)
[device_board_hihope](https://gitee.com/openharmony/device_board_hihope)
[vendor_hihope](https://gitee.com/openharmony/vendor_hihope)
|
| Small system| Hispark_Taurus | Hi3516DV300 | Function Description:
Hi3516D V300 is the next-generation system on chip (SoC) for smart HD IP cameras. It integrates the next-generation image signal processor (ISP), H.265 video compression encoder, and high-performance NNIE engine, and delivers high performance in terms of low bit rate, high image quality, intelligent processing and analysis, and low power consumption.
| Smart device with screens, such as refrigerators with screens and head units.| [device_soc_hisilicon](https://gitee.com/openharmony/device_soc_hisilicon)
[device_board_hisilicon](https://gitee.com/openharmony/device_board_hisilicon)
[vendor_hisilicon](https://gitee.com/openharmony/vendor_hisilicon)
|
| Mini system| Multi-modal V200Z-R | BES2600 | Function description:
The multi-modal V200Z-R development board is a high-performance, multi-functional, and cost-effective AIoT SoC powered by the BES2600WM chip of Bestechnic. It integrates a quad-core ARM processor with a frequency of up to 1 GHz as well as dual-mode Wi-Fi and dual-mode Bluetooth. The board supports the 802.11 a/b/g/n/ and BT/BLE 5.2 standards. It is able to accommodate RAM of up to 42 MB and flash memory of up to 32 MB, and supports the MIPI display serial interface (DSI) and camera serial interface (CSI). It is applicable to various AIoT multi-modal VUI and GUI interaction scenarios.
Use case:
[Multi-modal V200Z-R Use Case](device-dev/porting/porting-bes2600w-on-minisystem-display-demo.md)
| Smart hardware, and smart devices with screens, such as speakers and watches.| [device_soc_bestechnic](https://gitee.com/openharmony/device_soc_bestechnic)
[device_board_fnlink](https://gitee.com/openharmony/device_board_fnlink)
[vendor_bestechnic](https://gitee.com/openharmony/vendor_bestechnic)
|
diff --git a/en/application-dev/IDL/idl-guidelines.md b/en/application-dev/IDL/idl-guidelines.md
index 661b2532c49d36c79855c3e0530326ef590c7cd2..5b3a5d7990d4dfe55ddef2ad77ef7dab84033a2e 100644
--- a/en/application-dev/IDL/idl-guidelines.md
+++ b/en/application-dev/IDL/idl-guidelines.md
@@ -7,7 +7,7 @@ To ensure successful communications between the client and server, interfaces re

-IDL provides the following functions:
+**IDL provides the following functions:**
- Declares interfaces provided by system services for external systems, and based on the interface declaration, generates C, C++, JS, or TS code for inter-process communication (IPC) or remote procedure call (RPC) proxies and stubs during compilation.
@@ -17,7 +17,7 @@ IDL provides the following functions:

-IDL has the following advantages:
+**IDL has the following advantages:**
- Services are defined in the form of interfaces in IDL. Therefore, you do not need to focus on implementation details.
@@ -433,7 +433,7 @@ export default {
console.log('ServiceAbility want:' + JSON.stringify(want));
console.log('ServiceAbility want name:' + want.bundleName)
} catch(err) {
- console.log("ServiceAbility error:" + err)
+ console.log('ServiceAbility error:' + err)
}
console.info('ServiceAbility onConnect end');
return new IdlTestImp('connect');
@@ -455,13 +455,13 @@ import featureAbility from '@ohos.ability.featureAbility';
function callbackTestIntTransaction(result: number, ret: number): void {
if (result == 0 && ret == 124) {
- console.log("case 1 success ");
+ console.log('case 1 success');
}
}
function callbackTestStringTransaction(result: number): void {
if (result == 0) {
- console.log("case 2 success ");
+ console.log('case 2 success');
}
}
@@ -472,17 +472,17 @@ var onAbilityConnectDone = {
testProxy.testStringTransaction('hello', callbackTestStringTransaction);
},
onDisconnect:function (elementName) {
- console.log("onDisconnectService onDisconnect");
+ console.log('onDisconnectService onDisconnect');
},
onFailed:function (code) {
- console.log("onDisconnectService onFailed");
+ console.log('onDisconnectService onFailed');
}
};
function connectAbility: void {
let want = {
- "bundleName":"com.example.myapplicationidl",
- "abilityName": "com.example.myapplicationidl.ServiceAbility"
+ bundleName: 'com.example.myapplicationidl',
+ abilityName: 'com.example.myapplicationidl.ServiceAbility'
};
let connectionId = -1;
connectionId = featureAbility.connectAbility(want, onAbilityConnectDone);
@@ -495,7 +495,7 @@ function connectAbility: void {
You can send a class from one process to another through IPC interfaces. However, you must ensure that the peer can use the code of this class and this class supports the **marshalling** and **unmarshalling** methods. OpenHarmony uses **marshalling** and **unmarshalling** to serialize and deserialize objects into objects that can be identified by each process.
-To create a class that supports the sequenceable type, perform the following operations:
+**To create a class that supports the sequenceable type, perform the following operations:**
1. Implement the **marshalling** method, which obtains the current state of the object and serializes the object into a **Parcel** object.
2. Implement the **unmarshalling** method, which deserializes the object from a **Parcel** object.
@@ -595,7 +595,7 @@ export default class IdlTestServiceProxy implements IIdlTestService {
let _reply = new rpc.MessageParcel();
_data.writeInt(data);
this.proxy.sendRequest(IdlTestServiceProxy.COMMAND_TEST_INT_TRANSACTION, _data, _reply, _option).then(function(result) {
- if (result.errCode === 0) {
+ if (result.errCode == 0) {
let _errCode = result.reply.readInt();
if (_errCode != 0) {
let _returnValue = undefined;
@@ -605,7 +605,7 @@ export default class IdlTestServiceProxy implements IIdlTestService {
let _returnValue = result.reply.readInt();
callback(_errCode, _returnValue);
} else {
- console.log("sendRequest failed, errCode: " + result.errCode);
+ console.log('sendRequest failed, errCode: ' + result.errCode);
}
})
}
@@ -617,11 +617,11 @@ export default class IdlTestServiceProxy implements IIdlTestService {
let _reply = new rpc.MessageParcel();
_data.writeString(data);
this.proxy.sendRequest(IdlTestServiceProxy.COMMAND_TEST_STRING_TRANSACTION, _data, _reply, _option).then(function(result) {
- if (result.errCode === 0) {
+ if (result.errCode == 0) {
let _errCode = result.reply.readInt();
callback(_errCode);
} else {
- console.log("sendRequest failed, errCode: " + result.errCode);
+ console.log('sendRequest failed, errCode: ' + result.errCode);
}
})
}
@@ -644,12 +644,12 @@ import nativeMgr from 'nativeManager';
function testIntTransactionCallback(errCode: number, returnValue: number)
{
- console.log("errCode: " + errCode + " returnValue: " + returnValue);
+ console.log('errCode: ' + errCode + ' returnValue: ' + returnValue);
}
function testStringTransactionCallback(errCode: number)
{
- console.log("errCode: " + errCode);
+ console.log('errCode: ' + errCode);
}
function jsProxyTriggerCppStub()
@@ -660,6 +660,6 @@ function jsProxyTriggerCppStub()
tsProxy.testIntTransaction(10, testIntTransactionCallback);
// Call testStringTransaction.
- tsProxy.testStringTransaction("test", testIntTransactionCallback);
+ tsProxy.testStringTransaction('test', testIntTransactionCallback);
}
```
diff --git a/en/application-dev/ability/continuationmanager.md b/en/application-dev/ability/continuationmanager.md
index a1f5a66478cd53aeabe03ed9be21e08596cb2b6b..20c272e75a16c2bcf14d567c1cbc7afa28a3a69a 100644
--- a/en/application-dev/ability/continuationmanager.md
+++ b/en/application-dev/ability/continuationmanager.md
@@ -14,20 +14,20 @@ As the entry of the ability continuation capability, **continuationManager** is
## Available APIs
| API | Description|
| ---------------------------------------------------------------------------------------------- | ----------- |
-| register(callback: AsyncCallback\): void | Registers the continuation management service and obtains a token. This API does not involve any filter parameters and uses an asynchronous callback to return the result.|
-| register(options: ContinuationExtraParams, callback: AsyncCallback\): void | Registers the continuation management service and obtains a token. This API uses an asynchronous callback to return the result.|
-| register(options?: ContinuationExtraParams): Promise\ | Registers the continuation management service and obtains a token. This API uses a promise to return the result.|
-| on(type: "deviceConnect", token: number, callback: Callback\>): void | Subscribes to device connection events. This API uses an asynchronous callback to return the result.|
-| on(type: "deviceDisconnect", token: number, callback: Callback\>): void | Subscribes to device disconnection events. This API uses an asynchronous callback to return the result.|
-| off(type: "deviceConnect", token: number): void | Unsubscribes from device connection events.|
-| off(type: "deviceDisconnect", token: number): void | Unsubscribes from device disconnection events.|
-| startDeviceManager(token: number, callback: AsyncCallback\): void | Starts the device selection module to show the list of available devices. This API does not involve any filter parameters and uses an asynchronous callback to return the result.|
-| startDeviceManager(token: number, options: ContinuationExtraParams, callback: AsyncCallback\): void | Starts the device selection module to show the list of available devices. This API uses an asynchronous callback to return the result.|
-| startDeviceManager(token: number, options?: ContinuationExtraParams): Promise\ | Starts the device selection module to show the list of available devices. This API uses a promise to return the result.|
-| updateConnectStatus(token: number, deviceId: string, status: DeviceConnectState, callback: AsyncCallback\): void | Instructs the device selection module to update the device connection state. This API uses an asynchronous callback to return the result.|
-| updateConnectStatus(token: number, deviceId: string, status: DeviceConnectState): Promise\ | Instructs the device selection module to update the device connection state. This API uses a promise to return the result.|
-| unregister(token: number, callback: AsyncCallback\): void | Deregisters the continuation management service. This API uses an asynchronous callback to return the result.|
-| unregister(token: number): Promise\ | Deregisters the continuation management service. This API uses a promise to return the result.|
+| registerContinuation(callback: AsyncCallback\): void | Registers the continuation management service and obtains a token. This API does not involve any filter parameters and uses an asynchronous callback to return the result.|
+| registerContinuation(options: ContinuationExtraParams, callback: AsyncCallback\): void | Registers the continuation management service and obtains a token. This API uses an asynchronous callback to return the result.|
+| registerContinuation(options?: ContinuationExtraParams): Promise\ | Registers the continuation management service and obtains a token. This API uses a promise to return the result.|
+| on(type: "deviceSelected", token: number, callback: Callback\>): void | Subscribes to device connection events. This API uses an asynchronous callback to return the result.|
+| on(type: "deviceUnselected", token: number, callback: Callback\>): void | Subscribes to device disconnection events. This API uses an asynchronous callback to return the result.|
+| off(type: "deviceSelected", token: number): void | Unsubscribes from device connection events.|
+| off(type: "deviceUnselected", token: number): void | Unsubscribes from device disconnection events.|
+| startContinuationDeviceManager(token: number, callback: AsyncCallback\): void | Starts the device selection module to show the list of available devices. This API does not involve any filter parameters and uses an asynchronous callback to return the result.|
+| startContinuationDeviceManager(token: number, options: ContinuationExtraParams, callback: AsyncCallback\): void | Starts the device selection module to show the list of available devices. This API uses an asynchronous callback to return the result.|
+| startContinuationDeviceManager(token: number, options?: ContinuationExtraParams): Promise\ | Starts the device selection module to show the list of available devices. This API uses a promise to return the result.|
+| updateContinuationState(token: number, deviceId: string, status: DeviceConnectState, callback: AsyncCallback\): void | Instructs the device selection module to update the device connection state. This API uses an asynchronous callback to return the result.|
+| updateContinuationState(token: number, deviceId: string, status: DeviceConnectState): Promise\ | Instructs the device selection module to update the device connection state. This API uses a promise to return the result.|
+| unregisterContinuation(token: number, callback: AsyncCallback\): void | Deregisters the continuation management service. This API uses an asynchronous callback to return the result.|
+| unregisterContinuation(token: number): Promise\ | Deregisters the continuation management service. This API uses a promise to return the result.|
## How to Develop
1. Import the **continuationManager** module.
@@ -36,7 +36,7 @@ As the entry of the ability continuation capability, **continuationManager** is
import continuationManager from '@ohos.continuation.continuationManager';
```
-2. Apply for permissions required for cross-device continuation or collaboration operations.
+2. Apply for the **DISTRIBUTED_DATASYNC** permission.
The permission application operation varies according to the ability model in use. In the FA mode, add the required permission in the `config.json` file, as follows:
@@ -57,6 +57,7 @@ As the entry of the ability continuation capability, **continuationManager** is
```ts
import abilityAccessCtrl from "@ohos.abilityAccessCtrl";
import bundle from '@ohos.bundle';
+ import featureAbility from '@ohos.ability.featureAbility';
async function requestPermission() {
let permissions: Array = [
@@ -124,7 +125,8 @@ As the entry of the ability continuation capability, **continuationManager** is
// If the permission is not granted, call requestPermissionsFromUser to apply for the permission.
if (needGrantPermission) {
try {
- await globalThis.abilityContext.requestPermissionsFromUser(permissions);
+ // globalThis.context is Ability.context, which must be assigned a value in the MainAbility.ts file in advance.
+ await globalThis.context.requestPermissionsFromUser(permissions);
} catch (err) {
console.error('app permission request permissions error' + JSON.stringify(err));
}
@@ -140,13 +142,16 @@ As the entry of the ability continuation capability, **continuationManager** is
```ts
let token: number = -1; // Used to save the token returned after the registration. The token will be used when listening for device connection/disconnection events, starting the device selection module, and updating the device connection state.
-
- continuationManager.register().then((data) => {
- console.info('register finished, ' + JSON.stringify(data));
- token = data; // Obtain a token and assign a value to the token variable.
- }).catch((err) => {
- console.error('register failed, cause: ' + JSON.stringify(err));
- });
+ try {
+ continuationManager.registerContinuation().then((data) => {
+ console.info('registerContinuation finished, ' + JSON.stringify(data));
+ token = data; // Obtain a token and assign a value to the token variable.
+ }).catch((err) => {
+ console.error('registerContinuation failed, cause: ' + JSON.stringify(err));
+ });
+ } catch (err) {
+ console.error('registerContinuation failed, cause: ' + JSON.stringify(err));
+ }
```
4. Listen for the device connection/disconnection state.
@@ -156,28 +161,31 @@ As the entry of the ability continuation capability, **continuationManager** is
```ts
let remoteDeviceId: string = ""; // Used to save the information about the remote device selected by the user, which will be used for cross-device continuation or collaboration.
- // The token parameter is the token obtained during the registration.
- continuationManager.on("deviceConnect", token, (continuationResults) => {
- console.info('registerDeviceConnectCallback len: ' + continuationResults.length);
- if (continuationResults.length <= 0) {
- console.info('no selected device');
- return;
- }
- remoteDeviceId = continuationResults[0].id; // Assign the deviceId of the first selected remote device to the remoteDeviceId variable.
-
- // Pass the remoteDeviceId parameter to want.
- let want = {
- deviceId: remoteDeviceId,
- bundleName: 'ohos.samples.continuationmanager',
- abilityName: 'MainAbility'
- };
- // To initiate multi-device collaboration, you must obtain the ohos.permission.DISTRIBUTED_DATASYNC permission.
- globalThis.abilityContext.startAbility(want).then((data) => {
- console.info('StartRemoteAbility finished, ' + JSON.stringify(data));
- }).catch((err) => {
- console.error('StartRemoteAbility failed, cause: ' + JSON.stringify(err));
+ try {
+ // The token parameter is the token obtained during the registration.
+ continuationManager.on("deviceSelected", token, (continuationResults) => {
+ console.info('registerDeviceSelectedCallback len: ' + continuationResults.length);
+ if (continuationResults.length <= 0) {
+ console.info('no selected device');
+ return;
+ }
+ remoteDeviceId = continuationResults[0].id; // Assign the deviceId of the first selected remote device to the remoteDeviceId variable.
+
+ // Pass the remoteDeviceId parameter to want.
+ let want = {
+ deviceId: remoteDeviceId,
+ bundleName: 'ohos.samples.continuationmanager',
+ abilityName: 'MainAbility'
+ };
+ globalThis.abilityContext.startAbility(want).then((data) => {
+ console.info('StartRemoteAbility finished, ' + JSON.stringify(data));
+ }).catch((err) => {
+ console.error('StartRemoteAbility failed, cause: ' + JSON.stringify(err));
+ });
});
- });
+ } catch (err) {
+ console.error('on failed, cause: ' + JSON.stringify(err));
+ }
```
The preceding multi-device collaboration operation is performed across devices in the stage model. For details about this operation in the FA model, see [Page Ability Development](https://gitee.com/openharmony/docs/blob/master/en/application-dev/ability/fa-pageability.md).
@@ -189,35 +197,43 @@ As the entry of the ability continuation capability, **continuationManager** is
let deviceConnectStatus: continuationManager.DeviceConnectState = continuationManager.DeviceConnectState.CONNECTED;
// The token parameter is the token obtained during the registration, and the remoteDeviceId parameter is the remoteDeviceId obtained.
- continuationManager.updateConnectStatus(token, remoteDeviceId, deviceConnectStatus).then((data) => {
- console.info('updateConnectStatus finished, ' + JSON.stringify(data));
- }).catch((err) => {
- console.error('updateConnectStatus failed, cause: ' + JSON.stringify(err));
- });
+ try {
+ continuationManager.updateContinuationState(token, remoteDeviceId, deviceConnectStatus).then((data) => {
+ console.info('updateContinuationState finished, ' + JSON.stringify(data));
+ }).catch((err) => {
+ console.error('updateContinuationState failed, cause: ' + JSON.stringify(err));
+ });
+ } catch (err) {
+ console.error('updateContinuationState failed, cause: ' + JSON.stringify(err));
+ }
```
Listen for the device disconnection state so that the user can stop cross-device continuation or collaboration in time. The sample code is as follows:
```ts
- // The token parameter is the token obtained during the registration.
- continuationManager.on("deviceDisconnect", token, (deviceIds) => {
- console.info('onDeviceDisconnect len: ' + deviceIds.length);
- if (deviceIds.length <= 0) {
- console.info('no unselected device');
- return;
- }
+ try {
+ // The token parameter is the token obtained during the registration.
+ continuationManager.on("deviceUnselected", token, (continuationResults) => {
+ console.info('onDeviceUnselected len: ' + continuationResults.length);
+ if (continuationResults.length <= 0) {
+ console.info('no unselected device');
+ return;
+ }
- // Update the device connection state.
- let unselectedDeviceId: string = deviceIds[0]; // Assign the deviceId of the first deselected remote device to the unselectedDeviceId variable.
- let deviceConnectStatus: continuationManager.DeviceConnectState = continuationManager.DeviceConnectState.DISCONNECTING; // Device disconnected.
+ // Update the device connection state.
+ let unselectedDeviceId: string = continuationResults[0].id; // Assign the deviceId of the first deselected remote device to the unselectedDeviceId variable.
+ let deviceConnectStatus: continuationManager.DeviceConnectState = continuationManager.DeviceConnectState.DISCONNECTING; // Device disconnected.
- // The token parameter is the token obtained during the registration, and the unselectedDeviceId parameter is the unselectedDeviceId obtained.
- continuationManager.updateConnectStatus(token, unselectedDeviceId, deviceConnectStatus).then((data) => {
- console.info('updateConnectStatus finished, ' + JSON.stringify(data));
- }).catch((err) => {
- console.error('updateConnectStatus failed, cause: ' + JSON.stringify(err));
+ // The token parameter is the token obtained during the registration, and the unselectedDeviceId parameter is the unselectedDeviceId obtained.
+ continuationManager.updateContinuationState(token, unselectedDeviceId, deviceConnectStatus).then((data) => {
+ console.info('updateContinuationState finished, ' + JSON.stringify(data));
+ }).catch((err) => {
+ console.error('updateContinuationState failed, cause: ' + JSON.stringify(err));
+ });
});
- });
+ } catch (err) {
+ console.error('updateContinuationState failed, cause: ' + JSON.stringify(err));
+ }
```
5. Start the device selection module to show the list of available devices on the network.
@@ -231,12 +247,16 @@ As the entry of the ability continuation capability, **continuationManager** is
continuationMode: continuationManager.ContinuationMode.COLLABORATION_SINGLE // Single-choice mode of the device selection module.
};
- // The token parameter is the token obtained during the registration.
- continuationManager.startDeviceManager(token, continuationExtraParams).then((data) => {
- console.info('startDeviceManager finished, ' + JSON.stringify(data));
- }).catch((err) => {
- console.error('startDeviceManager failed, cause: ' + JSON.stringify(err));
- });
+ try {
+ // The token parameter is the token obtained during the registration.
+ continuationManager.startContinuationDeviceManager(token, continuationExtraParams).then((data) => {
+ console.info('startContinuationDeviceManager finished, ' + JSON.stringify(data));
+ }).catch((err) => {
+ console.error('startContinuationDeviceManager failed, cause: ' + JSON.stringify(err));
+ });
+ } catch (err) {
+ console.error('startContinuationDeviceManager failed, cause: ' + JSON.stringify(err));
+ }
```
6. If you do not need to perform cross-device migration or collaboration operations, you can deregister the continuation management service, by passing the token obtained during the registration.
@@ -244,10 +264,14 @@ As the entry of the ability continuation capability, **continuationManager** is
The sample code is as follows:
```ts
- // The token parameter is the token obtained during the registration.
- continuationManager.unregister(token).then((data) => {
- console.info('unregister finished, ' + JSON.stringify(data));
- }).catch((err) => {
- console.error('unregister failed, cause: ' + JSON.stringify(err));
- });
+ try {
+ // The token parameter is the token obtained during the registration.
+ continuationManager.unregisterContinuation(token).then((data) => {
+ console.info('unregisterContinuation finished, ' + JSON.stringify(data));
+ }).catch((err) => {
+ console.error('unregisterContinuation failed, cause: ' + JSON.stringify(err));
+ });
+ } catch (err) {
+ console.error('unregisterContinuation failed, cause: ' + JSON.stringify(err));
+ }
```
diff --git a/en/application-dev/connectivity/ipc-rpc-development-guideline.md b/en/application-dev/connectivity/ipc-rpc-development-guideline.md
index 1fddf868604e564e4b6a6701f8d3a8088c4d8326..0eeef8040da8abd9710f3996f0b5f2c65ecf71e2 100644
--- a/en/application-dev/connectivity/ipc-rpc-development-guideline.md
+++ b/en/application-dev/connectivity/ipc-rpc-development-guideline.md
@@ -10,7 +10,7 @@ IPC/RPC enables a proxy and a stub that run on different processes to communicat
| Class/Interface | Function | Description |
| --------------- | -------- | ----------- |
-| IRemoteBroker | sptr AsObject() | Obtains the holder of a remote proxy object. This method must be implemented by the derived classes of **IRemoteBroker**. If you call this method on the stub, the **RemoteObject** is returned; if you call this method on the proxy, the proxy object is returned. |
+| [IRemoteBroker](../reference/apis/js-apis-rpc.md#iremotebroker) | sptr AsObject() | Obtains the holder of a remote proxy object. This method must be implemented by the derived classes of **IRemoteBroker**. If you call this method on the stub, the **RemoteObject** is returned; if you call this method on the proxy, the proxy object is returned. |
| IRemoteStub | virtual int OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) | Called to process a request from the proxy and return the result. Derived classes need to override this method. |
| IRemoteProxy | | Service proxy classes are derived from the **IRemoteProxy** class. |
@@ -25,10 +25,10 @@ IPC/RPC enables a proxy and a stub that run on different processes to communicat
```
class ITestAbility : public IRemoteBroker {
public:
- // DECLARE_INTERFACE_DESCRIPTOR is mandatory, and the input parameter is std::u16string.
- DECLARE_INTERFACE_DESCRIPTOR(u"test.ITestAbility");
- int TRANS_ID_PING_ABILITY = 1; // Define the message code.
- virtual int TestPingAbility(const std::u16string &dummy) = 0; // Define functions.
+ // DECLARE_INTERFACE_DESCRIPTOR is mandatory, and the input parameter is std::u16string.
+ DECLARE_INTERFACE_DESCRIPTOR(u"test.ITestAbility");
+ int TRANS_ID_PING_ABILITY = 1; // Define the message code.
+ virtual int TestPingAbility(const std::u16string &dummy) = 0; // Define functions.
};
```
diff --git a/en/application-dev/device/device-location-info.md b/en/application-dev/device/device-location-info.md
index 4c51f50e9c29c9df846011e80c06a46a59045794..a153f69fbfe2b71362a4b7e5808fe57c1b7a4216 100644
--- a/en/application-dev/device/device-location-info.md
+++ b/en/application-dev/device/device-location-info.md
@@ -66,25 +66,7 @@ To learn more about the APIs for obtaining device location information, see [Geo
If your application needs to access the device location information when running on the background, it must be configured to be able to run on the background and be granted the **ohos.permission.LOCATION_IN_BACKGROUND** permission. In this way, the system continues to report device location information after your application moves to the background.
- To allow your application to access device location information, declare the required permissions in the **module.json** file of your application. The sample code is as follows:
-
-
- ```
- {
- "module": {
- "reqPermissions": [
- "name": "ohos.permission.LOCATION",
- "reason": "$string:reason_description",
- "usedScene": {
- "ability": ["com.myapplication.LocationAbility"],
- "when": "inuse"
- }
- ]
- }
- }
- ```
-
- For details about these fields, see [Application Package Structure Configuration File](../quick-start/stage-structure.md).
+ You can declare the required permission in your application's configuration file. For details, see [Access Control (Permission) Development](../security/accesstoken-guidelines.md).
2. Import the **geolocation** module by which you can implement all APIs related to the basic location capabilities.
diff --git a/en/application-dev/media/audio-playback.md b/en/application-dev/media/audio-playback.md
index 5227f6cdd1b9ec89818b0d1762c99267ec7eba97..92aa1cd4fc35a4b64ad9b1044c1a7bd59f24453d 100644
--- a/en/application-dev/media/audio-playback.md
+++ b/en/application-dev/media/audio-playback.md
@@ -1,25 +1,35 @@
# Audio Playback Development
-## When to Use
+## Introduction
-You can use audio playback APIs to convert audio data into audible analog signals, play the signals using output devices, and manage playback tasks.
+You can use audio playback APIs to convert audio data into audible analog signals and play the signals using output devices. You can also manage playback tasks. For example, you can start, suspend, stop playback, release resources, set the volume, seek to a playback position, and obtain track information.
-**Figure 1** Playback status
+## Working Principles
+
+The following figures show the audio playback status changes and the interaction with external modules for audio playback.
+
+**Figure 1** Audio playback state transition

-**Note**: If the status is **Idle**, setting the **src** attribute does not change the status. In addition, after the **src** attribute is set successfully, you must call **reset()** before setting it to another value.
+**NOTE**: If the status is **Idle**, setting the **src** attribute does not change the status. In addition, after the **src** attribute is set successfully, you must call **reset()** before setting it to another value.
-**Figure 2** Layer 0 diagram of audio playback
+**Figure 2** Interaction with external modules for audio playback

+**NOTE**: When a third-party application calls the JS interface provided by the JS interface layer to implement a feature, the framework layer invokes the audio component through the media service of the native framework and outputs the audio data decoded by the software to the audio HDI of the hardware interface layer to implement audio playback.
+
## How to Develop
For details about the APIs, see [AudioPlayer in the Media API](../reference/apis/js-apis-media.md#audioplayer).
+> **NOTE**
+>
+> The method for obtaining the path in the FA model is different from that in the stage model. **pathDir** used in the sample code below is an example. You need to obtain the path based on project requirements. For details about how to obtain the path, see [Application Sandbox Path Guidelines](../reference/apis/js-apis-fileio.md#guidelines).
+
### Full-Process Scenario
The full audio playback process includes creating an instance, setting the URI, playing audio, seeking to the playback position, setting the volume, pausing playback, obtaining track information, stopping playback, resetting the player, and releasing resources.
@@ -99,8 +109,9 @@ async function audioPlayerDemo() {
setCallBack(audioPlayer); // Set the event callbacks.
// 2. Set the URI of the audio file.
let fdPath = 'fd://'
- // The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\01.mp3 /data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile" command.
- let path = '/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/01.mp3';
+ let pathDir = "/data/storage/el2/base/haps/entry/files" // The method for obtaining pathDir in the FA model is different from that in the stage model. For details, see NOTE just below How to Develop. You need to obtain pathDir based on project requirements.
+ // The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\01.mp3 /data/app/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files" command.
+ let path = pathDir + '/01.mp3'
await fileIO.open(path).then((fdNumber) => {
fdPath = fdPath + '' + fdNumber;
console.info('open fd success fd is' + fdPath);
@@ -118,6 +129,7 @@ async function audioPlayerDemo() {
```js
import media from '@ohos.multimedia.media'
import fileIO from '@ohos.fileio'
+
export class AudioDemo {
// Set the player callbacks.
setCallBack(audioPlayer) {
@@ -139,8 +151,9 @@ export class AudioDemo {
let audioPlayer = media.createAudioPlayer(); // Create an AudioPlayer instance.
this.setCallBack(audioPlayer); // Set the event callbacks.
let fdPath = 'fd://'
- // The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\01.mp3 /data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile" command.
- let path = '/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/01.mp3';
+ let pathDir = "/data/storage/el2/base/haps/entry/files" // The method for obtaining pathDir in the FA model is different from that in the stage model. For details, see NOTE just below How to Develop. You need to obtain pathDir based on project requirements.
+ // The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\01.mp3 /data/app/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files" command.
+ let path = pathDir + '/01.mp3'
await fileIO.open(path).then((fdNumber) => {
fdPath = fdPath + '' + fdNumber;
console.info('open fd success fd is' + fdPath);
@@ -159,6 +172,7 @@ export class AudioDemo {
```js
import media from '@ohos.multimedia.media'
import fileIO from '@ohos.fileio'
+
export class AudioDemo {
// Set the player callbacks.
private isNextMusic = false;
@@ -185,8 +199,9 @@ export class AudioDemo {
async nextMusic(audioPlayer) {
this.isNextMusic = true;
let nextFdPath = 'fd://'
- // The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\02.mp3 /data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile" command.
- let nextpath = '/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/02.mp3';
+ let pathDir = "/data/storage/el2/base/haps/entry/files" // The method for obtaining pathDir in the FA model is different from that in the stage model. For details, see NOTE just below How to Develop. You need to obtain pathDir based on project requirements.
+ // The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\02.mp3 /data/app/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files" command.
+ let nextpath = pathDir + '/02.mp3'
await fileIO.open(nextpath).then((fdNumber) => {
nextFdPath = nextFdPath + '' + fdNumber;
console.info('open fd success fd is' + nextFdPath);
@@ -202,8 +217,9 @@ export class AudioDemo {
let audioPlayer = media.createAudioPlayer(); // Create an AudioPlayer instance.
this.setCallBack(audioPlayer); // Set the event callbacks.
let fdPath = 'fd://'
- // The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\01.mp3 /data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile" command.
- let path = '/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/01.mp3';
+ let pathDir = "/data/storage/el2/base/haps/entry/files" // The method for obtaining pathDir in the FA model is different from that in the stage model. For details, see NOTE just below How to Develop. You need to obtain pathDir based on project requirements.
+ // The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\01.mp3 /data/app/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files" command.
+ let path = pathDir + '/01.mp3'
await fileIO.open(path).then((fdNumber) => {
fdPath = fdPath + '' + fdNumber;
console.info('open fd success fd is' + fdPath);
@@ -222,6 +238,7 @@ export class AudioDemo {
```js
import media from '@ohos.multimedia.media'
import fileIO from '@ohos.fileio'
+
export class AudioDemo {
// Set the player callbacks.
setCallBack(audioPlayer) {
@@ -239,8 +256,9 @@ export class AudioDemo {
let audioPlayer = media.createAudioPlayer(); // Create an AudioPlayer instance.
this.setCallBack(audioPlayer); // Set the event callbacks.
let fdPath = 'fd://'
- // The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\01.mp3 /data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile" command.
- let path = '/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/01.mp3';
+ let pathDir = "/data/storage/el2/base/haps/entry/files" // The method for obtaining pathDir in the FA model is different from that in the stage model. For details, see NOTE just below How to Develop. You need to obtain pathDir based on project requirements.
+ // The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\01.mp3 /data/app/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files" command.
+ let path = pathDir + '/01.mp3'
await fileIO.open(path).then((fdNumber) => {
fdPath = fdPath + '' + fdNumber;
console.info('open fd success fd is' + fdPath);
diff --git a/en/application-dev/media/audio-recorder.md b/en/application-dev/media/audio-recorder.md
index f465db2b88118b77c9a4e64307170da07c3e8918..78650a61d0a803811394e623ab0bc46155438ba9 100644
--- a/en/application-dev/media/audio-recorder.md
+++ b/en/application-dev/media/audio-recorder.md
@@ -1,8 +1,12 @@
# Audio Recording Development
-## When to Use
+## Introduction
-During audio recording, audio signals are captured, encoded, and saved to files. You can specify parameters such as the sampling rate, number of audio channels, encoding format, encapsulation format, and file path for audio recording.
+During audio recording, audio signals are captured, encoded, and saved to files. You can specify parameters such as the sampling rate, number of audio channels, encoding format, encapsulation format, and output file path for audio recording.
+
+## Working Principles
+
+The following figures show the audio recording state transition and the interaction with external modules for audio recording.
**Figure 1** Audio recording state transition
@@ -10,10 +14,16 @@ During audio recording, audio signals are captured, encoded, and saved to files.
-**Figure 2** Layer 0 diagram of audio recording
+**Figure 2** Interaction with external modules for audio recording

+**NOTE**: When a third-party recording application or recorder calls the JS interface provided by the JS interface layer to implement a feature, the framework layer invokes the audio component through the media service of the native framework to obtain the audio data captured through the audio HDI. The framework layer then encodes the audio data through software and saves the encoded and encapsulated audio data to a file to implement audio recording.
+
+## Constraints
+
+Before developing audio recording, configure the **ohos.permission.MICROPHONE** permission for your application. For details about the configuration, see [Permission Application Guide](../security/accesstoken-guidelines.md).
+
## How to Develop
For details about the APIs, see [AudioRecorder in the Media API](../reference/apis/js-apis-media.md#audiorecorder).
diff --git a/en/application-dev/media/camera.md b/en/application-dev/media/camera.md
index 06439dd049be835cdf5a96a35e2a2a42012ee6f8..25e5e573057661487895bc003c143393287b4829 100644
--- a/en/application-dev/media/camera.md
+++ b/en/application-dev/media/camera.md
@@ -2,7 +2,13 @@
## When to Use
-You can use the camera module to develop basic camera functions, including previewing, photographing, and video recording.
+With the APIs provided by the **Camera** module, you can access and operate camera devices and develop new functions. Common operations include preview, photographing, and video recording. You can also implement flash control, exposure time control, focus mode control, zooming control, and many others.
+
+Before calling camera APIs, be familiar with the following concepts:
+
+- **Static camera capabilities**: A series of parameters used to describe inherent capabilities of a camera, such as orientation and supported resolution.
+- **Physical camera**: An independent camera device. The physical camera ID is a string that uniquely identifies a physical camera.
+- **Asynchronous operation**: To prevent the UI thread from being blocked, most **Camera** calls are asynchronous. Each API provides the callback and promise functions.
## How to Develop
@@ -12,152 +18,298 @@ For details about the APIs, see [Camera Management](../reference/apis/js-apis-ca
### Full-Process Scenario
-The full process includes creating an instance, setting parameters, managing sessions, taking photos, recording videos, and releasing resources.
+The full process includes applying for permissions, creating an instance, setting parameters, managing sessions, taking photos, recording videos, and releasing resources.
+
+#### Applying for Permissions
+
+You must apply for the permission for your application to access the camera device and other functions. The following table lists camera-related permissions.
+
+| Permission| Attribute Value |
+| -------- | ------------------------------ |
+| Camera| ohos.permission.CAMERA |
+| Call recording| ohos.permission.MICROPHONE |
+| Storage| ohos.permission.WRITE_MEDIA |
+| Read| ohos.permission.READ_MEDIA |
+| Location| ohos.permission.MEDIA_LOCATION |
-The method for creating an XComponent is also provided. For details, see [XComponent Creation](#xcomponent-creation).
+The code snippet is as follows:
-For details about the APIs used to save images, see [Image Processing](../reference/apis/js-apis-image.md).
+```typescript
+const PERMISSIONS: Array = [
+ 'ohos.permission.CAMERA',
+ 'ohos.permission.MICROPHONE',
+ 'ohos.permission.MEDIA_LOCATION',
+ 'ohos.permission.READ_MEDIA',
+ 'ohos.permission.WRITE_MEDIA'
+]
+
+function applyPermission() {
+ console.info('[permission] get permission');
+ globalThis.abilityContext.requestPermissionFromUser(PERMISSIONS)
+ }
+```
#### Creating an Instance
-```js
+You must create an independent **CameraManager** instance before performing camera operations. If this operation fails, the camera may be occupied or unusable. If the camera is occupied, wait until it is released. You can call **getSupportedCameras()** to obtain the list of cameras supported by the current device. The list stores all camera IDs of the current device. If the list is not empty, each ID in the list can be used to create an independent camera instance. If the list is empty, no camera is available for the current device and subsequent operations cannot be performed. The camera has preview, shooting, video recording, and metadata streams. You can use **getSupportedOutputCapability()** to obtain the output stream capabilities of the camera and configure them in the **profile** field in **CameraOutputCapability**. The procedure for creating a **CameraManager** instance is as follows:
+
+```typescript
import camera from '@ohos.multimedia.camera'
import image from '@ohos.multimedia.image'
import media from '@ohos.multimedia.media'
-import featureAbility from '@ohos.ability.featureAbility'
// Create a CameraManager object.
-let cameraManager
-await camera.getCameraManager(globalThis.Context, (err, manager) => {
- if (err) {
- console.error('Failed to get the CameraManager instance ${err.message}');
- return;
- }
- console.log('Callback returned with the CameraManager instance');
- cameraManager = manager
-})
-
-// Register a callback to listen for camera status changes and obtain the updated camera status information.
-cameraManager.on('cameraStatus', (cameraStatusInfo) => {
- console.log('camera : ' + cameraStatusInfo.camera.cameraId);
- console.log('status: ' + cameraStatusInfo.status);
-})
+context: any = getContext(this)
+let cameraManager = await camera.getCameraManager(this.context)
+if (!cameraManager) {
+ console.error('Failed to get the CameraManager instance');
+}
// Obtain the camera list.
-let cameraArray
-await 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);
- cameraArray = cameras
-})
+let cameraArray = await cameraManager.getSupportedCameras()
+if (!cameraArray) {
+ console.error('Failed to get the cameras');
+}
-for(let cameraIndex = 0; cameraIndex < cameraArray.length; cameraIndex++) {
- console.log('cameraId : ' + cameraArray[cameraIndex].cameraId) // Obtain the camera ID.
- console.log('cameraPosition : ' + cameraArray[cameraIndex].cameraPosition) // Obtain the camera position.
- console.log('cameraType : ' + cameraArray[cameraIndex].cameraType) // Obtain the camera type.
- console.log('connectionType : ' + cameraArray[cameraIndex].connectionType) // Obtain the camera connection type.
+for (let index = 0; index < cameraArray.length; index++) {
+ console.log('cameraId : ' + cameraArray[index].cameraId) // Obtain the camera ID.
+ console.log('cameraPosition : ' + cameraArray[index].cameraPosition) // Obtain the camera position.
+ console.log('cameraType : ' + cameraArray[index].cameraType) // Obtain the camera type.
+ console.log('connectionType : ' + cameraArray[index].connectionType) // Obtain the camera connection type.
}
// Create a camera input stream.
-let cameraInput
-await cameraManager.createCameraInput(cameraArray[0].cameraId).then((input) => {
- console.log('Promise returned with the CameraInput instance');
- cameraInput = input
-})
+let cameraInput = await cameraManager.createCameraInput(cameraArray[0])
+
+// Obtain the output stream capabilities supported by the camera.
+let cameraOutputCap = await cameraManager.getSupportedOutputCapability(cameraArray[0]);
+if (!cameraOutputCap) {
+ console.error("outputCapability outputCapability == null || undefined")
+} else {
+ console.info("outputCapability: " + JSON.stringify(cameraOutputCap));
+}
-// Create a preview output stream.
-let previewOutput
-camera.createPreviewOutput((globalThis.surfaceId), (err, output) => {
- if (err) {
- console.error('Failed to create the PreviewOutput instance. ${err.message}');
- return;
- }
- console.log('Callback returned with previewOutput instance');
- previewOutput = output
-});
+let previewProfilesArray = cameraOutputCap.GetPreviewProfiles();
+if (!previewProfilesArray) {
+ console.error("createOutput previewProfilesArray == null || undefined")
+}
+
+let photoProfilesArray = cameraOutputCap.GetPhotoProfiles();
+if (!photoProfilesArray) {
+ console.error("createOutput photoProfilesArray == null || undefined")
+}
+
+let videoProfilesArray = cameraOutputCap.GetVideoProfiles();
+if (!videoProfilesArray) {
+ console.error("createOutput videoProfilesArray == null || undefined")
+}
+
+let metadataObjectTypesArray = cameraOutputCap.GetSupportedMetadataObjectType();
+if (!metadataObjectTypesArray) {
+ console.error("createOutput metadataObjectTypesArray == null || undefined")
+}
+
+// Create a preview stream. For details about the surfaceId parameter, see the XComponent section. The preview stream is the surface provided by the XComponent.
+let previewOutput = await cameraManager.createPreviewOutput(previewProfilesArray[0], surfaceId)
+if (!previewOutput) {
+ console.error("Failed to create the PreviewOutput instance.")
+}
-// Create an ImageReceiver object and set image parameters.
+// Create an ImageReceiver object and set photo parameters. The resolution is set based on the photographing resolutions supported by the current device, which are obtained by photoProfilesArray.
let imageReceiver = await image.createImageReceiver(1920, 1080, 4, 8)
// Obtain the surface ID for displaying the photos.
let photoSurfaceId = await imageReceiver.getReceivingSurfaceId()
// Create a photographing output stream.
-let photoOutput
-camera.createPhotoOutput((photoSurfaceId), (err, output) => {
- if (err) {
- console.error('Failed to create the PhotoOutput instance. ${err.message}');
- return;
- }
- console.log('Callback returned with the PhotoOutput instance.');
- photoOutput = output
-});
+let photoOutput = await cameraManager.createPhotoOutput(photoProfilesArray[0], photoSurfaceId)
+if (!photoOutput) {
+ console.error('Failed to create the PhotoOutput instance.');
+ return;
+}
// Define video recording parameters.
-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 : 'file:///data/media/01.mp4',
- orientationHint : 0,
- location : { latitude : 30, longitude : 130 },
+ audioSourceType: 1,
+ videoSourceType: 1,
+ profile: {
+ audioBitrate: 48000,
+ audioChannels: 2,
+ audioCodec: 'audio/mp4v-es',
+ audioSampleRate: 48000,
+ durationTime: 1000,
+ fileFormat: 'mp4',
+ videoBitrate: 48000,
+ videoCodec: 'video/mp4v-es',
+ videoFrameWidth: 640,
+ videoFrameHeight: 480,
+ videoFrameRate: 30
+ },
+ url: 'file:///data/media/01.mp4',
+ orientationHint: 0,
+ maxSize: 100,
+ maxDuration: 500,
+ rotation: 0
}
// Create a video recording output stream.
let videoRecorder
-await media.createVideoRecorder().then((recorder) => {
+media.createVideoRecorder().then((recorder) => {
console.log('createVideoRecorder called')
videoRecorder = recorder
})
// Set video recording parameters.
-await videoRecorder.prepare(videoConfig)
+videoRecorder.prepare(videoConfig)
// Obtain the surface ID for video recording.
-await videoRecorder.getInputSurface().then((id) => {
+let videoSurfaceId
+videoRecorder.getInputSurface().then((id) => {
console.log('getInputSurface called')
videoSurfaceId = id
})
-```
-For details about how to create a video recorder, see [Video Recording Development](./video-recorder.md).
-```js
+
// Create a VideoOutput object.
-let videoOutput
-camera.createVideoOutput((surfaceId), (err, output) => {
- if (err) {
- console.error('Failed to create the VideoOutput instance. ${err.message}');
- return;
+let videoOutput = await cameraManager.createVideoOutput(videoProfilesArray[0], videoSurfaceId)
+if (!videoOutput) {
+ console.error('Failed to create the videoOutput instance.');
+ return;
+}
+```
+Surfaces must be created in advance for the preview, shooting, and video recording stream. The preview stream is the surface provided by the **XComponent**, the shooting stream is the surface provided by **ImageReceiver**, and the video recording stream is the surface provided by **VideoRecorder**.
+
+**XComponent**
+
+```typescript
+mXComponentController: XComponentController = new XComponentController // Create an XComponentController.
+
+build() {
+ Flex() {
+ XComponent({ // Create an XComponent.
+ id: '',
+ type: 'surface',
+ libraryname: '',
+ controller: this.mXComponentController
+ })
+ .onload(() => { // Set the onload callback.
+ // Set the surface width and height (1920 x 1080). For details about how to set the preview size, see the preview resolutions supported by the current device, which are obtained by previewProfilesArray.
+ this.mXComponentController.setXComponentSurfaceSize({surfaceWidth:1920,surfaceHeight:1080})
+ // Obtain the surface ID.
+ globalThis.surfaceId = mXComponentController.getXComponentSurfaceId()
+ })
+ .width('1920px') // Set the width of the XComponent.
+ .height('1080px') // Set the height of the XComponent.
}
- console.log('Callback returned with the VideoOutput instance');
- videoOutput = output
-});
+}
+```
+
+**ImageReceiver**
+
+```typescript
+function getImageReceiverSurfaceId() {
+ let receiver = image.createImageReceiver(640, 480, 4, 8)
+ console.log(TAG + 'before ImageReceiver check')
+ if (receiver !== undefined) {
+ console.log('ImageReceiver is ok')
+ surfaceId1 = receiver.getReceivingSurfaceId()
+ console.log('ImageReceived id: ' + JSON.stringify(surfaceId1))
+ } else {
+ console.log('ImageReceiver is not ok')
+ }
+ }
+```
+
+**VideoRecorder**
+
+```typescript
+function getVideoRecorderSurface() {
+ await getFd('CameraManager.mp4');
+ mVideoConfig.url = mFdPath;
+ media.createVideoRecorder((err, recorder) => {
+ console.info('Entering create video receiver')
+ mVideoRecorder = recorder
+ console.info('videoRecorder is :' + JSON.stringify(mVideoRecorder))
+ console.info('videoRecorder.prepare called.')
+ mVideoRecorder.prepare(mVideoConfig, (err) => {
+ console.info('videoRecorder.prepare success.')
+ mVideoRecorder.getInputSurface((err, id) => {
+ console.info('getInputSurface called')
+ mVideoSurface = id
+ console.info('getInputSurface surfaceId: ' + JSON.stringify(mVideoSurface))
+ })
+ })
+ })
+ }
+```
+
+#### Managing Sessions
+
+##### Creating a Session
+
+```typescript
+// Create a session.
+let captureSession = await camera.createCaptureSession()
+if (!captureSession) {
+ console.error('Failed to create the CaptureSession instance.');
+ return;
+}
+console.log('Callback returned with the CaptureSession instance.' + session);
+
+// Start configuration for the session.
+await captureSession.beginConfig()
+
+// Add the camera input stream to the session.
+await captureSession.addInput(cameraInput)
+
+// Add the preview input stream to the session.
+await captureSession.addOutput(previewOutput)
+
+// Add the photographing output stream to the session.
+await captureSession.addOutput(photoOutput)
+
+// Commit the session configuration.
+await captureSession.commitConfig()
+
+// Start the session.
+await captureSession.start().then(() => {
+ console.log('Promise returned to indicate the session start success.');
+})
+```
+##### Switching a Session
+
+```typescript
+// Stop the session.
+await captureSession.stop()
+
+// Start configuration for the session.
+await captureSession.beginConfig()
+
+// Remove the photographing output stream from the session.
+await captureSession.removeOutput(photoOutput)
+
+// Add a video recording output stream to the session.
+await captureSession.addOutput(videoOutput)
+
+// Commit the session configuration.
+await captureSession.commitConfig()
+
+// Start the session.
+await captureSession.start().then(() => {
+ console.log('Promise returned to indicate the session start success.');
+})
```
#### Setting Parameters
-```js
+```typescript
// Check whether the camera has flash.
-let flashStatus
-await cameraInput.hasFlash().then((status) => {
- console.log('Promise returned with the flash light support status:' + status);
- flashStatus = status
-})
-if(flashStatus) {
+let flashStatus = await captureSession.hasFlash()
+if (!flashStatus) {
+ console.error('Failed to check whether the device has the flash mode.');
+}
+console.log('Promise returned with the flash light support status:' + flashStatus);
+
+if (flashStatus) {
// Check whether the auto flash mode is supported.
let flashModeStatus
- cameraInput.isFlashModeSupported(camera.FlashMode.FLASH_MODE_AUTO, (err, status) => {
+ captureSession.isFlashModeSupported(camera.FlashMode.FLASH_MODE_AUTO, async (err, status) => {
if (err) {
console.error('Failed to check whether the flash mode is supported. ${err.message}');
return;
@@ -167,7 +319,7 @@ if(flashStatus) {
})
if(flashModeStatus) {
// Set the flash mode to auto.
- cameraInput.setFlashMode(camera.FlashMode.FLASH_MODE_AUTO, (err) => {
+ captureSession.setFlashMode(camera.FlashMode.FLASH_MODE_AUTO, async (err) => {
if (err) {
console.error('Failed to set the flash mode ${err.message}');
return;
@@ -179,7 +331,7 @@ if(flashStatus) {
// Check whether the continuous auto focus is supported.
let focusModeStatus
-cameraInput.isFocusModeSupported(camera.FocusMode.FOCUS_MODE_CONTINUOUS_AUTO, (err, status) => {
+captureSession.isFocusModeSupported(camera.FocusMode.FOCUS_MODE_CONTINUOUS_AUTO, async (err, status) => {
if (err) {
console.error('Failed to check whether the focus mode is supported. ${err.message}');
return;
@@ -187,9 +339,9 @@ cameraInput.isFocusModeSupported(camera.FocusMode.FOCUS_MODE_CONTINUOUS_AUTO, (e
console.log('Callback returned with the focus mode support status: ' + status);
focusModeStatus = status
})
-if(focusModeStatus) {
+if (focusModeStatus) {
// Set the focus mode to continuous auto focus.
- cameraInput.setFocusMode(camera.FocusMode.FOCUS_MODE_CONTINUOUS_AUTO, (err) => {
+ captureSession.setFocusMode(camera.FocusMode.FOCUS_MODE_CONTINUOUS_AUTO, async (err) => {
if (err) {
console.error('Failed to set the focus mode ${err.message}');
return;
@@ -199,18 +351,14 @@ if(focusModeStatus) {
}
// Obtain the zoom ratio range supported by the camera.
-let zoomRatioRange
-cameraInput.getZoomRatioRange((err, range) => {
- if (err) {
- console.error('Failed to get the zoom ratio range. ${err.message}');
- return;
- }
- console.log('Callback returned with zoom ratio range: ' + range.length);
- zoomRatioRange = range
-})
+let zoomRatioRange = await captureSession.getZoomRatioRange()
+if (!zoomRatioRange) {
+ console.error('Failed to get the zoom ratio range.');
+ return;
+}
// Set a zoom ratio.
-cameraInput.setZoomRatio(zoomRatioRange[0], (err) => {
+captureSession.setZoomRatio(zoomRatioRange[0], async (err) => {
if (err) {
console.error('Failed to set the zoom ratio value ${err.message}');
return;
@@ -219,139 +367,15 @@ cameraInput.setZoomRatio(zoomRatioRange[0], (err) => {
})
```
-#### Managing Sessions
-
-##### Creating a Session
-
-```js
-// Create a Context object.
-let context = featureAbility.getContext()
-
-// Create a session.
-let captureSession
-await camera.createCaptureSession((context), (err, session) => {
- if (err) {
- console.error('Failed to create the CaptureSession instance. ${err.message}');
- return;
- }
- console.log('Callback returned with the CaptureSession instance.' + session);
- captureSession = session
-});
-
-// Start configuration for the session.
-await 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.');
-});
-
-// Add the camera input stream to the session.
-await 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.');
-});
-
-// Add the preview input stream to the session.
-await 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.');
-});
-
-// Add the photographing output stream to the session.
-await 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.');
-});
-
-// Commit the session configuration.
-await 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.');
-});
-
-// Start the session.
-await captureSession.start().then(() => {
- console.log('Promise returned to indicate the session start success.');
-})
-```
-
-##### Switching a Session
-
-```js
-// Stop the session.
-await 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.');
-});
-
-// Start configuration for the session.
-await 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.');
-});
-
-// Remove the photographing output stream from the session.
-await 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.');
-});
-
-// Add a video recording output stream to the session.
-await 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.');
-});
-
-// Commit the session configuration.
-await 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.');
-});
-
-// Start the session.
-await captureSession.start().then(() => {
- console.log('Promise returned to indicate the session start success.');
-})
-```
-
#### Taking Photos
-```js
+```typescript
let settings = {
quality: camera.QualityLevel.QUALITY_LEVEL_HIGH, // Set the image quality to high.
rotation: camera.ImageRotation.ROTATION_0 // Set the image rotation angle to 0.
}
// Use the current photographing settings to take photos.
-photoOutput.capture(settings, (err) => {
+photoOutput.capture(settings, async (err) => {
if (err) {
console.error('Failed to capture the photo ${err.message}');
return;
@@ -362,9 +386,9 @@ photoOutput.capture(settings, (err) => {
#### Recording Videos
-```js
+```typescript
// Start the video recording output stream.
-videoOutput.start((err) => {
+videoOutput.start(async (err) => {
if (err) {
console.error('Failed to start the video output ${err.message}');
return;
@@ -373,17 +397,17 @@ videoOutput.start((err) => {
});
// Start video recording.
-await videoRecorder.start().then(() => {
+videoRecorder.start().then(() => {
console.info('videoRecorder start success');
}
// Stop video recording.
-await videoRecorder.stop().then(() => {
+videoRecorder.stop().then(() => {
console.info('stop success');
}
// Stop the video recording output stream.
-await videoOutput.stop((err) => {
+videoOutput.stop((err) => {
if (err) {
console.error('Failed to stop the video output ${err.message}');
return;
@@ -392,81 +416,34 @@ await videoOutput.stop((err) => {
});
```
+For details about the APIs used for saving photos, see [Image Processing](image.md#using-imagereceiver).
+
#### Releasing Resources
-```js
+```typescript
// Stop the session.
-await 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.');
-});
+captureSession.stop()
+
// Release the camera input stream.
-await 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.');
-});
+cameraInput.release()
+
// Release the preview output stream.
-await 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.');
-});
+previewOutput.release()
+
// Release the photographing output stream.
-await 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.');
-});
+photoOutput.release()
+
// Release the video recording output stream.
-await 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.');
-});
+videoOutput.release()
+
// Release the session.
-await 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.');
-});
-```
+captureSession.release()
-#### XComponent Creation
-The surface ID must be obtained for image preview.
+// Set the session to null.
+captureSession = null
+```
-```js
-mXComponentController: XComponentController = new XComponentController // Create an XComponentController.
+## Process Flowchart
-build() {
- Flex() {
- XComponent({ // Create an XComponent.
- id: '',
- type: 'surface',
- libraryname: '',
- controller: this.mXComponentController
- })
- .onload(() => { // Set the onload callback.
- // Set the width and height of the surface to 1920 and 1080, respectively.
- this.mXComponentController.setXComponentSurfaceSize({surfaceWidth:1920,surfaceHeight:1080})
- // Obtain the surface ID.
- globalThis.surfaceId = mXComponentController.getXComponentSurfaceId()
- })
- .width('1920px') // Set the width of the XComponent.
- .height('1080px') // Set the height of the XComponent.
- }
-}
-```
+The following figure shows the process of using the camera.
+
diff --git a/en/application-dev/media/figures/camera_framework_process.jpg b/en/application-dev/media/figures/camera_framework_process.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..1207a9a4adb5d5886f9427b07f0ec7d717fc5bf8
Binary files /dev/null and b/en/application-dev/media/figures/camera_framework_process.jpg differ
diff --git a/en/application-dev/media/video-playback.md b/en/application-dev/media/video-playback.md
index 6ee5cf660069294f717c5cac614ed707db9f1a8c..b324f19b3cf0f3621bd74809c4f1a2d0b57d0abd 100644
--- a/en/application-dev/media/video-playback.md
+++ b/en/application-dev/media/video-playback.md
@@ -1,17 +1,23 @@
# Video Playback Development
-## When to Use
+## Introduction
-You can use video playback APIs to convert video data into visible signals, play the signals using output devices, and manage playback tasks. This document describes development for the following video playback scenarios: full-process, normal playback, video switching, and loop playback.
+You can use video playback APIs to convert audio data into audible analog signals and play the signals using output devices. You can also manage playback tasks. For example, you can start, suspend, stop playback, release resources, set the volume, seek to a playback position, set the playback speed, and obtain track information. This document describes development for the following video playback scenarios: full-process, normal playback, video switching, and loop playback.
+
+## Working Principles
+
+The following figures show the video playback state transition and the interaction with external modules for video playback.
**Figure 1** Video playback state transition

-**Figure 2** Layer 0 diagram of video playback
+**Figure 2** Interaction with external modules for video playback

+**NOTE**: When a third-party application calls a JS interface provided by the JS interface layer, the framework layer invokes the audio component through the media service of the native framework to output the audio data decoded by the software to the audio HDI. The graphics subsystem outputs the image data decoded by the codec HDI at the hardware interface layer to the display HDI. In this way, video playback is implemented.
+
*Note: Video playback requires hardware capabilities such as display, audio, and codec.*
1. A third-party application obtains a surface ID from the XComponent.
diff --git a/en/application-dev/media/video-recorder.md b/en/application-dev/media/video-recorder.md
index 62e81cf05c384a7cd1a780c562697be046153d05..bef55899bcb51359a6b6d68ef6d7894d70e435ae 100644
--- a/en/application-dev/media/video-recorder.md
+++ b/en/application-dev/media/video-recorder.md
@@ -1,17 +1,27 @@
# Video Recording Development
-## When to Use
+## Introduction
-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.
+You can use video recording APIs to capture audio and video signals, encode them, and save them to files. You can start, suspend, resume, and stop recording, and release resources. You can also specify parameters such as the encoding format, encapsulation format, and file path for video recording.
+
+## Working Principles
+
+The following figures show the video recording state transition and the interaction with external modules for video recording.
**Figure 1** Video recording state transition

-**Figure 2** Layer 0 diagram of video recording
+**Figure 2** Interaction with external modules for video recording

+**NOTE**: When a third-party camera application or system camera calls a JS interface provided by the JS interface layer, the framework layer uses the media service of the native framework to invoke the audio component. Through the audio HDI, the audio component captures audio data, encodes the audio data through software, and saves the encoded audio data to a file. The graphics subsystem captures image data through the video HDI, encodes the image data through the video codec HDI, and saves the encoded image data to a file. In this way, video recording is implemented.
+
+## Constraints
+
+Before developing video recording, configure the permissions **ohos.permission.MICROPHONE** and **ohos.permission.CAMERA** for your application. For details about the configuration, see [Permission Application Guide](../security/accesstoken-guidelines.md).
+
## How to Develop
For details about the APIs, see [VideoRecorder in the Media API](../reference/apis/js-apis-media.md#videorecorder9).
@@ -147,3 +157,4 @@ export class VideoRecorderDemo {
}
}
```
+
diff --git a/en/application-dev/quick-start/arkts-rendering-control.md b/en/application-dev/quick-start/arkts-rendering-control.md
new file mode 100644
index 0000000000000000000000000000000000000000..06862c299448fea4052c690ac45eb29caae1c636
--- /dev/null
+++ b/en/application-dev/quick-start/arkts-rendering-control.md
@@ -0,0 +1,282 @@
+# Rendering Control
+
+ArkTS provides conditional rendering and loop rendering. Conditional rendering can render state-specific UI content based on the application status. Loop rendering iteratively obtains data from the data source and creates the corresponding component during each iteration.
+
+## Conditional Rendering
+
+Use **if/else** for conditional rendering.
+
+
+> **NOTE**
+>
+> - State variables can be used in the **if/else** statement.
+>
+> - The **if/else** statement can be used to implement rendering of child components.
+>
+> - The **if/else** statement must be used in container components.
+>
+> - Some container components limit the type or number of subcomponents. When **if/else** is placed in these components, the limitation applies to components created in **if/else** statements. For example, when **if/else** is used in the **\** container component, whose child components can only be **\**, only the **\** component can be used in the **if/else** statement.
+
+
+```ts
+Column() {
+ if (this.count < 0) {
+ Text('count is negative').fontSize(14)
+ } else if (this.count % 2 === 0) {
+ Text('count is even').fontSize(14)
+ } else {
+ Text('count is odd').fontSize(14)
+ }
+}
+```
+
+## Loop Rendering
+
+You can use **ForEach** to obtain data from arrays and create components for each data item.
+
+```
+ForEach(
+ arr: any[],
+ itemGenerator: (item: any, index?: number) => void,
+ keyGenerator?: (item: any, index?: number) => string
+)
+```
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| ------------- | ------------------------------------- | ---- | ------------------------------------------------------------ |
+| arr | any[] | Yes | An array, which can be empty, in which case no child component is created. The functions that return array-type values are also allowed, for example, **arr.slice (1, 3)**. The set functions cannot change any state variables including the array itself, such as **Array.splice**, **Array.sort**, and **Array.reverse**.|
+| itemGenerator | (item: any, index?: number) => void | Yes | A lambda function used to generate one or more child components for each data item in an array. A single child component or a list of child components must be included in parentheses.|
+| keyGenerator | (item: any, index?: number) => string | No | An anonymous function used to generate a unique and fixed key value for each data item in an array. This key value must remain unchanged for the data item even when the item is relocated in the array. When the item is replaced by a new item, the key value of the new item must be different from that of the existing item. This key-value generator is optional. However, for performance reasons, it is strongly recommended that the key-value generator be provided, so that the development framework can better identify array changes. For example, if no key-value generator is provided, a reverse of an array will result in rebuilding of all nodes in **ForEach**.|
+
+> **NOTE**
+>
+> - **ForEach** must be used in container components.
+>
+> - The generated child components should be allowed in the parent container component of **ForEach**.
+>
+> - The **itemGenerator** function can contain an **if/else** statement, and an **if/else** statement can contain **ForEach**.
+>
+> - The call sequence of **itemGenerator** functions may be different from that of the data items in the array. During the development, do not assume whether or when the **itemGenerator** and **keyGenerator** functions are executed. The following is an example of incorrect usage:
+>
+> ```ts
+> ForEach(anArray.map((item1, index1) => { return { i: index1 + 1, data: item1 }; }),
+> item => Text(`${item.i}. item.data.label`),
+> item => item.data.id.toString())
+> ```
+
+## Example
+
+```ts
+// xxx.ets
+@Entry
+@Component
+struct MyComponent {
+ @State arr: number[] = [10, 20, 30]
+
+ build() {
+ Column({ space: 5 }) {
+ Button('Reverse Array')
+ .onClick(() => {
+ this.arr.reverse()
+ })
+
+ ForEach(this.arr, (item: number) => {
+ Text(`item value: ${item}`).fontSize(18)
+ Divider().strokeWidth(2)
+ }, (item: number) => item.toString())
+ }
+ }
+}
+```
+
+
+
+## Lazy Loading
+
+You can use **LazyForEach** to iterate over provided data sources and create corresponding components during each iteration.
+
+```ts
+LazyForEach(
+ dataSource: IDataSource,
+ itemGenerator: (item: any) => void,
+ keyGenerator?: (item: any) => string
+): void
+
+interface IDataSource {
+ totalCount(): number;
+ getData(index: number): any;
+ registerDataChangeListener(listener: DataChangeListener): void;
+ unregisterDataChangeListener(listener: DataChangeListener): void;
+}
+
+interface DataChangeListener {
+ onDataReloaded(): void;
+ onDataAdd(index: number): void;
+ onDataMove(from: number, to: number): void;
+ onDataDelete(index: number): void;
+ onDataChange(index: number): void;
+}
+```
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| ------------- | --------------------- | ---- | ------------------------------------------------------------ |
+| dataSource | IDataSource | Yes | Object used to implement the **IDataSource** API. You need to implement related APIs. |
+| itemGenerator | (item: any) => void | Yes | A lambda function used to generate one or more child components for each data item in an array. A single child component or a list of child components must be included in parentheses.|
+| keyGenerator | (item: any) => string | No | An anonymous function used to generate a unique and fixed key value for each data item in an array. This key value must remain unchanged for the data item even when the item is relocated in the array. When the item is replaced by a new item, the key value of the new item must be different from that of the existing item. This key-value generator is optional. However, for performance reasons, it is strongly recommended that the key-value generator be provided, so that the development framework can better identify array changes. For example, if no key-value generator is provided, a reverse of an array will result in rebuilding of all nodes in **LazyForEach**.|
+
+### Description of IDataSource
+
+| Name | Description |
+| ------------------------------------------------------------ | ---------------------- |
+| totalCount(): number | Obtains the total number of data records. |
+| getData(index: number): any | Obtains the data corresponding to the specified index. |
+| registerDataChangeListener(listener:DataChangeListener): void | Registers a listener for data changes.|
+| unregisterDataChangeListener(listener:DataChangeListener): void | Deregisters a listener for data changes.|
+
+### Description of DataChangeListener
+
+| Name | Description |
+| -------------------------------------------------------- | -------------------------------------- |
+| onDataReloaded(): void | Invoked when all data is reloaded. |
+| onDataAdded(index: number): void (deprecated) | Invoked when data is added to the position indicated by the specified index. |
+| onDataMoved(from: number, to: number): void (deprecated) | Invoked when data is moved from the **from** position to the **to** position.|
+| onDataDeleted(index: number): void (deprecated) | Invoked when data is deleted from the position indicated by the specified index. |
+| onDataChanged(index: number): void (deprecated) | Invoked when data in the position indicated by the specified index is changed. |
+| onDataAdd(index: number): void 8+ | Invoked when data is added to the position indicated by the specified index. |
+| onDataMove(from: number, to: number): void 8+ | Invoked when data is moved from the **from** position to the **to** position.|
+| onDataDelete(index: number): void 8+ | Invoked when data is deleted from the position indicated by the specified index. |
+| onDataChange(index: number): void 8+ | Invoked when data in the position indicated by the specified index is changed. |
+
+## Example
+
+```ts
+// xxx.ets
+class BasicDataSource implements IDataSource {
+ private listeners: DataChangeListener[] = []
+
+ public totalCount(): number {
+ return 0
+ }
+
+ public getData(index: number): any {
+ return undefined
+ }
+
+ registerDataChangeListener(listener: DataChangeListener): void {
+ if (this.listeners.indexOf(listener) < 0) {
+ console.info('add listener')
+ this.listeners.push(listener)
+ }
+ }
+
+ unregisterDataChangeListener(listener: DataChangeListener): void {
+ const pos = this.listeners.indexOf(listener);
+ if (pos >= 0) {
+ console.info('remove listener')
+ this.listeners.splice(pos, 1)
+ }
+ }
+
+ notifyDataReload(): void {
+ this.listeners.forEach(listener => {
+ listener.onDataReloaded()
+ })
+ }
+
+ notifyDataAdd(index: number): void {
+ this.listeners.forEach(listener => {
+ listener.onDataAdd(index)
+ })
+ }
+
+ notifyDataChange(index: number): void {
+ this.listeners.forEach(listener => {
+ listener.onDataChange(index)
+ })
+ }
+
+ notifyDataDelete(index: number): void {
+ this.listeners.forEach(listener => {
+ listener.onDataDelete(index)
+ })
+ }
+
+ notifyDataMove(from: number, to: number): void {
+ this.listeners.forEach(listener => {
+ listener.onDataMove(from, to)
+ })
+ }
+}
+
+class MyDataSource extends BasicDataSource {
+ // Initialize the data list.
+ private dataArray: string[] = ['/path/image0.png', '/path/image1.png', '/path/image2.png', '/path/image3.png']
+
+ public totalCount(): number {
+ return this.dataArray.length
+ }
+
+ public getData(index: number): any {
+ return this.dataArray[index]
+ }
+
+ public addData(index: number, data: string): void {
+ this.dataArray.splice(index, 0, data)
+ this.notifyDataAdd(index)
+ }
+
+ public pushData(data: string): void {
+ this.dataArray.push(data)
+ this.notifyDataAdd(this.dataArray.length - 1)
+ }
+}
+
+@Entry
+@Component
+struct MyComponent {
+ private data: MyDataSource = new MyDataSource()
+
+ build() {
+ List({ space: 3 }) {
+ LazyForEach(this.data, (item: string) => {
+ ListItem() {
+ Row() {
+ Image(item).width(50).height(50)
+ Text(item).fontSize(20).margin({ left: 10 })
+ }.margin({ left: 10, right: 10 })
+ }
+ .onClick(() => {
+ // The count increases by one each time the list is clicked.
+ this.data.pushData('/path/image' + this.data.totalCount() + '.png')
+ })
+ }, item => item)
+ }
+ }
+}
+```
+
+> **NOTE**
+>
+> - **LazyForEach** must be used in the container component. Currently, only the **\**, **\**, and **\** components support lazy loading (that is, only the visible part and a small amount of data before and after the visible part are loaded for caching). For other components, all data is loaded at a time.
+>
+> - **LazyForEach** must create and only one child component in each iteration.
+>
+> - The generated child components must be allowed in the parent container component of **LazyForEach**.
+>
+> - **LazyForEach** can be included in an **if/else** statement, but cannot contain such a statement.
+>
+> - For the purpose of high-performance rendering, when the **onDataChange** method of the **DataChangeListener** object is used to update the UI, the component update is triggered only when the state variable is used in the child component created by **itemGenerator**.
+>
+> - The call sequence of **itemGenerator** functions may be different from that of the data items in the data source. During the development, do not assume whether or when the **itemGenerator** and **keyGenerator** functions are executed. The following is an example of incorrect usage:
+>
+> ```ts
+> LazyForEach(dataSource,
+> item => Text(`${item.i}. item.data.label`)),
+> item => item.data.id.toString())
+> ```
+
+
diff --git a/en/application-dev/quick-start/figures/forEach1.gif b/en/application-dev/quick-start/figures/forEach1.gif
new file mode 100644
index 0000000000000000000000000000000000000000..8e9e35e98b8c5fec6baf58997ae78992a554e069
Binary files /dev/null and b/en/application-dev/quick-start/figures/forEach1.gif differ
diff --git a/en/application-dev/quick-start/figures/lazyForEach.gif b/en/application-dev/quick-start/figures/lazyForEach.gif
new file mode 100644
index 0000000000000000000000000000000000000000..e8f92b92fd63c572e22964d8caa6132d318cf5bd
Binary files /dev/null and b/en/application-dev/quick-start/figures/lazyForEach.gif differ
diff --git a/en/application-dev/reference/apis/Readme-EN.md b/en/application-dev/reference/apis/Readme-EN.md
index b0496b23ece03d1698df3b88f1002908bd033797..6e564f2518cf3ce6f083da66d8d72c0b8310f650 100644
--- a/en/application-dev/reference/apis/Readme-EN.md
+++ b/en/application-dev/reference/apis/Readme-EN.md
@@ -45,6 +45,7 @@
- [@ohos.application.formInfo](js-apis-formInfo.md)
- [@ohos.application.formProvider](js-apis-formprovider.md)
- [@ohos.application.missionManager](js-apis-missionManager.md)
+ - [@ohos.application.quickFixManager](js-apis-application-quickFixManager.md)
- [@ohos.application.Want](js-apis-application-Want.md)
- [@ohos.continuation.continuationManager](js-apis-continuation-continuationExtraParams.md)
- [@ohos.continuation.continuationManager](js-apis-continuation-continuationManager.md)
@@ -90,8 +91,8 @@
- UI Page
- [@ohos.animator](js-apis-animator.md)
- [@ohos.mediaquery](js-apis-mediaquery.md)
+ - [@ohos.promptAction](js-apis-promptAction.md)
- [@ohos.router](js-apis-router.md)
- - [@ohos.uiAppearance](js-apis-uiappearance.md)
- Graphics
- [@ohos.animation.windowAnimationManager](js-apis-windowAnimationManager.md)
- [@ohos.display ](js-apis-display.md)
@@ -146,6 +147,7 @@
- [@ohos.document](js-apis-document.md)
- [@ohos.environment](js-apis-environment.md)
- [@ohos.fileio](js-apis-fileio.md)
+ - [@ohos.filemanagement.userfile_manager](js-apis-userfilemanager.md)
- [@ohos.multimedia.medialibrary](js-apis-medialibrary.md)
- [@ohos.securityLabel](js-apis-securityLabel.md)
- [@ohos.statfs](js-apis-statfs.md)
@@ -213,6 +215,7 @@
- [@ohos.geolocation](js-apis-geolocation.md)
- [@ohos.multimodalInput.inputConsumer](js-apis-inputconsumer.md)
- [@ohos.multimodalInput.inputDevice](js-apis-inputdevice.md)
+ - [@ohos.multimodalInput.inputDeviceCooperate](js-apis-cooperate.md)
- [@ohos.multimodalInput.inputEvent](js-apis-inputevent.md)
- [@ohos.multimodalInput.inputEventClient](js-apis-inputeventclient.md)
- [@ohos.multimodalInput.inputMonitor](js-apis-inputmonitor.md)
@@ -261,6 +264,7 @@
- [@ohos.application.testRunner](js-apis-testRunner.md)
- [@ohos.uitest](js-apis-uitest.md)
- APIs No Longer Maintained
+ - [@ohos.bundleState](js-apis-deviceUsageStatistics.md)
- [@ohos.bytrace](js-apis-bytrace.md)
- [@ohos.data.storage](js-apis-data-storage.md)
- [@ohos.data.distributedData](js-apis-distributed-data.md)
diff --git a/en/application-dev/reference/apis/figures/en-us_image_0001.gif b/en/application-dev/reference/apis/figures/en-us_image_0001.gif
new file mode 100644
index 0000000000000000000000000000000000000000..099acf91f8a1a6936c56e0ae09aaf7530b080828
Binary files /dev/null and b/en/application-dev/reference/apis/figures/en-us_image_0001.gif differ
diff --git a/en/application-dev/reference/apis/figures/en-us_image_0002.gif b/en/application-dev/reference/apis/figures/en-us_image_0002.gif
new file mode 100644
index 0000000000000000000000000000000000000000..6e4c041811c24ffba57eee64c64d12532150fe4b
Binary files /dev/null and b/en/application-dev/reference/apis/figures/en-us_image_0002.gif differ
diff --git a/en/application-dev/reference/apis/figures/en-us_image_0004.gif b/en/application-dev/reference/apis/figures/en-us_image_0004.gif
new file mode 100644
index 0000000000000000000000000000000000000000..f622ab0eca3995baece321539984c289ab1b8b1a
Binary files /dev/null and b/en/application-dev/reference/apis/figures/en-us_image_0004.gif differ
diff --git a/en/application-dev/reference/apis/figures/en-us_image_0005.gif b/en/application-dev/reference/apis/figures/en-us_image_0005.gif
new file mode 100644
index 0000000000000000000000000000000000000000..5d904fbfabdc50751afd51e9a29b0aa18c6e445f
Binary files /dev/null and b/en/application-dev/reference/apis/figures/en-us_image_0005.gif differ
diff --git a/en/application-dev/reference/apis/figures/en-us_image_0006.gif b/en/application-dev/reference/apis/figures/en-us_image_0006.gif
new file mode 100644
index 0000000000000000000000000000000000000000..7477b94b0437fadfc2d875841f182648d1bcccc9
Binary files /dev/null and b/en/application-dev/reference/apis/figures/en-us_image_0006.gif differ
diff --git a/en/application-dev/reference/apis/js-apis-application-quickFixManager.md b/en/application-dev/reference/apis/js-apis-application-quickFixManager.md
new file mode 100644
index 0000000000000000000000000000000000000000..5abe8c19658d484fb335efc0d3fe8e2aa49bdc48
--- /dev/null
+++ b/en/application-dev/reference/apis/js-apis-application-quickFixManager.md
@@ -0,0 +1,186 @@
+# quickFixManager
+
+The **quickFixManager** module provides APIs for quick fix. With quick fix, you can fix bugs in your application by applying patches, which is more efficient than by updating the entire application.
+
+> **NOTE**
+>
+> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
+
+## Modules to Import
+
+```
+import quickFixManager from '@ohos.application.quickFixManager';
+```
+
+## HapModuleQuickFixInfo
+
+Defines the quick fix information at the HAP file level.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.QuickFix
+
+**System API**: This is a system API and cannot be called by third-party applications.
+
+| Name | Readable/Writable| Type | Mandatory| Description |
+| ----------- | -------- | -------------------- | ---- | ------------------------------------------------------------ |
+| moduleName | Read only | string | Yes | Name of the HAP file. |
+| originHapHash | Read only | string | Yes | Hash value of the HAP file. |
+| quickFixFilePath | Read only | string | Yes | Installation path of the quick fix file. |
+
+## ApplicationQuickFixInfo
+
+Defines the quick fix information at the application level.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.QuickFix
+
+**System API**: This is a system API and cannot be called by third-party applications.
+
+| Name | Readable/Writable| Type | Mandatory| Description |
+| ----------- | -------- | -------------------- | ---- | ------------------------------------------------------------ |
+| bundleName | Read only | string | Yes | Bundle name of the application. |
+| bundleVersionCode | Read only | number | Yes | Internal version number of the application. |
+| bundleVersionName | Read only | string | Yes | Version number of the application that is shown to users. |
+| quickFixVersionCode | Read only | number | Yes | Version code of the quick fix patch package. |
+| quickFixVersionName | Read only | string | Yes | Text description of the version number of the quick fix patch package. |
+| hapModuleQuickFixInfo | Read only | Array\<[HapModuleQuickFixInfo](#hapmodulequickfixinfo)> | Yes | Quick fix information at the HAP file level. |
+
+## quickFixManager.applyQuickFix
+
+applyQuickFix(hapModuleQuickFixFiles: Array\, callback: AsyncCallback\): void;
+
+Applies a quick fix patch. This API uses an asynchronous callback to return the result.
+
+**Required permissions**: ohos.permission.INSTALL_BUNDLE
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.QuickFix
+
+**System API**: This is a system API and cannot be called by third-party applications.
+
+**Parameters**
+
+ | Parameter| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | hapModuleQuickFixFiles | Array\ | No| Quick fix files, each of which must contain a valid file path.|
+ | callback | AsyncCallback\ | No| Callback used to return the result.|
+
+**Example**
+
+```js
+ import quickFixManager from '@ohos.application.quickFixManager'
+
+ let hapModuleQuickFixFiles = ["/data/storage/el2/base/entry.hqf"]
+ quickFixManager.applyQuickFix(hapModuleQuickFixFiles, (error) => {
+ if (error) {
+ console.info( `applyQuickFix failed with error + ${error}`)
+ } else {
+ console.info( 'applyQuickFix success')
+ }
+ })
+```
+
+## quickFixManager.applyQuickFix
+
+applyQuickFix(hapModuleQuickFixFiles: Array\): Promise\;
+
+Applies a quick fix patch. This API uses a promise to return the result.
+
+**Required permissions**: ohos.permission.INSTALL_BUNDLE
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.QuickFix
+
+**System API**: This is a system API and cannot be called by third-party applications.
+
+**Parameters**
+
+ | Parameter| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | hapModuleQuickFixFiles | Array\ | No| Quick fix files, each of which must contain a valid file path.|
+
+**Return value**
+
+ | Type| Description|
+ | -------- | -------- |
+ | Promise\ | Promise used to return the result.|
+
+**Example**
+
+```js
+ import quickFixManager from '@ohos.application.quickFixManager'
+
+ let hapModuleQuickFixFiles = ["/data/storage/el2/base/entry.hqf"]
+ quickFixManager.applyQuickFix(hapModuleQuickFixFiles).then(() => {
+ console.info('applyQuickFix success')
+ }).catch((error) => {
+ console.info(`applyQuickFix err: + ${error}`)
+ })
+```
+
+## quickFixManager.getApplicationQuickFixInfo
+
+getApplicationQuickFixInfo(bundleName: string, callback: AsyncCallback\): void;
+
+Obtains the quick fix information of the application. This API uses an asynchronous callback to return the result.
+
+**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.QuickFix
+
+**System API**: This is a system API and cannot be called by third-party applications.
+
+**Parameters**
+
+ | Parameter| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | bundleName | string | No|Bundle name of the application. |
+ | callback | AsyncCallback\<[ApplicationQuickFixInfo](#applicationquickfixinfo)> | No| Callback used to return the quick fix information.|
+
+**Example**
+
+```js
+ import quickFixManager from '@ohos.application.quickFixManager'
+
+ let bundleName = "bundleName"
+ quickFixManager.getApplicationQuickFixInfo(bundleName, (error, data) => {
+ if (error) {
+ console.info(`getApplicationQuickFixInfo error: + ${error}`)
+ } else {
+ console.info(`getApplicationQuickFixInfo success: + ${data}`)
+ }
+ })
+```
+
+## quickFixManager.getApplicationQuickFixInfo
+
+getApplicationQuickFixInfo(bundleName: string): Promise\;
+
+Obtains the quick fix information of the application. This API uses a promise to return the result.
+
+**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.QuickFix
+
+**System API**: This is a system API and cannot be called by third-party applications.
+
+**Parameters**
+
+ | Parameter| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | bundleName | string | No| Bundle name of the application. |
+
+**Return value**
+
+ | Type| Description|
+ | -------- | -------- |
+ | Promise\<[ApplicationQuickFixInfo](#applicationquickfixinfo)> | Promise used to return the quick fix information.|
+
+**Example**
+
+ ```js
+ import quickFixManager from '@ohos.application.quickFixManager'
+
+ let bundleName = "bundleName"
+ quickFixManager.getApplicationQuickFixInfo(bundleName).then((data) => {
+ console.info(`getApplicationQuickFixInfo success: + ${data}`)
+ }).catch((error) => {
+ console.info(`getApplicationQuickFixInfo err: + ${error}`)
+ })
+```
diff --git a/en/application-dev/reference/apis/js-apis-call.md b/en/application-dev/reference/apis/js-apis-call.md
index ab561f552758ed5af3c79bc2c4406d84ceb56f2b..a04f49f6d46bd886af5b23c01e65ce7d0b689e85 100644
--- a/en/application-dev/reference/apis/js-apis-call.md
+++ b/en/application-dev/reference/apis/js-apis-call.md
@@ -403,7 +403,7 @@ A formatted phone number is a standard numeric string, for example, 555 0100.
**Example**
```js
-call.formatPhoneNumber("138xxxxxxxx",{
+call.formatPhoneNumber("138xxxxxxxx", {
countryCode: "CN"
}, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
@@ -796,7 +796,7 @@ call.reject(rejectMessageOptions, (err, data) => {
## call.reject7+
-reject(callId: number, callback: AsyncCallback):
+reject(callId: number, callback: AsyncCallback\): void
Rejects a call based on the specified call ID. This API uses an asynchronous callback to return the result.
@@ -811,16 +811,11 @@ This is a system API.
| callId | number | Yes | Call ID. You can obtain the value by subscribing to **callDetailsChange** events.|
| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
-**Return value**
-
-| Type | Description |
-| ------------------- | --------------------------- |
-| Promise<void> | Promise used to return the result.|
**Example**
```js
-call.reject(1, (error, data) => {
+call.reject(1, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
@@ -1621,8 +1616,8 @@ This is a system API.
**Example**
```js
-call.on('callDetailsChange', (err, data) => {
- console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
+call.on('callDetailsChange', data => {
+ console.log(`callback: data->${JSON.stringify(data)}`);
});
```
@@ -1646,8 +1641,8 @@ This is a system API.
**Example**
```js
-call.on('callEventChange', (err, data) => {
- console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
+call.on('callEventChange', data => {
+ console.log(`callback: data->${JSON.stringify(data)}`);
});
```
@@ -1671,8 +1666,8 @@ This is a system API.
**Example**
```js
-call.on('callDisconnectedCause', (err, data) => {
- console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
+call.on('callDisconnectedCause', data => {
+ console.log(`callback: data->${JSON.stringify(data)}`);
});
```
@@ -1696,8 +1691,8 @@ This is a system API.
**Example**
```js
-call.on('mmiCodeResult', (err, data) => {
- console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
+call.on('mmiCodeResult', data => {
+ console.log(`callback: data->${JSON.stringify(data)}`);
});
```
@@ -1721,8 +1716,8 @@ This is a system API.
**Example**
```js
-call.off('callDetailsChange', (err, data) => {
- console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
+call.off('callDetailsChange', data => {
+ console.log(`callback: data->${JSON.stringify(data)}`);
});
```
@@ -1746,8 +1741,8 @@ This is a system API.
**Example**
```js
-call.off('callEventChange', (err, data) => {
- console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
+call.off('callEventChange', data => {
+ console.log(`callback: data->${JSON.stringify(data)}`);
});
```
@@ -1771,8 +1766,8 @@ This is a system API.
**Example**
```js
-call.off('callDisconnectedCause', (err, data) => {
- console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
+call.off('callDisconnectedCause', data => {
+ console.log(`callback: data->${JSON.stringify(data)}`);
});
```
@@ -1796,8 +1791,8 @@ This is a system API.
**Example**
```js
-call.off('mmiCodeResult', (err, data) => {
- console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
+call.off('mmiCodeResult', data => {
+ console.log(`callback: data->${JSON.stringify(data)}`);
});
```
@@ -2386,7 +2381,7 @@ This is a system API.
let audioDeviceOptions={
bluetoothAddress: "IEEE 802-2014"
}
-call.setAudioDevice(1, audioDeviceOptions, (err, value) => {
+call.setAudioDevice(1, audioDeviceOptions, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
diff --git a/en/application-dev/reference/apis/js-apis-camera.md b/en/application-dev/reference/apis/js-apis-camera.md
index 5d57d317cb2a4ae2fa0e7ba29e61a23d95c8dbd1..cc34ebefa765c63b14d0bf65e1d8d26ebe64e4e1 100644
--- a/en/application-dev/reference/apis/js-apis-camera.md
+++ b/en/application-dev/reference/apis/js-apis-camera.md
@@ -20,9 +20,9 @@ Obtains a **CameraManager** instance. This API uses an asynchronous callback to
**Parameters**
-| Name | Type | Mandatory| Description |
-| -------- | ----------------------------------------------- | ---- | ---------------------------------- |
-| context | Context | Yes | Application context. |
+| Name | Type | Mandatory| Description |
+| -------- | ----------------------------------------------- | ---- | ---------------------------- |
+| context | [Context](../../ability/context-userguide.md) | Yes | Application context. |
| callback | AsyncCallback<[CameraManager](#cameramanager)\> | Yes | Callback used to return the **CameraManager** instance.|
**Example**
@@ -30,7 +30,7 @@ Obtains a **CameraManager** instance. This API uses an asynchronous callback to
```js
camera.getCameraManager(context, (err, cameraManager) => {
if (err) {
- console.error('Failed to get the CameraManager instance ${err.message}');
+ console.error(`Failed to get the CameraManager instance ${err.message}`);
return;
}
console.log('Callback returned with the CameraManager instance');
@@ -49,12 +49,12 @@ Obtains a **CameraManager** instance. This API uses a promise to return the resu
| Name | Type | Mandatory| Description |
| ------- | ------- | ---- | ------------ |
-| context | Context | Yes | Application context.|
+| context | [Context](../../ability/context-userguide.md) | Yes | Application context.|
**Return value**
-| Type | Description |
-| ----------------------------------------- | ----------------------------------------- |
+| Type | Description |
+| ----------------------------------------- | ----------------------------------- |
| Promise<[CameraManager](#cameramanager)\> | Promise used to return the **CameraManager** instance.|
**Example**
@@ -78,876 +78,884 @@ Enumerates the camera statuses.
| CAMERA_STATUS_AVAILABLE | 2 | The camera is available. |
| CAMERA_STATUS_UNAVAILABLE | 3 | The camera is unavailable.|
+## Profile
-## CameraPosition
-
-Enumerates the camera positions.
+Defines the camera profile.
**System capability**: SystemCapability.Multimedia.Camera.Core
-| Name | Value | Description |
-| --------------------------- | ---- | ---------------- |
-| CAMERA_POSITION_UNSPECIFIED | 0 | Unspecified position.|
-| CAMERA_POSITION_BACK | 1 | Rear camera. |
-| CAMERA_POSITION_FRONT | 2 | Front camera. |
+| Name | Type | Read Only| Description |
+| -------- | ----------------------------- |---- | ------------- |
+| format | [CameraFormat](#cameraformat) | Yes | Output format. |
+| size | [Size](#size) | Yes | Resolution. |
-## CameraType
+## FrameRateRange
-Enumerates the camera types.
+Defines the frame rate range.
**System capability**: SystemCapability.Multimedia.Camera.Core
-| Name | Value | Description |
-| ----------------------- | ---- | ---------------- |
-| CAMERA_TYPE_UNSPECIFIED | 0 | Unspecified camera type.|
-| CAMERA_TYPE_WIDE_ANGLE | 1 | Wide camera. |
-| CAMERA_TYPE_ULTRA_WIDE | 2 | Ultra wide camera. |
-| CAMERA_TYPE_TELEPHOTO | 3 | Telephoto camera. |
-| CAMERA_TYPE_TRUE_DEPTH | 4 | Camera with depth of field information. |
-
+| Name | Type | Read Only| Description |
+| -------- | ----------------------------- |---- | ------------- |
+| min | number | Yes | Minimum frame rate. |
+| max | number | Yes | Maximum frame rate. |
-## ConnectionType
+## VideoProfile
-Enumerates the camera connection types.
+Defines the video profile.
**System capability**: SystemCapability.Multimedia.Camera.Core
-| Name | Value | Description |
-| ---------------------------- | ---- | ------------- |
-| CAMERA_CONNECTION_BUILT_IN | 0 | Built-in camera. |
-| CAMERA_CONNECTION_USB_PLUGIN | 1 | Camera connected using USB.|
-| CAMERA_CONNECTION_REMOTE | 2 | Remote camera. |
+| Name | Type | Read Only| Description |
+| ------------------------- | ----------------------------------------- | --- |----------- |
+| frameRateRange | [FrameRateRange](#frameraterange) | Yes | Frame rate range. |
-## Size
+## CameraOutputCapability
-Defines the image size that can be used in previewing, photographing, and video recording.
+Defines the camera output capability.
**System capability**: SystemCapability.Multimedia.Camera.Core
-| Name | Type | Readable| Writable| Description |
-| ------ | ------ | ---- | ---- | ------------ |
-| height | string | Yes | Yes | Image height.|
-| width | number | Yes | Yes | Image width.|
+| Name | Type | Read Only| Description |
+| ----------------------------- | -------------------------------------------------- | --- |------------------- |
+| previewProfiles | Array<[Profile](#profile)\> | Yes | Supported preview profiles. |
+| photoProfiles | Array<[Profile](#profile)\> | Yes | Supported shooting profiles. |
+| videoProfiles | Array<[VideoProfile](#videoprofile)\> | Yes | Supported video recording profiles. |
+| supportedMetadataObjectTypes | Array<[MetadataObjectType](#metadataobjecttype)\> | Yes | Supported metadata object types.|
## CameraManager
Implements camera management. Before calling any API in **CameraManager**, you must use **getCameraManager** to obtain a **CameraManager** instance.
-### getCameras
+### getSupportedCameras
-getCameras(callback: AsyncCallback\>): void
+getSupportedCameras(callback: AsyncCallback\>): void
-Obtains all cameras supported by the device. This API uses an asynchronous callback to return the array of supported cameras.
+Obtains supported cameras. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| -------- | ----------------------------------------- | ---- | ------------------------------------ |
-| callback | AsyncCallback\> | Yes | Callback used to return the array of supported cameras.|
+| Name | Type | Mandatory| Description |
+| -------- | ----------------------------------------------------- | ---- | ------------------------------- |
+| callback | AsyncCallback\> | Yes | Callback used to return the array of supported cameras.|
**Example**
```js
-cameraManager.getCameras((err, cameras) => {
+cameraManager.getSupportedCameras((err, cameras) => {
if (err) {
- console.error('Failed to get the cameras. ${err.message}');
+ console.error(`Failed to get the cameras. ${err.message}`);
return;
}
- console.log('Callback returned with an array of supported cameras: ' + cameras.length);
+ console.log(`Callback returned with an array of supported cameras: ${cameras.length}`);
})
```
-### getCameras
+### getSupportedCameras
-getCameras(): Promise\>
+getSupportedCameras(): Promise\>
-Obtains all cameras supported by the device. This API uses a promise to return the array of supported cameras.
+Obtains supported cameras. This API uses a promise to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Return value**
-| Type | Description |
-| ----------------------------------- | ----------------------------- |
-| Promise\> | Promise used to return the array of supported cameras.|
+| Type | Description |
+| ----------------------------------------------- | ------------------------- |
+| Promise\> | Promise used to return the array of supported cameras.|
**Example**
```js
-cameraManager.getCameras().then((cameraArray) => {
- console.log('Promise returned with an array of supported cameras: ' + cameraArray.length);
+cameraManager.getSupportedCameras().then((cameraArray) => {
+ console.log(`Promise returned with an array of supported cameras: ${cameraArray.length}`);
})
```
-### createCameraInput
-
-createCameraInput(cameraId: string, callback: AsyncCallback): void
+### getSupportedOutputCapability
-Creates a **CameraInput** instance with the specified camera ID. This API uses an asynchronous callback to return the result.
+getSupportedOutputCapability(camera:CameraDevice, callback: AsyncCallback): void
-**Required permissions**: ohos.permission.CAMERA
+Obtains the output capability supported by a camera. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| -------- | ------------------------------------------- | ---- | ----------------------------------- |
-| cameraId | string | Yes | ID of the target camera. |
-| callback | AsyncCallback<[CameraInput](#camerainput)\> | Yes | Callback used to return the **CameraInput** instance.|
+| Name | Type | Mandatory| Description |
+| ------------ |--------------------------------------------------------------- | -- | -------------------------- |
+| CameraDevice | [CameraDevice](#cameradevice) | Yes| Camera device. |
+| callback | AsyncCallback<[CameraOutputCapability](#cameraoutputcapability)\> | Yes| Callback used to return the output capability.|
**Example**
```js
-cameraManager.createCameraInput(cameraId, (err, cameraInput) => {
+cameraManager.getSupportedOutputCapability(cameradevice, (err, cameras) => {
if (err) {
- console.error('Failed to create the CameraInput instance. ${err.message}');
+ console.error(`Failed to get the cameras. ${err.message}`);
return;
}
- console.log('Callback returned with the CameraInput instance.');
+ console.log('Callback returned with an array of supported outputCapability');
})
```
-### createCameraInput
-
-createCameraInput(cameraId: string): Promise
+### getSupportedOutputCapability
-Creates a **CameraInput** instance with the specified camera ID. This API uses a promise to return the result.
+getSupportedOutputCapability(camera:CameraDevice): Promise
-**Required permissions**: ohos.permission.CAMERA
+Obtains the output capability supported by a camera. This API uses a promise to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| -------- | ------ | ---- | ------------ |
-| cameraId | string | Yes | ID of the target camera.|
+| Name | Type | Mandatory | Description |
+| -------- | --------------------------------- | ---- | ---------- |
+| camera | [CameraDevice](#cameradevice) | Yes | Camera device. |
**Return value**
-| Type | Description |
-| ------------------------------------- | ---------------------------------------- |
-| Promise<[CameraInput](#camerainput)\> | Promise used to return the **CameraInput** instance.|
+| Type | Description |
+| -------------------------------------------------------------- | ----------------------------- |
+| Promise<[CameraOutputCapability](#cameraoutputcapability)\> | Promise used to return the output capability.|
**Example**
```js
-cameraManager.createCameraInput(cameraId).then((cameraInput) => {
- console.log('Promise returned with the CameraInput instance');
+cameraManager.getSupportedOutputCapability(cameradevice).then((cameraoutputcapability) => {
+ console.log('Promise returned with an array of supported outputCapability');
})
```
-### createCameraInput
+### isCameraMuted
-createCameraInput(position: CameraPosition, type: CameraType, callback: AsyncCallback): void
+isCameraMuted(): boolean
-Creates a **CameraInput** instance with the specified camera position and type. This API uses an asynchronous callback to return the result.
+Checks whether the camera is muted.
-**Required permissions**: ohos.permission.CAMERA
+Before calling the API, ensure that the camera can be muted. You can use [isCameraMuteSupported](#iscameramutesupported) to check whether the camera can be muted.
**System capability**: SystemCapability.Multimedia.Camera.Core
-**Parameters**
+**Return value**
-| Name | Type | Mandatory| Description |
-| -------- | ------------------------------------------- | ---- | ----------------------------------- |
-| position | [CameraPosition](#cameraposition) | Yes | Camera position. |
-| type | [CameraType](#cameratype) | Yes | Camera type. |
-| callback | AsyncCallback<[CameraInput](#camerainput)\> | Yes | Callback used to return the **CameraInput** instance.|
+| Type | Description |
+| ---------- | -------------------------------------------- |
+| boolean | Returns **true** if the camera is muted; returns **false** otherwise.|
**Example**
```js
-cameraManager.createCameraInput(camera.CameraPosition.CAMERA_POSITION_BACK, camera.CameraType.CAMERA_TYPE_UNSPECIFIED, (err, cameraInput) => {
- if (err) {
- console.error('Failed to create the CameraInput instance. ${err.message}');
- return;
- }
- console.log('Callback returned with the CameraInput instance');
-})
+let ismuted = await cameraManager.isCameraMuted();
```
-### createCameraInput
-
-createCameraInput(position: CameraPosition, type: CameraType): Promise
+### isCameraMuteSupported
-Creates a **CameraInput** instance with the specified camera position and type. This API uses a promise to return the result.
+isCameraMuteSupported(): boolean
-**Required permissions**: ohos.permission.CAMERA
+Checks whether the camera can be muted.
**System capability**: SystemCapability.Multimedia.Camera.Core
-**Parameters**
-
-| Name | Type | Mandatory| Description |
-| -------- | --------------------------------- | ---- | ---------- |
-| position | [CameraPosition](#cameraposition) | Yes | Camera position.|
-| type | [CameraType](#cameratype) | Yes | Camera type.|
-
**Return value**
-| Type | Description |
-| ------------------------------------- | ---------------------------------------- |
-| Promise<[CameraInput](#camerainput)\> | Promise used to return the **CameraInput** instance.|
+| Type | Description |
+| ---------- | ----------------------------- |
+| boolean | Returns **true** if the camera can be muted; returns **false** otherwise.|
**Example**
```js
-cameraManager.createCameraInput(camera.CameraPosition.CAMERA_POSITION_BACK, camera.CameraType.CAMERA_TYPE_UNSPECIFIED).then((cameraInput) => {
- console.log('Promise returned with the CameraInput instance.');
-})
+let ismutesuppotred = await cameraManager.isCameraMuteSupported();
```
-### on('cameraStatus')
+### muteCamera
-on(type: 'cameraStatus', callback: AsyncCallback): void
+muteCamera(mute: boolean): void
-Listens for camera status changes. This API uses an asynchronous callback to return the result.
+Mutes or unmutes the camera.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| :------- | :---------------------------------------------------- | :--- | :--------------------------------------------------- |
-| type | string | Yes | Event type. The value is fixed at **`cameraStatus`**, indicating the camera status change event.|
-| callback | AsyncCallback<[CameraStatusInfo](#camerastatusinfo)\> | Yes | Callback used to return the camera status change. |
-
-**Example**
-
-```js
-cameraManager.on('cameraStatus', (err, cameraStatusInfo) => {
- if (err) {
- console.error('Failed to get cameraStatus callback. ${err.message}');
- return;
- }
- console.log('camera : ' + cameraStatusInfo.camera.cameraId);
- console.log('status: ' + cameraStatusInfo.status);
-})
-```
-
-## Camera
-
-After **[camera.getCameraManager](#cameragetcameramanager)** is called, a camera instance is returned, with camera-related metadata such as **cameraId**, **cameraPosition**, **cameraType**, and **connectionType**.
-
-**System capability**: SystemCapability.Multimedia.Camera.Core
-
-| Name | Type | Read only| Description |
-| -------------- | --------------------------------- | ---- | -------------- |
-| cameraId | string | Yes | Camera ID. |
-| cameraPosition | [CameraPosition](#cameraposition) | Yes | Camera position. |
-| cameraType | [CameraType](#cameratype) | Yes | Camera type. |
-| connectionType | [ConnectionType](#connectiontype) | Yes | Camera connection type.|
+| Name | Type | Mandatory | Description |
+| -------- | --------------------------------- | ---- | ---------- |
+| mute | boolean | Yes | Whether to mute the camera. The value **true** means to mute the camera, and **false** means the opposite. |
**Example**
```js
-async function getCameraInfo("cameraId") {
- var cameraManager = await camera.getCameraManager(context);
- var cameras = await cameraManager.getCameras();
- var cameraObj = cameras[0];
- var cameraId = cameraObj.cameraId;
- var cameraPosition = cameraObj.cameraPosition;
- var cameraType = cameraObj.cameraType;
- var connectionType = cameraObj.connectionType;
-}
+cameraManager.muteCamera(mute);
```
-## CameraStatusInfo
-
-Describes the camera status information.
-
-**System capability**: SystemCapability.Multimedia.Camera.Core
-
-| Name | Type | Description |
-| ------ | ----------------------------- | ---------- |
-| camera | [Camera](#camera) | Camera object.|
-| status | [CameraStatus](#camerastatus) | Camera status.|
-
-
-## CameraInput
+### createCameraInput
-Implements a **CameraInput** instance. Before calling any API in **CameraInput**, you must create a **CameraInput** instance.
+createCameraInput(camera: CameraDevice, callback: AsyncCallback): void
-### getCameraId
+Creates a **CameraInput** instance with the specified **CameraDevice** object. This API uses an asynchronous callback to return the result.
-getCameraId(callback: AsyncCallback\): void
+This is a system API.
-Obtains the camera ID based on which this **CameraInput** instance is created. This API uses an asynchronous callback to return the camera ID.
+**Required permissions**: ohos.permission.CAMERA
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| -------- | ---------------------- | ---- | -------------------------- |
-| callback | AsyncCallback | Yes | Callback used to return the camera ID.|
+| Name | Type | Mandatory| Description |
+| -------- | ------------------------------------------- | ---- | --------------------------------- |
+| camera | [CameraDevice](#cameradevice) | Yes | **CameraDevice** object. |
+| callback | AsyncCallback<[CameraInput](#camerainput)\> | Yes | Callback used to return the **CameraInput** instance. |
**Example**
```js
-cameraInput.getCameraId((err, cameraId) => {
+cameraManager.createCameraInput(camera, (err, cameraInput) => {
if (err) {
- console.error('Failed to get the camera ID. ${err.message}');
+ console.error(`Failed to create the CameraInput instance. ${err.message}`);
return;
}
- console.log('Callback returned with the camera ID: ' + cameraId);
+ console.log('Callback returned with the CameraInput instance.');
})
```
-### getCameraId
+### createCameraInput
+
+createCameraInput(camera: CameraDevice): Promise
+
+Creates a **CameraInput** instance with the specified **CameraDevice** object. This API uses a promise to return the result.
-getCameraId(): Promise
+This is a system API.
-Obtains the camera ID based on which this **CameraInput** instance is created. This API uses a promise to return the camera ID.
+**Required permissions**: ohos.permission.CAMERA
**System capability**: SystemCapability.Multimedia.Camera.Core
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| -------- | ----------------------------- | ---- | ---------- |
+| camera | [CameraDevice](#cameradevice) | Yes | **CameraDevice** object.|
+
**Return value**
-| Type | Description |
-| ---------------- | ----------------------------- |
-| Promise | Promise used to return the camera ID.|
+| Type | Description |
+| ------------------------------------- | ------------------------------------ |
+| Promise<[CameraInput](#camerainput)\> | Promise used to return the **CameraInput** instance.|
**Example**
```js
-cameraInput.getCameraId().then((cameraId) => {
- console.log('Promise returned with the camera ID:' + cameraId);
+cameraManager.createCameraInput(camera).then((cameraInput) => {
+ console.log('Promise returned with the CameraInput instance');
})
```
+### createCameraInput
-### hasFlash
+createCameraInput(position: CameraPosition, type: CameraType, callback: AsyncCallback): void
-hasFlash(callback: AsyncCallback): void
+Creates a **CameraInput** instance with the specified camera position and type. This API uses an asynchronous callback to return the result.
-Checks whether the device has flash. This API uses an asynchronous callback to return the result.
+This is a system API.
+
+**Required permissions**: ohos.permission.CAMERA
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| -------- | ----------------------- | ---- | -------------------------------------- |
-| callback | AsyncCallback | Yes | Callback used to return the flash support status. The value **true** means that the device has flash.|
+| Name | Type | Mandatory| Description |
+| -------- | ------------------------------------------- | ---- | --------------------------------- |
+| position | [CameraPosition](#cameraposition) | Yes | Camera position. |
+| type | [CameraType](#cameratype) | Yes | Camera type. |
+| callback | AsyncCallback<[CameraInput](#camerainput)\> | Yes | Callback used to return the **CameraInput** instance. |
**Example**
```js
-cameraInput.hasFlash((err, status) => {
+cameraManager.createCameraInput(camera.CameraPosition.CAMERA_POSITION_BACK, camera.CameraType.CAMERA_TYPE_UNSPECIFIED, (err, cameraInput) => {
if (err) {
- console.error('Failed to check whether the device has flash light. ${err.message}');
+ console.error(`Failed to create the CameraInput instance. ${err.message}`);
return;
}
- console.log('Callback returned with flash light support status: ' + status);
+ console.log('Callback returned with the CameraInput instance');
})
```
-### hasFlash
+### createCameraInput
-hasFlash(): Promise
+createCameraInput(position: CameraPosition, type:CameraType ): Promise
-Checks whether the device has flash. This API uses a promise to return the result.
+Creates a **CameraInput** instance with the specified camera position and type. This API uses a promise to return the result.
+
+This is a system API.
+
+**Required permissions**: ohos.permission.CAMERA
**System capability**: SystemCapability.Multimedia.Camera.Core
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| -------- | --------------------------------- | ---- | ------------ |
+| position | [CameraPosition](#cameraposition) | Yes | Camera position. |
+| type | [CameraType](#cameratype) | Yes | Camera type. |
+
**Return value**
-| Type | Description |
-| ----------------- | ------------------------------------------------------- |
-| Promise | Promise used to return the flash support status. The value **true** means that the device has flash.|
+| Type | Description |
+| ------------------------------------- | ------------------------------------ |
+| Promise<[CameraInput](#camerainput)\> | Promise used to return the **CameraInput** instance.|
**Example**
```js
-cameraInput.hasFlash().then((status) => {
- console.log('Promise returned with the flash light support status:' + status);
+cameraManager.createCameraInput(camera.CameraPosition.CAMERA_POSITION_BACK, camera.CameraType.CAMERA_TYPE_UNSPECIFIED).then((cameraInput) => {
+ console.log('Promise returned with the CameraInput instance');
})
```
-### isFlashModeSupported
+### createPreviewOutput
-isFlashModeSupported(flashMode: FlashMode, callback: AsyncCallback): void
+createPreviewOutput(profile: Profile, surfaceId: string, callback: AsyncCallback): void
-Checks whether a specified flash mode is supported. This API uses an asynchronous callback to return the result.
+Creates a **PreviewOutput** instance. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| --------- | ----------------------- | ---- | ---------------------------------------- |
-| flashMode | [FlashMode](#flashmode) | Yes | Flash mode. |
-| callback | AsyncCallback | Yes | Callback used to return the flash mode support status. The value **true** means that the flash mode is supported, and **false** means the opposite.|
+| Name | Type | Mandatory| Description |
+| -------- | ----------------------------------------------- | ---- | ------------------------------- |
+| profile | [Profile](#profile) | Yes | Supported preview profile. |
+| surfaceId| string | Yes | Surface ID, which is obtained from **[XComponent](../arkui-ts/ts-basic-components-xcomponent.md)** or **[ImageReceiver](js-apis-image.md#imagereceiver9)**.|
+| callback | AsyncCallback<[PreviewOutput](#previewoutput)\> | Yes | Callback used to return the **PreviewOutput** instance.|
**Example**
```js
-cameraInput.isFlashModeSupported(camera.FlashMode.FLASH_MODE_AUTO, (err, status) => {
+cameraManager.createPreviewOutput(profile, surfaceId, (err, previewoutput) => {
if (err) {
- console.error('Failed to check whether the flash mode is supported. ${err.message}');
+ console.error(`Failed to gcreate previewOutput. ${err.message}`);
return;
}
- console.log('Callback returned with the flash mode support status: ' + status);
+ console.log('Callback returned with previewOutput created.');
})
```
-### isFlashModeSupported
+### createPreviewOutput
-isFlashModeSupported(flashMode: FlashMode): Promise
+createPreviewOutput(profile: Profile, surfaceId: string): Promise
-Checks whether a specified flash mode is supported. This API uses a promise to return the result.
+Creates a **PreviewOutput** instance. This API uses a promise to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| --------- | ----------------------- | ---- | ---------------- |
-| flashMode | [FlashMode](#flashmode) | Yes | Flash mode.|
+| Name | Type | Mandatory| Description |
+| -------- | ---------------------------------| ---- | ----------------- |
+| profile | [Profile](#profile) | Yes | Supported preview profile. |
+| surfaceId| string | Yes | Surface ID, which is obtained from **[XComponent](../arkui-ts/ts-basic-components-xcomponent.md)** or **[ImageReceiver](js-apis-image.md#imagereceiver9)**.|
**Return value**
-| Type | Description |
-| ----------------- | ------------------------------------------------------------ |
-| Promise | Promise used to return the flash mode support status. The value **true** means that the flash mode is supported, and **false** means the opposite.|
+| Type | Description |
+| ---------------------------------------- | ---------------------------------------- |
+| Promise<[PreviewOutput](#previewoutput)\> | Promise used to return the **PreviewOutput** instance. |
**Example**
```js
-cameraInput.isFlashModeSupported(camera.FlashMode.FLASH_MODE_AUTO).then((status) => {
- console.log('Promise returned with flash mode support status.' + status);
+cameraManager.createPreviewOutput(profile, surfaceId).then((previewoutput) => {
+ console.log('Promise returned with previewOutput created.');
})
```
-### setFlashMode
-
-setFlashMode(flashMode: FlashMode, callback: AsyncCallback): void
-
-Sets the flash mode. This API uses an asynchronous callback to return the result.
+### createPhotoOutput
-Before the setting, do the following checks:
+createPhotoOutput(profile: Profile, surfaceId: string, callback: AsyncCallback): void
-1. Use **[hasFlash](#hasflash)** to check whether the device has flash.
-2. Use **[isFlashModeSupported](#isflashmodesupported)** to check whether the device supports the flash mode.
+Creates a **PhotoOutput** instance. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| --------- | ----------------------- | ---- | ------------------------ |
-| flashMode | [FlashMode](#flashmode) | Yes | Flash mode. |
-| callback | AsyncCallback | Yes | Callback used to return the result.|
+| Name | Type | Mandatory| Description |
+| -------- | ------------------------------------------- | ---- | ----------------------------------- |
+| profile | [Profile](#profile) | Yes | Supported shooting profile. |
+| surfaceId| string | Yes | Surface ID, which is obtained from **[ImageReceiver](js-apis-image.md#imagereceiver9)**.|
+| callback | AsyncCallback<[PhotoOutput](#photooutput)\> | Yes | Callback used to return the **PhotoOutput** instance. |
**Example**
```js
-cameraInput.setFlashMode(camera.FlashMode.FLASH_MODE_AUTO, (err) => {
+cameraManager.createPhotoOutput(profile, surfaceId, (err, photooutput) => {
if (err) {
- console.error('Failed to set the flash mode ${err.message}');
+ console.error(`Failed to create photoOutput. ${err.message}`);
return;
}
- console.log('Callback returned with the successful execution of setFlashMode.');
+ console.log('Callback returned with photoOutput created.');
})
```
-### setFlashMode
-
-setFlashMode(flashMode: FlashMode): Promise
-
-Sets a flash mode. This API uses a promise to return the result.
+### createPhotoOutput
-Before the setting, do the following checks:
+createPhotoOutput(profile: Profile, surfaceId: string): Promise
-1. Use **[hasFlash](#hasflash)** to check whether the device has flash.
-2. Use **[isFlashModeSupported](#isflashmodesupported)** to check whether the device supports the flash mode.
+Creates a **PhotoOutput** instance. This API uses a promise to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| --------- | ----------------------- | ---- | ---------------- |
-| flashMode | [FlashMode](#flashmode) | Yes | Flash mode.|
+| Name | Type | Mandatory| Description |
+| -------- | ---------------------------------| ---- | ----------- |
+| profile | [Profile](#profile) | Yes | Supported shooting profile. |
+| surfaceId| string | Yes | Surface ID, which is obtained from **[ImageReceiver](js-apis-image.md#imagereceiver9)**.|
**Return value**
-| Type | Description |
-| -------------- | --------------------------- |
-| Promise| Promise used to return the result.|
+| Type | Description |
+| ------------------------------------- | -------------------------------------- |
+| Promise<[PhotoOutput](#photooutput)\> | Promise used to return the **PhotoOutput** instance. |
**Example**
```js
-cameraInput.setFlashMode(camera.FlashMode.FLASH_MODE_AUTO).then(() => {
- console.log('Promise returned with the successful execution of setFlashMode.');
+cameraManager.createPhotoOutput(profile, surfaceId).then((photooutput) => {
+ console.log('Promise returned with photoOutput created.');
})
```
-### getFlashMode
+### createVideoOutput
-getFlashMode(callback: AsyncCallback): void
+createVideoOutput(profile: VideoProfile, surfaceId: string, callback: AsyncCallback): void
-Obtains the flash mode in use. This API uses an asynchronous callback to return the result.
+Creates a **VideoOutput** instance. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| -------- | --------------------------------------- | ---- | ---------------------------------------- |
-| callback | AsyncCallback<[FlashMode](#flashmode)\> | Yes | Callback used to return the flash mode.|
+| Name | Type | Mandatory| Description |
+| -------- | ------------------------------------------- | ---- | ------------------------------ |
+| profile | [VideoProfile](#videoprofile) | Yes | Supported video recording profile. |
+| surfaceId| string | Yes | Surface ID, which is obtained from **[VideoRecorder](js-apis-media.md#videorecorder9)**.|
+| callback | AsyncCallback<[VideoOutput](#videooutput)\> | Yes | Callback used to return the **VideoOutput** instance.|
**Example**
```js
-cameraInput.getFlashMode((err, flashMode) => {
+cameraManager.createVideoOutput(profile, surfaceId, (err, videooutput) => {
if (err) {
- console.error('Failed to get the flash mode ${err.message}');
+ console.error(`Failed to create videoOutput. ${err.message}`);
return;
}
- console.log('Callback returned with current flash mode: ' + flashMode);
+ console.log('Callback returned with an array of supported outputCapability' );
})
```
-### getFlashMode
+### createVideoOutput
-getFlashMode(): Promise
+createVideoOutput(profile: VideoProfile, surfaceId: string): Promise
-Obtains the flash mode in use. This API uses a promise to return the result.
+Creates a **VideoOutput** instance. This API uses a promise to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| -------- | ---------------------------------| ---- | ---------- |
+| profile | [VideoProfile](#videoprofile) | Yes | Supported video recording profile. |
+| surfaceId| string | Yes | Surface ID, which is obtained from **[VideoRecorder](js-apis-media.md#videorecorder9)**.|
+
**Return value**
-| Type | Description |
-| --------------------------------- | --------------------------------------- |
-| Promise<[FlashMode](#flashmode)\> | Promise used to return the flash mode.|
+| Type | Description |
+| ------------------------------------- | -------------------------------------- |
+| Promise<[VideoOutput](#videooutput)\> | Promise used to return the **VideoOutput** instance. |
**Example**
```js
-cameraInput.getFlashMode().then((flashMode) => {
- console.log('Promise returned with current flash mode : ' + flashMode);
+cameraManager.createVideoOutput(profile, surfaceId).then((videooutput) => {
+ console.log('Promise returned with videoOutput created.');
})
```
-### isFocusModeSupported
+### createMetadataOutput
-isFocusModeSupported(afMode: FocusMode, callback: AsyncCallback): void
+createMetadataOutput(metadataObjectTypes:Array, callback: AsyncCallback): void
-Checks whether a specified focus mode is supported. This API uses an asynchronous callback to return the result.
+Creates a **MetadataOutput** instance. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| -------- | ----------------------- | ---- | -------------------------------------- |
-| afMode | [FocusMode](#focusmode) | Yes | Focus mode. |
-| callback | AsyncCallback | Yes | Callback used to return the focus mode support status. The value **true** means that the focus mode is supported, and **false** means the opposite.|
+| Name | Type | Mandatory| Description |
+| -------------------- | -------------------------------------------------- | --- | ---------------------------- |
+| metadataObjectTypes | Array<[MetadataObjectType](#metadataobjecttype)\> | Yes | Metadata object types. |
+| callback | AsyncCallback<[MetadataOutput](#metadataoutput)\> | Yes | Callback used to return the **MetadataOutput** instance. |
**Example**
```js
-cameraInput.isFocusModeSupported(camera.FocusMode.FOCUS_MODE_AUTO, (err, status) => {
+cameraManager.createMetadataOutput(metadataObjectTypes, (err, metadataoutput) => {
if (err) {
- console.error('Failed to check whether the focus mode is supported. ${err.message}');
+ console.error(`Failed to create metadataOutput. ${err.message}`);
return;
}
- console.log('Callback returned with the focus mode support status: ' + status);
+ console.log('Callback returned with metadataOutput created.');
})
```
-### isFocusModeSupported
+### createMetadataOutput
-isFocusModeSupported(afMode: FocusMode): Promise
+createMetadataOutput(metadataObjectTypes:Array): Promise
-Checks whether a specified focus mode is supported. This API uses a promise to return the result.
+Creates a **MetadataOutput** instance. This API uses a promise to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| ------ | ----------------------- | ---- | ---------------- |
-| afMode | [FocusMode](#focusmode) | Yes | Focus mode.|
+| Name | Type | Mandatory| Description |
+| -------------------- | -------------------------------------------------- | --- | -------------------- |
+| metadataObjectTypes | Array<[MetadataObjectType](#metadataobjecttype)\> | Yes | Metadata object types. |
**Return value**
-| Type | Description |
-| ----------------- | ----------------------------------------------------------- |
-| Promise | Promise used to return the focus mode support status. The value **true** means that the focus mode is supported, and **false** means the opposite.|
+| Type | Description |
+| ------------------------------------------ | ----------------------------------------- |
+| Promise<[MetadataOutput](#metadataoutput)\> | Promise used to return the **MetadataOutput** instance.|
**Example**
```js
-cameraInput.isFocusModeSupported(camera.FocusMode.FOCUS_MODE_AUTO).then((status) => {
- console.log('Promise returned with focus mode support status.' + status);
+cameraManager.createMetadataOutput().then((metadataoutput) => {
+ console.log('Promise returned with metadataOutput created.');
})
```
-### setFocusMode
-
-setFocusMode(afMode: FocusMode, callback: AsyncCallback): void
+### createCaptureSession
-Sets a focus mode. This API uses an asynchronous callback to return the result.
+createCaptureSession(callback: AsyncCallback): void
-Before the setting, use **[isFocusModeSupported](#isfocusmodesupported)** to check whether the focus mode is supported.
+Creates a **CaptureSession** instance. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| -------- | ----------------------- | ---- | ------------------------ |
-| afMode | [FocusMode](#focusmode) | Yes | Focus mode. |
-| callback | AsyncCallback | Yes | Callback used to return the result.|
+| Name | Type | Mandatory | Description |
+| -------------------- | ----------------------------------------- | ----------- | ---------------------------- |
+| callback | AsyncCallback<[CaptureSession](#capturesession)\> | Yes | Callback used to return the **CaptureSession** instance.|
**Example**
```js
-cameraInput.setFocusMode(camera.FocusMode.FOCUS_MODE_AUTO, (err) => {
+cameraManager.createCaptureSession((err, capturesession) => {
if (err) {
- console.error('Failed to set the focus mode ${err.message}');
+ console.error(`Failed to create captureSession. ${err.message}`);
return;
}
- console.log('Callback returned with the successful execution of setFocusMode.');
+ console.log('Callback returned with captureSession created.');
})
```
-### setFocusMode
-
-setFocusMode(afMode: FocusMode): Promise
+### createCaptureSession
-Sets a focus mode. This API uses a promise to return the result.
+createCaptureSession(): Promise
-Before the setting, use **[isFocusModeSupported](#isfocusmodesupported)** to check whether the focus mode is supported.
+Creates a **CaptureSession** instance. This API uses a promise to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
-**Parameters**
-
-| Name | Type | Mandatory| Description |
-| ------ | ----------------------- | ---- | ---------------- |
-| afMode | [FocusMode](#focusmode) | Yes | Focus mode.|
-
**Return value**
-| Type | Description |
-| -------------- | --------------------------- |
-| Promise| Promise used to return the result.|
+| Type | Description |
+| ------------------------------------------- | ---------------------------------------- |
+| Promise<[CaptureSession](#capturesession)\> | Promise used to return the **CaptureSession** instance.|
**Example**
```js
-cameraInput.setFocusMode(camera.FocusMode.FOCUS_MODE_AUTO).then(() => {
- console.log('Promise returned with the successful execution of setFocusMode.');
+cameraManager.createCaptureSession().then((capturesession) => {
+ console.log('Promise returned with captureSession created.');
})
```
-### getFocusMode
+### on('cameraStatus')
-getFocusMode(callback: AsyncCallback): void
+on(type: 'cameraStatus', callback: AsyncCallback): void
-Obtains the focus mode in use. This API uses an asynchronous callback to return the result.
+Listens for camera status changes. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| -------- | --------------------------------------- | ---- | -------------------------------------- |
-| callback | AsyncCallback<[FocusMode](#focusmode)\> | Yes | Callback used to return the focus mode.|
+| Name | Type | Mandatory| Description |
+| -------- | ----------------------------------------------------- | ---- | --------- |
+| type | string | Yes | Event type. The value is fixed at **'cameraStatus'**, indicating the camera status change event.|
+| callback | AsyncCallback<[CameraStatusInfo](#camerastatusinfo)\> | Yes | Callback used to return the camera status change. |
**Example**
```js
-cameraInput.getFocusMode((err, afMode) => {
+cameraManager.on('cameraStatus', (err, cameraStatusInfo) => {
if (err) {
- console.error('Failed to get the focus mode ${err.message}');
+ console.error(`Failed to get cameraStatus callback. ${err.message}`);
return;
}
- console.log('Callback returned with current focus mode: ' + afMode);
-})
-```
-
-### getFocusMode
-
-getFocusMode(): Promise
-
-Obtains the focus mode in use. This API uses a promise to return the result.
-
-**System capability**: SystemCapability.Multimedia.Camera.Core
-
-**Return value**
-
-| Type | Description |
-| ------------------- | ------------------------------------- |
-| Promise | Promise used to return the focus mode.|
-
-**Example**
-
-```js
-cameraInput.getFocusMode().then((afMode) => {
- console.log('Promise returned with current focus mode : ' + afMode);
+ console.log(`camera : ${cameraStatusInfo.camera.cameraId}`);
+ console.log(`status: ${cameraStatusInfo.status}`);
})
```
-### getZoomRatioRange
+### on('cameraMute')
-getZoomRatioRange\(callback: AsyncCallback\>\): void
+on(type: 'cameraMute', callback: AsyncCallback): void
-Obtains the zoom ratio range. This API uses an asynchronous callback to return the result.
+Listens for camera mute status changes. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| -------- | ------------------------------ | ---- | ------------------------ |
-| callback | AsyncCallback\> | Yes | Callback used to return an array containing the minimum and maximum zoom ratios.|
+| Name | Type | Mandatory| Description |
+| -------- | --------------- | ---- | --------- |
+| type | string | Yes | Event type. The value is fixed at **'cameraMute'**, indicating the camera mute status change event.|
+| callback | boolean | Yes | Callback used to return the camera mute status. |
**Example**
```js
-cameraInput.getZoomRatioRange((err, zoomRatioRange) => {
+cameraManager.on('cameraMute', (err, cameraStatusInfo) => {
if (err) {
- console.error('Failed to get the zoom ratio range. ${err.message}');
+ console.error(`Failed to get cameraMute callback. ${err.message}`);
return;
}
- console.log('Callback returned with zoom ratio range: ' + zoomRatioRange.length);
})
```
-### getZoomRatioRange
-
-getZoomRatioRange\(\): Promise\>
+## CameraStatusInfo
-Obtains the zoom ratio range. This API uses a promise to return the result.
+Describes the camera status information.
**System capability**: SystemCapability.Multimedia.Camera.Core
-**Return value**
-
-| Type | Description |
-| ------------------------ | ------------------------------------------- |
-| Promise\> | Promise used to return an array containing the minimum and maximum zoom ratios.|
+| Name | Type | Description |
+| ------ | ----------------------------- | ---------- |
+| camera | [CameraDevice](#cameradevice) | Camera object.|
+| status | [CameraStatus](#camerastatus) | Camera status.|
+
+## CameraPosition
+
+Enumerates the camera positions.
+
+**System capability**: SystemCapability.Multimedia.Camera.Core
+
+| Name | 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 capability**: SystemCapability.Multimedia.Camera.Core
+
+| Name | Value | Description |
+| ----------------------- | ---- | -------------- |
+| CAMERA_TYPE_UNSPECIFIED | 0 | Unspecified camera type. |
+| CAMERA_TYPE_WIDE_ANGLE | 1 | Wide camera. |
+| CAMERA_TYPE_ULTRA_WIDE | 2 | Ultra wide camera. |
+| CAMERA_TYPE_TELEPHOTO | 3 | Telephoto camera. |
+| CAMERA_TYPE_TRUE_DEPTH | 4 | Camera with depth of field information.|
+
+## ConnectionType
+
+Enumerates the camera connection types.
+
+**System capability**: SystemCapability.Multimedia.Camera.Core
+
+| Name | Value | Description |
+| ---------------------------- | ---- | ------------- |
+| CAMERA_CONNECTION_BUILT_IN | 0 | Built-in camera. |
+| CAMERA_CONNECTION_USB_PLUGIN | 1 | Camera connected using USB.|
+| CAMERA_CONNECTION_REMOTE | 2 | Remote camera.|
+
+## CameraDevice
+
+Defines the camera device information.
+
+**System capability**: SystemCapability.Multimedia.Camera.Core
+
+| Name | Type | Read Only| Description |
+| -------------- | --------------------------------- | ---- | ---------- |
+| cameraId | string | Yes | **CameraDevice** object.|
+| cameraPosition | [CameraPosition](#cameraposition) | Yes | Camera position. |
+| cameraType | [CameraType](#cameratype) | Yes | Camera type. |
+| connectionType | [ConnectionType](#connectiontype) | Yes | Camera connection type.|
**Example**
```js
-cameraInput.getZoomRatioRange().then((zoomRatioRange) => {
- console.log('Promise returned with zoom ratio range: ' + zoomRatioRange.length);
-})
+async function getCameraInfo("cameraId") {
+ let cameraManager = await camera.getCameraManager(context);
+ let cameras = await cameraManager.getSupportedCameras();
+ let cameraObj = cameras[0];
+ let cameraId = cameraObj.cameraId;
+ let cameraPosition = cameraObj.cameraPosition;
+ let cameraType = cameraObj.cameraType;
+ let connectionType = cameraObj.connectionType;
+}
```
-### setZoomRatio
+## Size
-setZoomRatio(zoomRatio: number, callback: AsyncCallback): void
+Enumerates the camera output capability.
-Sets a zoom ratio. This API uses an asynchronous callback to return the result.
+**System capability**: SystemCapability.Multimedia.Camera.Core
+
+| Name | Type | Readable| Writable| Description |
+| ------ | ------ | ---- | ---- | ------------ |
+| height | number | Yes | Yes | Image height, in pixels.|
+| width | number | Yes | Yes | Image width, in pixels.|
+
+## Point
+
+Enumerates the point coordinates, which are used for focus and exposure configuration.
+
+**System capability**: SystemCapability.Multimedia.Camera.Core
+
+| Name | Type | Mandatory | Description |
+| ------ | ------ | ---- | ------------ |
+| x | number | Yes | X coordinate of a point. |
+| y | number | Yes | Y coordinate of a point. |
+
+## CameraFormat
+
+Enumerates the camera output formats.
+
+**System capability**: SystemCapability.Multimedia.Camera.Core
+
+| Name | Default Value | Description |
+| ----------------------- | --------- | ------------ |
+| CAMERA_FORMAT_RGBA_8888 | 3 | RGB image. |
+| CAMERA_FORMAT_YUV_420_SP| 1003 | YUV 420 SP image. |
+| CAMERA_FORMAT_JPEG | 2000 | JPEG image. |
+
+## CameraInput
+
+Provides camera information used in **[CaptureSession](#capturesession)**.
+
+### open
+
+open\(callback: AsyncCallback\): void
+
+Opens this camera. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| --------- | -------------------- | ---- | ------------------------ |
-| zoomRatio | number | Yes | Zoom ratio. |
-| callback | AsyncCallback | Yes | Callback used to return the result.|
+| Name | Type | Mandatory| Description |
+| -------- | -------------------- | ---- | ------------------- |
+| callback | AsyncCallback | Yes | Callback used to return the result.|
**Example**
```js
-cameraInput.setZoomRatio(1, (err) => {
+cameraInput.open((err) => {
if (err) {
- console.error('Failed to set the zoom ratio value ${err.message}');
+ console.error(`Failed to open the camera. ${err.message}`);
return;
}
- console.log('Callback returned with the successful execution of setZoomRatio.');
+ console.log('Callback returned with camera opened.');
})
```
-### setZoomRatio
+### open
-setZoomRatio(zoomRatio: number): Promise
+open(): Promise
-Sets a zoom ratio. This API uses a promise to return the result.
+Opens this camera. This API uses a promise to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
-**Parameters**
-
-| Name | Type | Mandatory| Description |
-| --------- | ------ | ---- | ------------ |
-| zoomRatio | number | Yes | Zoom ratio.|
-
**Return value**
-| Type | Description |
-| -------------- | --------------------------- |
+| Type | Description |
+| -------------- | ----------------------- |
| Promise| Promise used to return the result.|
**Example**
```js
-cameraInput.setZoomRatio(1).then(() => {
- console.log('Promise returned with the successful execution of setZoomRatio.');
+cameraInput.open().then(() => {
+ console.log('Promise returned with camera opened.');
})
```
-### getZoomRatio
+### close
-getZoomRatio(callback: AsyncCallback): void
+close\(callback: AsyncCallback\): void
-Obtains the zoom ratio in use. This API uses an asynchronous callback to return the result.
+Closes this camera. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| -------- | ---------------------- | ---- | ------------------------ |
-| callback | AsyncCallback | Yes | Callback used to return the result.|
+| Name | Type | Mandatory| Description |
+| -------- | -------------------- | ---- | -------------------- |
+| callback | AsyncCallback | Yes | Callback used to return the result.|
**Example**
```js
-cameraInput.getZoomRatio((err, zoomRatio) => {
+cameraInput.close((err) => {
if (err) {
- console.error('Failed to get the zoom ratio ${err.message}');
+ console.error(`Failed to close the cameras. ${err.message}`);
return;
}
- console.log('Callback returned with current zoom ratio: ' + zoomRatio);
+ console.log('Callback returned with camera closed.');
})
```
-### getZoomRatio
+### close
-getZoomRatio(): Promise
+close(): Promise
-Obtains the zoom ratio in use. This API uses a promise to return the result.
+Closes this camera. This API uses a promise to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Return value**
-| Type | Description |
-| ---------------- | --------------------------- |
-| Promise | Promise used to return the zoom ratio.|
+| Type | Description |
+| -------------- | ----------------------- |
+| Promise| Promise used to return the result.|
**Example**
```js
-cameraInput.getZoomRatio().then((zoomRatio) => {
- console.log('Promise returned with current zoom ratio : ' + zoomRatio);
+cameraInput.close().then(() => {
+ console.log('Promise returned with camera closed.');
})
```
@@ -955,14 +963,14 @@ cameraInput.getZoomRatio().then((zoomRatio) => {
release\(callback: AsyncCallback\): void
-Releases this **CameraInput** instance. This API uses an asynchronous callback to return the result.
+Releases this camera. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| -------- | -------------------- | ---- | ------------------------ |
+| Name | Type | Mandatory| Description |
+| -------- | -------------------- | ---- | ------------------- |
| callback | AsyncCallback | Yes | Callback used to return the result.|
**Example**
@@ -970,7 +978,7 @@ Releases this **CameraInput** instance. This API uses an asynchronous callback t
```js
cameraInput.release((err) => {
if (err) {
- console.error('Failed to release the CameraInput instance ${err.message}');
+ console.error(`Failed to release the CameraInput instance ${err.message}`);
return;
}
console.log('Callback invoked to indicate that the CameraInput instance is released successfully.');
@@ -981,14 +989,14 @@ cameraInput.release((err) => {
release(): Promise
-Releases this **CameraInput** instance. This API uses a promise to return the result.
+Releases this camera. This API uses a promise to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Return value**
-| Type | Description |
-| -------------- | --------------------------- |
+| Type | Description |
+| -------------- | ----------------------- |
| Promise| Promise used to return the result.|
**Example**
@@ -999,32 +1007,9 @@ cameraInput.release().then(() => {
})
```
-### on('focusStateChange')
-
-on(type: 'focusStateChange', callback: AsyncCallback): void
-
-Listens for focus state changes. This API uses an asynchronous callback to return the result.
-
-**System capability**: SystemCapability.Multimedia.Camera.Core
-
-**Parameters**
-
-| Name | Type | Mandatory| Description |
-| :------- | :---------------------------------------- | :--- | :------------------------------------------------------- |
-| type | string | Yes | Event type. The value is fixed at **'focusStateChange'**, indicating the focus state change event.|
-| callback | AsyncCallback<[FocusState](#focusstate)\> | Yes | Callback used to return the focus state change. |
-
-**Example**
-
-```js
-cameraInput.on('focusStateChange', (focusState) => {
- console.log('Focus state : ' + focusState);
-})
-```
-
### on('error')
-on(type: 'error', callback: ErrorCallback): void
+on(type: 'error', camera:CameraDevice, callback: ErrorCallback): void
Listens for **CameraInput** errors. This API uses a callback to return the result.
@@ -1032,37 +1017,43 @@ Listens for **CameraInput** errors. This API uses a callback to return the resul
**Parameters**
-| Name | Type | Mandatory| Description |
-| :------- | :------------------------------- | :--- | :----------------------------------------------- |
+| Name | Type | Mandatory| Description |
+| -------- | -------------------------------- | --- | ------------------------------------------- |
| type | string | Yes | Event type. The value is fixed at **'error'**, indicating the camera input error event.|
-| callback | ErrorCallback<[CameraInputError](#camerainputerror)\> | Yes | Callback used to return the result. |
+| camera | [CameraDevice](#cameradevice) | Yes | **CameraDevice** object.|
+| callback | ErrorCallback<[CameraInputError](#camerainputerror)\> | Yes | Callback used to return the result. |
**Example**
```js
-cameraInput.on('error', (cameraInputError) => {
- console.log('Camera input error code: ' + cameraInputError.code);
+cameraInput.on('error', camera, (cameraInputError) => {
+ console.log(`Camera input error code: ${cameraInputError.code}`);
})
```
-## CameraInputErrorCode
+## CameraInputErrorCode
-Enumerates the error codes used in a **CameraInput** instance.
+Enumerates the error codes used for camera input.
**System capability**: SystemCapability.Multimedia.Camera.Core
-| Name | Value | Description |
-| ------------- | ---- | ---------- |
-| ERROR_UNKNOWN | -1 | Unknown error.|
+| Name | Value | Description |
+| ------------------------- | ---- | ---------- |
+| ERROR_UNKNOWN | -1 | Unknown error.|
+| ERROR_NO_PERMISSION | 0 | You do not have the required permission.|
+| ERROR_DEVICE_PREEMPTED | 1 | The camera is preempted.|
+| ERROR_DEVICE_DISCONNECTED | 2 | The camera is disconnected.|
+| ERROR_DEVICE_IN_USE | 3 | The camera is in use.|
+| ERROR_DRIVER_ERROR | 4 | Driver error. |
-## CameraInputError
+## CameraInputError
-Defines a **CameraInput** error.
+Defines an error object used for **[CameraInput](#camerainput)**.
**System capability**: SystemCapability.Multimedia.Camera.Core
-| Name| Type | Description |
-| ---- | ------------------------------------------- | -------------------------- |
+| Name| Type | Description |
+| ---- | --------------------------------------------- | --------------------- |
| code | [CameraInputErrorCode](#camerainputerrorcode) | **CameraInput** error code.|
@@ -1072,25 +1063,37 @@ Enumerates the flash modes.
**System capability**: SystemCapability.Multimedia.Camera.Core
-| Name | Value | Description |
-| ---------------------- | ---- | ------------ |
+| Name | Value | Description |
+| ---------------------- | ---- | ---------- |
| FLASH_MODE_CLOSE | 0 | The flash is off.|
| FLASH_MODE_OPEN | 1 | The flash is on.|
| FLASH_MODE_AUTO | 2 | The flash mode is auto, indicating that the flash fires automatically depending on the shooting conditions.|
| FLASH_MODE_ALWAYS_OPEN | 3 | The flash is steady on.|
-## FocusMode
+## ExposureMode
+
+Enumerates the exposure modes.
+
+**System capability**: SystemCapability.Multimedia.Camera.Core
+
+| Name | Value | Description |
+| ----------------------------- | ---- | ----------- |
+| EXPOSURE_MODE_LOCKED | 0 | Exposure locked.|
+| EXPOSURE_MODE_AUTO | 1 | Auto exposure.|
+| EXPOSURE_MODE_CONTINUOUS_AUTO | 2 | Continuous auto exposure.|
+
+ ## FocusMode
Enumerates the focus modes.
**System capability**: SystemCapability.Multimedia.Camera.Core
-| Name | Value | Description |
-| -------------------------- | ---- | ------------------ |
+| Name | Value | Description |
+| -------------------------- | ---- | ------------ |
| FOCUS_MODE_MANUAL | 0 | Manual focus. |
| FOCUS_MODE_CONTINUOUS_AUTO | 1 | Continuous auto focus.|
| FOCUS_MODE_AUTO | 2 | Auto focus. |
-| FOCUS_MODE_LOCKED | 3 | Focus locked. |
+| FOCUS_MODE_LOCKED | 3 | Focus locked. |
## FocusState
@@ -1098,70 +1101,29 @@ Enumerates the focus states.
**System capability**: SystemCapability.Multimedia.Camera.Core
-| Name | Value | Description |
-| --------------------- | ---- | ------------ |
-| FOCUS_STATE_SCAN | 0 | Focusing. |
-| FOCUS_STATE_FOCUSED | 1 | Focused.|
+| Name | Value | Description |
+| --------------------- | ---- | --------- |
+| FOCUS_STATE_SCAN | 0 | Focusing. |
+| FOCUS_STATE_FOCUSED | 1 | Focused. |
| FOCUS_STATE_UNFOCUSED | 2 | Unfocused.|
-## camera.createCaptureSession
-
-createCaptureSession\(context: Context, callback: AsyncCallback\): void
-
-Creates a **CaptureSession** instance. This API uses an asynchronous callback to return the result.
-
-**System capability**: SystemCapability.Multimedia.Camera.Core
-
-**Parameters**
-
-| Name | Type | Mandatory| Description |
-| -------- | ------------------------------------------------- | ---- | -------------------------------------- |
-| context | Context | Yes | Application context. |
-| callback | AsyncCallback<[CaptureSession](#capturesession)\> | Yes | Callback used to return the **CaptureSession** instance.|
-
-**Example**
-
-```js
-camera.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);
-});
-```
-
-## camera.createCaptureSession
+## VideoStabilizationMode
-createCaptureSession(context: Context\): Promise;
-
-Creates a **CaptureSession** instance. This API uses a promise to return the result.
+Enumerates the video stabilization modes.
**System capability**: SystemCapability.Multimedia.Camera.Core
-**Parameters**
-
-| Name | Type | Mandatory| Description |
-| ------- | ------- | ---- | ------------ |
-| context | Context | Yes | Application context.|
-
-**Return value**
-
-| Type | Description |
-| ------------------------------------------- | ----------------------------------------- |
-| Promise<[CaptureSession](#capturesession)\> | Promise used to return the **CaptureSession** instance.|
-
-**Example**
-
-```js
-camera.createCaptureSession(context).then((captureSession) => {
- console.log('Promise returned with the CaptureSession instance');
-})
-```
+| Name | Value | Description |
+| --------- | ---- | ------------ |
+| OFF | 0 | Video stabilization is disabled. |
+| LOW | 1 | The basic video stabilization algorithm is used. |
+| MIDDLE | 2 | A video stabilization algorithm with a stabilization effect better than that of the **LOW** type is used. |
+| HIGH | 3 | A video stabilization algorithm with a stabilization effect better than that of the **MIDDLE** type is used. |
+| AUTO | 4 | Automatic video stabilization is used. |
## CaptureSession
-Implements a shooting session.
+Implements a shooting session, which saves all **[CameraInput](#camerainput)** and **[CameraOutput](#cameraoutput)** instances required to run the camera and requests the camera to complete shooting or video recording.
### beginConfig
@@ -1173,8 +1135,8 @@ Starts configuration for this **CaptureSession** instance. This API uses an asyn
**Parameters**
-| Name | Type | Mandatory| Description |
-| -------- | -------------------- | ---- | ------------------------ |
+| Name | Type | Mandatory| Description |
+| -------- | -------------------- | ---- | ------------------- |
| callback | AsyncCallback | Yes | Callback used to return the result.|
**Example**
@@ -1182,7 +1144,7 @@ Starts configuration for this **CaptureSession** instance. This API uses an asyn
```js
captureSession.beginConfig((err) => {
if (err) {
- console.error('Failed to start the configuration. ${err.message}');
+ console.error(`Failed to start the configuration. ${err.message}`);
return;
}
console.log('Callback invoked to indicate the begin config success.');
@@ -1199,8 +1161,8 @@ Starts configuration for this **CaptureSession** instance. This API uses a promi
**Return value**
-| Type | Description |
-| -------------- | --------------------------- |
+| Type | Description |
+| -------------- | ------------------------ |
| Promise| Promise used to return the result.|
@@ -1222,8 +1184,8 @@ Commits the configuration for this **CaptureSession** instance. This API uses an
**Parameters**
-| Name | Type | Mandatory| Description |
-| -------- | -------------------- | ---- | ------------------------ |
+| Name | Type | Mandatory| Description |
+| -------- | -------------------- | ---- | -------------------- |
| callback | AsyncCallback | Yes | Callback used to return the result.|
**Example**
@@ -1231,7 +1193,7 @@ Commits the configuration for this **CaptureSession** instance. This API uses an
```js
captureSession.commitConfig((err) => {
if (err) {
- console.error('Failed to commit the configuration. ${err.message}');
+ console.error(`Failed to commit the configuration. ${err.message}`);
return;
}
console.log('Callback invoked to indicate the commit config success.');
@@ -1248,8 +1210,8 @@ Commits the configuration for this **CaptureSession** instance. This API uses a
**Return value**
-| Type | Description |
-| -------------- | --------------------------- |
+| Type | Description |
+| -------------- | ------------------------ |
| Promise| Promise used to return the result.|
**Example**
@@ -1264,14 +1226,14 @@ captureSession.commitConfig().then(() => {
addInput\(cameraInput: CameraInput, callback: AsyncCallback\): void
-Adds a **CameraInput** instance to this **CaptureSession** instance. This API uses an asynchronous callback to return the result.
+Adds a **[CameraInput](#camerainput)** instance to this **CaptureSession**. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| ----------- | --------------------------- | ---- | --------------------------- |
+| Name | Type | Mandatory| Description |
+| ----------- | --------------------------- | ---- | ------------------------ |
| cameraInput | [CameraInput](#camerainput) | Yes | **CameraInput** instance to add.|
| callback | AsyncCallback | Yes | Callback used to return the result. |
@@ -1280,7 +1242,7 @@ Adds a **CameraInput** instance to this **CaptureSession** instance. This API us
```js
captureSession.addInput(cameraInput, (err) => {
if (err) {
- console.error('Failed to add the CameraInput instance. ${err.message}');
+ console.error(`Failed to add the CameraInput instance. ${err.message}`);
return;
}
console.log('Callback invoked to indicate that the CameraInput instance is added.');
@@ -1291,20 +1253,20 @@ captureSession.addInput(cameraInput, (err) => {
addInput\(cameraInput: CameraInput\): Promise
-Adds a **CameraInput** instance to this **CaptureSession** instance. This API uses a promise to return the result.
+Adds a **[CameraInput](#camerainput)** instance to this **CaptureSession**. This API uses a promise to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| ----------- | --------------------------- | ---- | --------------------------- |
+| Name | Type | Mandatory| Description |
+| ----------- | --------------------------- | ---- | ------------------------ |
| cameraInput | [CameraInput](#camerainput) | Yes | **CameraInput** instance to add.|
**Return value**
-| Type | Description |
-| -------------- | --------------------------- |
+| Type | Description |
+| -------------- | ------------------------ |
| Promise| Promise used to return the result.|
**Example**
@@ -1315,969 +1277,2262 @@ captureSession.addInput(cameraInput).then(() => {
})
```
-### addOutput
+### removeInput
-addOutput\(previewOutput: PreviewOutput, callback: AsyncCallback\): void
+removeInput\(cameraInput: CameraInput, callback: AsyncCallback\): void
-Adds a **PreviewOutput** instance to this **CaptureSession** instance. This API uses an asynchronous callback to return the result.
+Removes a **[CameraInput](#camerainput)** instance from this **CaptureSession**. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| ------------- | ------------------------------- | ---- | ----------------------------- |
-| previewOutput | [PreviewOutput](#previewoutput) | Yes | **PreviewOutput** instance to add.|
-| callback | AsyncCallback | Yes | Callback used to return the result. |
+| Name | Type | Mandatory| Description |
+| ----------- | --------------------------- | ---- | ------------------------ |
+| cameraInput | [CameraInput](#camerainput) | Yes | **CameraInput** instance to remove.|
+| callback | AsyncCallback | Yes | Callback used to return the result. |
**Example**
```js
-captureSession.addOutput(previewOutput, (err) => {
+captureSession.removeInput(cameraInput, (err) => {
if (err) {
- console.error('Failed to add the PreviewOutput instance ${err.message}');
+ console.error(`Failed to remove the CameraInput instance. ${err.message}`);
return;
}
- console.log('Callback invoked to indicate that the PreviewOutput instance is added.');
+ console.log('Callback invoked to indicate that the cameraInput instance is removed.');
});
```
-### addOutput
+### removeInput
-addOutput\(previewOutput: PreviewOutput\): Promise
+removeInput\(cameraInput: CameraInput\): Promise
-Adds a **PreviewOutput** instance to this **CaptureSession** instance. This API uses a promise to return the result.
+Removes a **[CameraInput](#camerainput)** instance from this **CaptureSession**. This API uses a promise to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| ------------- | ------------------------------- | ---- | ----------------------------- |
-| previewOutput | [PreviewOutput](#previewoutput) | Yes | **PreviewOutput** instance to add.|
+| Name | Type | Mandatory| Description |
+| ----------- | --------------------------- | ---- | ------------------------ |
+| cameraInput | [CameraInput](#camerainput) | Yes | **CameraInput** instance to remove.|
**Return value**
-| Type | Description |
-| -------------- | --------------------------- |
-| Promise| Promise used to return the result.|
+| Type | Description |
+| -------------- | ------------------------- |
+| Promise\ | Promise used to return the result.|
**Example**
```js
-captureSession.addOutput(previewOutput).then(() => {
- console.log('Promise used to indicate that the PreviewOutput instance is added.');
+captureSession.removeInput(cameraInput).then(() => {
+ console.log('Promise returned to indicate that the cameraInput instance is removed.');
})
```
### addOutput
-addOutput\(photoOutput: PhotoOutput, callback: AsyncCallback\): void
+addOutput\(cameraOutput: CameraOutput, callback: AsyncCallback\): void
-Adds a **PhotoOutput** instance to this **CaptureSession** instance. This API uses an asynchronous callback to return the result.
+Adds a **[CameraOutput](#cameraoutput)** instance to this **CaptureSession**. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| ----------- | --------------------------- | ---- | --------------------------- |
-| photoOutput | [PhotoOutput](#photooutput) | Yes | **PhotoOutput** instance to add.|
-| callback | AsyncCallback | Yes | Callback used to return the result. |
+| Name | Type | Mandatory| Description |
+| ------------- | ------------------------------- | ---- | ------------------------ |
+| cameraOutput | [CameraOutput](#cameraoutput) | Yes | **CameraOutput** instance to add.|
+| callback | AsyncCallback | Yes | Callback used to return the result. |
**Example**
```js
-captureSession.addOutput(photoOutput, (err) => {
+captureSession.addOutput(cameraOutput, (err) => {
if (err) {
- console.error('Failed to add the PhotoOutput instance ${err.message}');
+ console.error(`Failed to add output. ${err.message}`);
return;
}
- console.log('Callback invoked to indicate that the PhotoOutput instance is added.');
-});
+ console.log('Callback returned with output added.');
+})
```
### addOutput
-addOutput\(photoOutput: PhotoOutput\): Promise
+addOutput\(cameraOutput: CameraOutput\): Promise
-Adds a **PhotoOutput** instance to this **CaptureSession** instance. This API uses a promise to return the result.
+Adds a **[CameraOutput](#cameraoutput)** instance to this **CaptureSession**. This API uses a promise to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| ----------- | --------------------------- | ---- | --------------------------- |
-| photoOutput | [PhotoOutput](#photooutput) | Yes | **PhotoOutput** instance to add.|
+| Name | Type | Mandatory| Description |
+| ------------- | ------------------------------- | ---- | ------------------------- |
+| cameraOutput | [CameraOutput](#cameraoutput) | Yes | **CameraOutput** instance to add.|
**Return value**
-| Type | Description |
-| -------------- | --------------------------- |
-| Promise\ | Promise used to return the result.|
+| Type | Description |
+| -------------- | ----------------------- |
+| Promise| Promise used to return the result.|
**Example**
```js
-captureSession.addOutput(photoOutput).then(() => {
- console.log('Promise used to indicate that the PhotoOutput instance is added.');
+captureSession.addOutput(cameraOutput).then(() => {
+ console.log('Promise returned with cameraOutput added.');
})
```
-### addOutput
+### removeOutput
-addOutput\(videoOutput: VideoOutput, callback: AsyncCallback\): void
+removeOutput\(cameraOutput: CameraOutput, callback: AsyncCallback\): void
-Adds a **VideoOutput** instance to this **CaptureSession** instance. This API uses an asynchronous callback to return the result.
+Removes a **[CameraOutput](#cameraoutput)** instance from this **CaptureSession**. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| ----------- | --------------------------- | ---- | --------------------------- |
-| videoOutput | [VideoOutput](#videooutput) | Yes | **VideoOutput** instance to add.|
-| callback | AsyncCallback | Yes | Callback used to return the result. |
+| Name | Type | Mandatory| Description |
+| ------------- | ------------------------------- | ---- | ------------------------ |
+| cameraOutput | [CameraOutput](#cameraoutput) | Yes | **CameraOutput** instance to remove.|
+| callback | AsyncCallback | Yes | Callback used to return the result. |
**Example**
```js
-captureSession.addOutput(videoOutput, (err) => {
+captureSession.removeOutput(cameraOutput, (err) => {
if (err) {
- console.error('Failed to add the VideoOutput instance ${err.message}');
+ console.error(`Failed to remove the CameraOutput instance. ${err.message}`);
return;
}
- console.log('Callback invoked to indicate that the VideoOutput instance is added.');
+ console.log('Callback invoked to indicate that the CameraOutput instance is removed.');
});
```
-### addOutput
+### removeOutput
-addOutput\(videoOutput: VideoOutput\): Promise
+removeOutput(cameraOutput: CameraOutput): Promise
-Adds a **VideoOutput** instance to this **CaptureSession** instance. This API uses a promise to return the result.
+Removes a **[CameraOutput](#cameraoutput)** instance from this **CaptureSession**. This API uses a promise to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| ----------- | --------------------------- | ---- | --------------------------- |
-| videoOutput | [VideoOutput](#videooutput) | Yes | **VideoOutput** instance to add.|
+| Name | Type | Mandatory| Description |
+| ------------- | ------------------------------- | ---- | ------------------------- |
+| cameraOutput | [CameraOutput](#cameraoutput) | Yes | **CameraOutput** instance to remove.|
+
**Return value**
-| Type | Description |
-| -------------- | --------------------------- |
-| Promise\ | Promise used to return the result.|
+| Type | Description |
+| -------------- | ------------------------ |
+| Promise| Promise used to return the result.|
+
**Example**
```js
-captureSession.addOutput(videoOutput).then(() => {
- console.log('Promise used to indicate that the VideoOutput instance is added.');
+captureSession.removeOutput(cameraOutput).then(() => {
+ console.log('Promise returned to indicate that the CameraOutput instance is removed.');
})
```
-### removeInput
+### start
-removeInput\(cameraInput: CameraInput, callback: AsyncCallback\): void
+start\(callback: AsyncCallback\): void
-Removes a **CameraInput** instance from this **CaptureSession** instance. This API uses an asynchronous callback to return the result.
+Starts this **CaptureSession**. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| ----------- | --------------------------- | ---- | --------------------------- |
-| cameraInput | [CameraInput](#camerainput) | Yes | **CameraInput** instance to remove.|
-| callback | AsyncCallback | Yes | Callback used to return the result. |
+| Name | Type | Mandatory| Description |
+| -------- | -------------------- | ---- | -------------------- |
+| callback | AsyncCallback | Yes | Callback used to return the result.|
**Example**
```js
-captureSession.removeInput(cameraInput, (err) => {
+captureSession.start((err) => {
if (err) {
- console.error('Failed to remove the CameraInput instance. ${err.message}');
+ console.error(`Failed to start the session ${err.message}`);
return;
}
- console.log('Callback invoked to indicate that the cameraInput instance is removed.');
+ console.log('Callback invoked to indicate the session start success.');
});
```
-### removeInput
+### start
-removeInput\(cameraInput: CameraInput\): Promise
+start\(\): Promise
-Removes a **CameraInput** instance from this **CaptureSession** instance. This API uses a promise to return the result.
+Starts this **CaptureSession**. This API uses a promise to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
-**Parameters**
-
-| Name | Type | Mandatory| Description |
-| ----------- | --------------------------- | ---- | --------------------------- |
-| cameraInput | [CameraInput](#camerainput) | Yes | **CameraInput** instance to remove.|
-
**Return value**
-| Type | Description |
-| -------------- | --------------------------- |
-| Promise\ | Promise used to return the result.|
+| Type | Description |
+| -------------- | ------------------------ |
+| Promise| Promise used to return the result.|
**Example**
```js
-captureSession.removeInput(cameraInput).then(() => {
- console.log('Promise returned to indicate that the cameraInput instance is removed.');
+captureSession.start().then(() => {
+ console.log('Promise returned to indicate the session start success.');
})
```
-### removeOutput
+### stop
-removeOutput\(previewOutput: PreviewOutput, callback: AsyncCallback\): void
+stop\(callback: AsyncCallback\): void
-Removes a **PreviewOutput** instance from this **CaptureSession** instance. This API uses an asynchronous callback to return the result.
+Stops this **CaptureSession**. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| ------------- | ------------------------------- | ---- | ----------------------------- |
-| previewOutput | [PreviewOutput](#previewoutput) | Yes | **PreviewOutput** instance to remove.|
-| callback | AsyncCallback | Yes | Callback used to return the result. |
+| Name | Type | Mandatory| Description |
+| -------- | -------------------- | ---- | ------------------- |
+| callback | AsyncCallback | Yes | Callback used to return the result.|
**Example**
```js
-captureSession.removeOutput(previewOutput, (err) => {
+captureSession.stop((err) => {
if (err) {
- console.error('Failed to remove the PreviewOutput instance. ${err.message}');
+ console.error(`Failed to stop the session ${err.message}`);
return;
}
- console.log('Callback invoked to indicate that the PreviewOutput instance is removed.');
+ console.log('Callback invoked to indicate the session stop success.');
});
```
-### removeOutput
+### stop
-removeOutput(previewOutput: PreviewOutput): Promise
+stop(): Promise
-Removes a **PreviewOutput** instance from this **CaptureSession** instance. This API uses a promise to return the result.
+Stops this **CaptureSession**. This API uses a promise to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
-**Parameters**
-
-| Name | Type | Mandatory| Description |
-| ------------- | ------------------------------- | ---- | ----------------------------- |
-| previewOutput | [PreviewOutput](#previewoutput) | Yes | **PreviewOutput** instance to remove.|
-
-
**Return value**
-| Type | Description |
-| -------------- | --------------------------- |
+| Type | Description |
+| -------------- | ----------------------- |
| Promise| Promise used to return the result.|
-
**Example**
```js
-captureSession.removeOutput(previewOutput).then(() => {
- console.log('Promise returned to indicate that the PreviewOutput instance is removed.');
+captureSession.stop().then(() => {
+ console.log('Promise returned to indicate the session stop success.');
})
```
-### removeOutput
+### release
-removeOutput(photoOutput: PhotoOutput, callback: AsyncCallback): void
+release\(callback: AsyncCallback\): void
-Removes a **PhotoOutput** instance from this **CaptureSession** instance. This API uses an asynchronous callback to return the result.
+Releases this **CaptureSession**. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| ----------- | --------------------------- | ---- | --------------------------- |
-| photoOutput | [PhotoOutput](#photooutput) | Yes | **PhotoOutput** instance to remove.|
-| callback | AsyncCallback | Yes | Callback used to return the result. |
+| Name | Type | Mandatory| Description |
+| -------- | -------------------- | ---- | -------------------- |
+| callback | AsyncCallback | Yes | Callback used to return the result.|
**Example**
```js
-captureSession.removeOutput(photoOutput, (err) => {
+captureSession.release((err) => {
if (err) {
- console.error('Failed to remove the PhotoOutput instance. ${err.message}');
+ console.error(`Failed to release the CaptureSession instance ${err.message}`);
return;
}
- console.log('Callback invoked to indicate that the PhotoOutput instance is removed.');
+ console.log('Callback invoked to indicate that the CaptureSession instance is released successfully.');
});
```
-### removeOutput
+### release
-removeOutput(photoOutput: PhotoOutput): Promise
+release(): Promise
-Removes a **PhotoOutput** instance from this **CaptureSession** instance. This API uses a promise to return the result.
+Releases this **CaptureSession**. This API uses a promise to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
-**Parameters**
-
-| Name | Type | Mandatory| Description |
-| ----------- | --------------------------- | ---- | --------------------------- |
-| photoOutput | [PhotoOutput](#photooutput) | Yes | **PhotoOutput** instance to remove.|
-
-
**Return value**
-| Type | Description |
-| -------------- | --------------------------- |
+| Type | Description |
+| -------------- | ------------------------ |
| Promise| Promise used to return the result.|
-
**Example**
```js
-captureSession.removeOutput(photoOutput).then(() => {
- console.log('Promise returned to indicate that the PhotoOutput instance is removed.');
+captureSession.release().then(() => {
+ console.log('Promise returned to indicate that the CaptureSession instance is released successfully.');
})
```
-### removeOutput
+### hasFlash
-removeOutput(videoOutput: VideoOutput, callback: AsyncCallback): void
+hasFlash(callback: AsyncCallback): void
-Removes a **VideoOutput** instance from this **CaptureSession** instance. This API uses an asynchronous callback to return the result.
+Checks whether the device has flash. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| ----------- | --------------------------- | ---- | --------------------------- |
-| videoOutput | [VideoOutput](#videooutput) | Yes | **VideoOutput** instance to remove.|
-| callback | AsyncCallback | Yes | Callback used to return the result. |
+| Name | Type | Mandatory| Description |
+| -------- | ----------------------- | ---- | -------------------------------- |
+| callback | AsyncCallback | Yes | Callback used to return the flash support status. The value **true** means that the device has flash.|
**Example**
```js
-captureSession.removeOutput(videoOutput, (err) => {
+captureSession.hasFlash((err, status) => {
if (err) {
- console.error('Failed to remove the VideoOutput instance. ${err.message}');
+ console.error(`Failed to check whether the device has flash light. ${err.message}`);
return;
}
- console.log('Callback invoked to indicate that the VideoOutput instance is removed.');
-});
+ console.log(`Callback returned with flash light support status: ${status}`);
+})
```
-### removeOutput
+### hasFlash
-removeOutput(videoOutput: VideoOutput): Promise
+hasFlash(): Promise
-Removes a **VideoOutput** instance from this **CaptureSession** instance. This API uses a promise to return the result.
+Checks whether the device has flash. This API uses a promise to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
-**Parameters**
+**Return value**
-| Name | Type | Mandatory| Description |
-| ----------- | --------------------------- | ---- | --------------------------- |
-| videoOutput | [VideoOutput](#videooutput) | Yes | **VideoOutput** instance to remove.|
+| Type | Description |
+| ----------------- | ----------------------------------------------- |
+| Promise | Promise used to return the flash support status. The value **true** means that the device has flash.|
+**Example**
+
+```js
+captureSession.hasFlash().then((status) => {
+ console.log(`Promise returned with the flash light support status: ${status}`);
+})
+```
+
+### isFlashModeSupported
+
+isFlashModeSupported(flashMode: FlashMode, callback: AsyncCallback): void
+
+Checks whether a specified flash mode is supported. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Multimedia.Camera.Core
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| --------- | ----------------------- | ---- | --------------------------------- |
+| flashMode | [FlashMode](#flashmode) | Yes | Flash mode. |
+| callback | AsyncCallback | Yes | Callback used to return the flash mode support status. The value **true** means that the flash mode is supported, and **false** means the opposite.|
+
+**Example**
+
+```js
+captureSession.isFlashModeSupported(camera.FlashMode.FLASH_MODE_AUTO, (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
+
+isFlashModeSupported(flashMode: FlashMode): Promise
+
+Checks whether a specified flash mode is supported. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.Multimedia.Camera.Core
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| --------- | ----------------------- | ---- | ------------- |
+| flashMode | [FlashMode](#flashmode) | Yes | Flash mode.|
+
+**Return value**
+
+| Type | Description |
+| ----------------- | ---------------------------------------------------- |
+| Promise | Promise used to return the flash mode support status. The value **true** means that the flash mode is supported, and **false** means the opposite.|
+
+**Example**
+
+```js
+captureSession.isFlashModeSupported(camera.FlashMode.FLASH_MODE_AUTO).then((status) => {
+ console.log(`Promise returned with flash mode support status.${status}`);
+})
+```
+
+### setFlashMode
+
+setFlashMode(flashMode: FlashMode, callback: AsyncCallback): void
+
+Sets the flash mode. This API uses an asynchronous callback to return the result.
+
+Before the setting, do the following checks:
+
+1. Use **[hasFlash](#hasflash)** to check whether the device has flash.
+2. Use **[isFlashModeSupported](#isflashmodesupported)** to check whether the device supports the flash mode.
+
+**System capability**: SystemCapability.Multimedia.Camera.Core
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| --------- | ----------------------- | ---- | --------------------- |
+| flashMode | [FlashMode](#flashmode) | Yes | Flash mode. |
+| callback | AsyncCallback | Yes | Callback used to return the result.|
+
+**Example**
+
+```js
+captureSession.setFlashMode(camera.FlashMode.FLASH_MODE_AUTO, (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
+
+setFlashMode(flashMode: FlashMode): Promise
+
+Sets a flash mode. This API uses a promise to return the result.
+
+Before the setting, do the following checks:
+
+1. Use **[hasFlash](#hasflash)** to check whether the device has flash.
+2. Use **[isFlashModeSupported](#isflashmodesupported)** to check whether the device supports the flash mode.
+
+**System capability**: SystemCapability.Multimedia.Camera.Core
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| --------- | ----------------------- | ---- | ------------- |
+| flashMode | [FlashMode](#flashmode) | Yes | Flash mode.|
+
+**Return value**
+
+| Type | Description |
+| -------------- | ------------------------ |
+| Promise| Promise used to return the result.|
+
+**Example**
+
+```js
+captureSession.setFlashMode(camera.FlashMode.FLASH_MODE_AUTO).then(() => {
+ console.log('Promise returned with the successful execution of setFlashMode.');
+})
+```
+
+### getFlashMode
+
+getFlashMode(callback: AsyncCallback): void
+
+Obtains the flash mode in use. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Multimedia.Camera.Core
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| -------- | --------------------------------------- | ---- | --------------------------------- |
+| callback | AsyncCallback<[FlashMode](#flashmode)\> | Yes | Callback used to return the flash mode.|
+
+**Example**
+
+```js
+captureSession.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
+
+getFlashMode(): Promise
+
+Obtains the flash mode in use. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.Multimedia.Camera.Core
+
+**Return value**
+
+| Type | Description |
+| --------------------------------- | --------------------------------- |
+| Promise<[FlashMode](#flashmode)\> | Promise used to return the flash mode.|
+
+**Example**
+
+```js
+captureSession.getFlashMode().then((flashMode) => {
+ console.log(`Promise returned with current flash mode : ${flashMode}`);
+})
+```
+
+### isExposureModeSupported
+
+isExposureModeSupported(aeMode: ExposureMode, callback: AsyncCallback): void;
+
+Checks whether a specified exposure mode is supported. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Multimedia.Camera.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | -------------------------------| ---- | ----------------------------- |
+| aeMode | [ExposureMode](#exposuremode) | Yes | Exposure mode. |
+| callback | AsyncCallback | Yes | Callback used to return the exposure mode support status. The value **true** means that the exposure mode is supported, and **false** means the opposite.|
+
+**Example**
+
+```js
+captureSession.isExposureModeSupported(camera.ExposureMode.EXPOSURE_MODE_LOCKED,(err) => {
+ if (err) {
+ console.log(`Failed to check exposure mode supported ${err.message}`);
+ return ;
+ }
+ console.log('Callback returned with the successful execution of isExposureModeSupported');
+})
+```
+
+### isExposureModeSupported
+
+isExposureModeSupported(aeMode: ExposureMode): Promise
+
+Checks whether a specified exposure mode is supported. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.Multimedia.Camera.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | -------------------------------| ---- | ----------------------------- |
+| aeMode | [ExposureMode](#exposuremode) | Yes | Exposure mode. |
+
+**Return value**
+
+| Name | Description |
+| ----------------- |--------------------------------- |
+| Promise | Promise used to return the exposure mode support status. The value **true** means that the exposure mode is supported, and **false** means the opposite.|
+
+**Example**
+
+```js
+captureSession.isExposureModeSupported(camera.ExposureMode.EXPOSURE_MODE_LOCKED).then((isSupported) => {
+ console.log(`Promise returned with exposure mode supported : ${isSupported}`);
+})
+```
+
+### getExposureMode
+
+getExposureMode(callback: AsyncCallback): void
+
+Obtains the exposure mode in use. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Multimedia.Camera.Core
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| -------- | -------------------------------| ---- | ---------------------------------------- |
+| callback | AsyncCallback<[ExposureMode](#exposuremode)\> | Yes | Callback used to return the exposure mode.|
+
+**Example**
+
+```js
+captureSession.getExposureMode((err, exposureMode) => {
+ if (err) {
+ console.log(`Failed to get the exposure mode ${err.message}`);
+ return ;
+ }
+ console.log(`Callback returned with current exposure mode: ${exposureMode}`);
+})
+```
+
+### getExposureMode
+
+getExposureMode(): Promise
+
+Obtains the exposure mode in use. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.Multimedia.Camera.Core
+
+**Return value**
+
+| Name | Description |
+| --------------------------------------- |------------------------------- |
+| Promise<[ExposureMode](#exposuremode)\> | Promise used to return the exposure mode.|
+
+**Example**
+
+```js
+captureSession.getExposureMode().then((exposureMode) => {
+ console.log(`Promise returned with current exposure mode : ${exposureMode}`);
+})
+```
+
+### setExposureMode
+
+setExposureMode(aeMode: ExposureMode, callback: AsyncCallback): void
+
+Sets an exposure mode. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Multimedia.Camera.Core
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| -------- | -------------------------------| ---- | ----------------------- |
+| aeMode | [ExposureMode](#exposuremode) | Yes | Exposure mode. |
+| callback | AsyncCallback | Yes | Callback used to return the result.|
+
+**Example**
+
+```js
+captureSession.setExposureMode(camera.ExposureMode.EXPOSURE_MODE_LOCKED,(err) => {
+ if (err) {
+ console.log(`Failed to set the exposure mode ${err.message}`);
+ return ;
+ }
+ console.log('Callback returned with the successful execution of setExposureMode');
+})
+```
+
+### setExposureMode
+
+setExposureMode(aeMode: ExposureMode): Promise
+
+Sets an exposure mode. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.Multimedia.Camera.Core
+
+**Return value**
+
+| Name | Description |
+| ----------------- |---------------------------- |
+| Promise | Promise used to return the result.|
+
+**Example**
+
+```js
+captureSession.setExposureMode(camera.ExposureMode.EXPOSURE_MODE_LOCKED).then(() => {
+ console.log('Promise returned with the successful execution of setExposureMode.');
+})
+```
+
+### getMeteringPoint
+
+getMeteringPoint(callback: AsyncCallback): void
+
+Obtains the center of the metering area. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Multimedia.Camera.Core
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| -------- | -------------------------------| ---- | ------------------------ |
+| callback | AsyncCallback<[Point](#point)\>| Yes | Callback used to return the center of the metering area.|
+
+**Example**
+
+```js
+captureSession.getMeteringPoint((err, exposurePoint) => {
+ if (err) {
+ console.log(`Failed to get the current exposure point ${err.message}`);
+ return ;
+ }
+ console.log(`Callback returned with current exposure point: ${exposurePoint}`);
+})
+```
+
+### getMeteringPoint
+
+getMeteringPoint(): Promise
+
+Obtains the center of the metering area. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.Multimedia.Camera.Core
+
+**Return value**
+
+| Name | Description |
+| ------------------------- |----------------------------- |
+| Promise<[Point](#point)\> | Promise used to return the center of the metering area.|
+
+**Example**
+
+```js
+captureSession.getMeteringPoint().then((exposurePoint) => {
+ console.log(`Promise returned with current exposure point : ${exposurePoint}`);
+})
+```
+
+### setMeteringPoint
+
+setMeteringPoint(point: Point, callback: AsyncCallback): void
+
+Sets the center of the metering area. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Multimedia.Camera.Core
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| ------------- | -------------------------------| ---- | ------------------- |
+| exposurePoint | [Point](#point) | Yes | Exposure point. |
+| callback | AsyncCallback | Yes | Callback used to return the result.|
+
+**Example**
+
+```js
+const Point1 = {x: 1, y: 1};
+
+captureSession.setMeteringPoint(Point1,(err) => {
+ if (err) {
+ console.log(`Failed to set the exposure point ${err.message}`);
+ return ;
+ }
+ console.log('Callback returned with the successful execution of setMeteringPoint');
+})
+```
+
+### setMeteringPoint
+
+setMeteringPoint(point: Point): Promise
+
+Sets the center of the metering area. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.Multimedia.Camera.Core
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| ------------- | -------------------------------| ---- | ------------------- |
+| exposurePoint | [Point](#point) | Yes | Exposure point. |
+
+**Return value**
+
+| Name | Description |
+| ----------------- |------------------------ |
+| Promise | Promise used to return the center of the metering area.|
+
+**Example**
+
+```js
+const Point2 = {x: 2, y: 2};
+
+captureSession.setMeteringPoint(Point2).then(() => {
+ console.log('Promise returned with the successful execution of setMeteringPoint');
+})
+```
+
+### getExposureBiasRange
+
+getExposureBiasRange(callback: AsyncCallback\>): void
+
+Obtains the exposure compensation values. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Multimedia.Camera.Core
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| -------- | -------------------------------| ---- | ----------------------------- |
+| callback | AsyncCallback\> | Yes | Callback used to return the array of compensation values.|
+
+**Example**
+
+```js
+captureSession.getExposureBiasRange((err, biasRangeArray) => {
+ if (err) {
+ console.log(`Failed to get the array of compenstation range ${err.message}`);
+ return ;
+ }
+ console.log('Callback returned with the array of compenstation range: ' + JSON.stringify(biasRangeArray));
+})
+```
+
+### getExposureBiasRange
+
+getExposureBiasRange(): Promise\>
+
+Obtains the exposure compensation values. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.Multimedia.Camera.Core
+
+**Return value**
+
+| Name | Description |
+| ----------------- |-------------------------------------- |
+| Promise\> | Promise used to return the array of compensation values.|
+
+**Example**
+
+```js
+captureSession.isExposureModeSupported(camera.ExposureMode.EXPOSURE_MODE_LOCKED).then((isSupported) => {
+ console.log(`Promise returned with exposure mode supported : ${isSupported}`);
+})
+```
+
+### setExposureBias
+
+setExposureBias(exposureBias: number, callback: AsyncCallback): void
+
+Sets an exposure compensation value. This API uses an asynchronous callback to return the result.
+
+Before the setting, you are advised to use **[getExposureBiasRange](#getexposurebiasrange)** to obtain the supported values.
+
+**System capability**: SystemCapability.Multimedia.Camera.Core
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| -------- | -------------------------------| ---- | ------------------- |
+| exposureBias | number | Yes | Compensation value. |
+| callback | AsyncCallback | Yes | Callback used to return the result.|
+
+**Example**
+
+```js
+captureSession.setExposureBias(-4,(err) => {
+ if (err) {
+ console.log(`Failed to set the exposure bias ${err.message}`);
+ return ;
+ }
+ console.log('Callback returned with the successful execution of setExposureBias');
+})
+```
+
+### setExposureBias
+
+setExposureBias(exposureBias: number): Promise
+
+Sets an exposure compensation value. This API uses a promise to return the result.
+
+Before the setting, you are advised to use **[getExposureBiasRange](#getexposurebiasrange)** to obtain the supported values.
+
+**System capability**: SystemCapability.Multimedia.Camera.Core
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| -------------- | --------- | ---- | --------- |
+| exposureBias | number | Yes | Compensation value. |
+
+**Return value**
+
+| Name | Description |
+| ----------------- |------------------------- |
+| Promise | Promise used to return the result.|
+
+**Example**
+
+```js
+captureSession.setExposureBias(-4).then(() => {
+ console.log('Promise returned with the successful execution of setExposureBias.');
+})
+```
+
+### getExposureValue
+
+getExposureValue(callback: AsyncCallback): void
+
+Obtains the exposure value in use. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Multimedia.Camera.Core
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| -------- | ------------------------| ---- | --------------------- |
+| callback | AsyncCallback | Yes | Callback used to the exposure value.|
+
+**Example**
+
+```js
+captureSession.getExposureValue((err, exposureValue) => {
+ if (err) {
+ console.log(`Failed to get the exposure value ${err.message}`);
+ return ;
+ }
+ console.log(`Callback returned with the exposure value: ${exposureValue}`);
+})
+```
+
+### getExposureValue
+
+getExposureValue(): Promise
+
+Obtains the exposure value in use. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.Multimedia.Camera.Core
+
+**Return value**
+
+| Name | Description |
+| ----------------- |-------------------------- |
+| Promise | Promise used to the exposure value.|
+
+**Example**
+
+```js
+captureSession.getExposureValue().then((exposureValue) => {
+ console.log(`Promise returned with exposure value: ${exposureValude}`);
+})
+```
+
+### isFocusModeSupported
+
+isFocusModeSupported(afMode: FocusMode, callback: AsyncCallback): void
+
+Checks whether a specified focus mode is supported. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Multimedia.Camera.Core
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| -------- | ----------------------- | ---- | -------------------------------- |
+| afMode | [FocusMode](#focusmode) | Yes | Focus mode. |
+| callback | AsyncCallback | Yes | Callback used to return the focus mode support status. The value **true** means that the focus mode is supported, and **false** means the opposite.|
+
+**Example**
+
+```js
+captureSession.isFocusModeSupported(camera.FocusMode.FOCUS_MODE_AUTO, (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
+
+isFocusModeSupported(afMode: FocusMode): Promise
+
+Checks whether a specified focus mode is supported. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.Multimedia.Camera.Core
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| ------ | ----------------------- | ---- | ------------- |
+| afMode | [FocusMode](#focusmode) | Yes | Focus mode.|
+
+**Return value**
+
+| Type | Description |
+| ----------------- | --------------------------------------------------- |
+| Promise | Promise used to return the focus mode support status. The value **true** means that the focus mode is supported, and **false** means the opposite.|
+
+**Example**
+
+```js
+captureSession.isFocusModeSupported(camera.FocusMode.FOCUS_MODE_AUTO).then((status) => {
+ console.log(`Promise returned with focus mode support status ${status}.`);
+})
+```
+
+### setFocusMode
+
+setFocusMode(afMode: FocusMode, callback: AsyncCallback): void
+
+Sets a focus mode. This API uses an asynchronous callback to return the result.
+
+Before the setting, use **[isFocusModeSupported](#isfocusmodesupported)** to check whether the focus mode is supported.
+
+**System capability**: SystemCapability.Multimedia.Camera.Core
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| -------- | ----------------------- | ---- | ------------------- |
+| afMode | [FocusMode](#focusmode) | Yes | Focus mode. |
+| callback | AsyncCallback | Yes | Callback used to return the result.|
+
+**Example**
+
+```js
+captureSession.setFocusMode(camera.FocusMode.FOCUS_MODE_AUTO, (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
+
+setFocusMode(afMode: FocusMode): Promise
+
+Sets a focus mode. This API uses a promise to return the result.
+
+Before the setting, use **[isFocusModeSupported](#isfocusmodesupported)** to check whether the focus mode is supported.
+
+**System capability**: SystemCapability.Multimedia.Camera.Core
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| ------ | ----------------------- | ---- | ------------- |
+| afMode | [FocusMode](#focusmode) | Yes | Focus mode.|
+
+**Return value**
+
+| Type | Description |
+| -------------- | ------------------------ |
+| Promise| Promise used to return the result.|
+
+**Example**
+
+```js
+captureSession.setFocusMode(camera.FocusMode.FOCUS_MODE_AUTO).then(() => {
+ console.log('Promise returned with the successful execution of setFocusMode.');
+})
+```
+
+### getFocusMode
+
+getFocusMode(callback: AsyncCallback): void
+
+Obtains the focus mode in use. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Multimedia.Camera.Core
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| -------- | --------------------------------------- | ---- | ------------------------------- |
+| callback | AsyncCallback<[FocusMode](#focusmode)\> | Yes | Callback used to return the focus mode.|
+
+**Example**
+
+```js
+captureSession.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
+
+getFocusMode(): Promise
+
+Obtains the focus mode in use. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.Multimedia.Camera.Core
+
+**Return value**
+
+| Type | Description |
+| ------------------- | -------------------------------- |
+| Promise | Promise used to return the focus mode.|
+
+**Example**
+
+```js
+captureSession.getFocusMode().then((afMode) => {
+ console.log(`Promise returned with current focus mode : ${afMode}`);
+})
+```
+
+### setFocusPoint
+
+setFocusPoint(point: Point, callback: AsyncCallback): void
+
+Sets a focus point. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Multimedia.Camera.Core
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| -------- | ----------------------- | ---- | ------------------- |
+| point | [Point](#point) | Yes | Focal point. |
+| callback | AsyncCallback | Yes | Callback used to return the result.|
+
+**Example**
+
+```js
+const Point1 = {x: 1, y: 1};
+
+captureSession.setFocusPoint(Point1, (err) => {
+ if (err) {
+ console.error(`Failed to set the focus point ${err.message}`);
+ return;
+ }
+ console.log('Callback returned with the successful execution of setFocusPoint.');
+})
+```
+
+### setFocusPoint
+
+setFocusPoint(point: Point): Promise
+
+Sets a focal point. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.Multimedia.Camera.Core
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| -------- | ----------------------- | ---- | ------------------- |
+| point | [Point](#point) | Yes | Focal point. |
+
+**Return value**
+
+| Type | Description |
+| -------------- | ----------------------- |
+| Promise| Promise used to return the result.|
+
+**Example**
+
+```js
+const Point2 = {x: 2, y: 2};
+
+captureSession.setFocusPoint(Point2).then(() => {
+ console.log('Promise returned with the successful execution of setFocusPoint.');
+})
+```
+
+### getFocusPoint
+
+getFocusPoint(callback: AsyncCallback): void
+
+Obtains the focal point. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Multimedia.Camera.Core
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| -------- | ---------------------------------- | ---- | ----------------------- |
+| callback | AsyncCallback<[Point](#point)\> | Yes | Callback used to return the focal point.|
+
+**Example**
+
+```js
+captureSession.getFocusPoint((err, point) => {
+ if (err) {
+ console.error(`Failed to get the current focus point ${err.message}`);
+ return;
+ }
+ console.log('Callback returned with the current focus point: ' + JSON.stringify(point));
+})
+```
+
+### getFocusPoint
+
+getFocusPoint(): Promise
+
+Obtains the focal point. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.Multimedia.Camera.Core
+
+**Return value**
+
+| Type | Description |
+| --------------- | --------------------------- |
+| Promise