-
-
+
+## createAnimator
+
+createAnimator(options: AnimatorOptions): AnimatorResult
+
+Creates an **Animator** object.
+
+**System capability**: SystemCapability.ArkUI.ArkUI.Full
+
+**Parameters**
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| options | [AnimatorOptions](#animatoroptions) | Yes| Animator options. For details, see **AnimatorOptions**.|
+
+**Return value**
+| Type| Description|
+| -------- | -------- |
+| [AnimatorResult](#animatorresult) | Animator result.|
+
+**Example**
+
+ ```
+
+
+
- ```
-
- ```
- // js
- export default {
- data : {
- divWidth: 200,
- divHeight: 200,
- animator: null
- },
- onInit() {
- var options = {
- duration: 1500,
- easing: 'friction',
- fill: 'forwards',
- iterations: 2,
- begin: 200.0,
- end: 400.0
- };
- this.animator = animator.createAnimator(options);
- },
- Show() {
- var options1 = {
- duration: 2000,
- easing: 'friction',
- fill: 'forwards',
- iterations: 1,
- begin: 200.0,
- end: 400.0
- };
- this.animator.update(options1);
- var _this = this;
- this.animator.onframe = function(value) {
- _this.divWidth = value;
- _this.divHeight = value;
- };
- this.animator.play();
- }
+
+ ```
+
+ ```
+ // js
+ export default {
+ data : {
+ divWidth: 200,
+ divHeight: 200,
+ animator: null
+ },
+ onInit() {
+ var options = {
+ duration: 1500,
+ easing: 'friction',
+ fill: 'forwards',
+ iterations: 2,
+ begin: 200.0,
+ end: 400.0
+ };
+ this.animator = animator.createAnimator(options);
+ },
+ Show() {
+ var options1 = {
+ duration: 2000,
+ easing: 'friction',
+ fill: 'forwards',
+ iterations: 1,
+ begin: 200.0,
+ end: 400.0
+ };
+ this.animator.update(options1);
+ var _this = this;
+ this.animator.onframe = function(value) {
+ _this.divWidth = value;
+ _this.divHeight = value;
+ };
+ this.animator.play();
}
- ```
+ }
+ ```
+
+## AnimatorResult
+
+Defines the animator result.
+
+### update
+
+update(options: AnimatorOptions): void
+
+Updates this animator.
+
+**System capability**: SystemCapability.ArkUI.ArkUI.Full
+
+**Parameters**
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| options | [AnimatorOptions](#animatoroptions) | Yes| Animator options.|
+
+**Example**
+```
+animator.update(options);
+```
+
+### play
+
+play(): void
+
+Plays this animation.
+
+**System capability**: SystemCapability.ArkUI.ArkUI.Full
+
+**Example**
+```
+animator.play();
+```
+
+### finish
+
+finish(): void
+
+Ends this animation.
+
+**System capability**: SystemCapability.ArkUI.ArkUI.Full
+
+**Example**
+```
+animator.finish();
+```
+
+### pause
+
+pause(): void
+
+Pauses this animation.
+
+**System capability**: SystemCapability.ArkUI.ArkUI.Full
+
+**Example**
+```
+animator.pause();
+```
+
+### cancel
+
+cancel(): void
+
+Cancels this animation.
+
+**System capability**: SystemCapability.ArkUI.ArkUI.Full
+
+**Example**
+```
+animator.cancel();
+```
+
+### reverse
+
+reverse(): void
+
+Plays this animation in reverse order.
+
+**System capability**: SystemCapability.ArkUI.ArkUI.Full
+
+**Example**
+```
+animator.reverse();
+```
+
+### onframe
+
+onframe: (progress: number) => void
+
+Called when a frame is received.
+
+**System capability**: SystemCapability.ArkUI.ArkUI.Full
+
+**Parameters**
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| progress | number | Yes| Current progress of the animation.|
+
+**Example**
+```
+animator.onframe();
+```
+
+### onfinish
+
+onfinish: () => void
+
+Called when this animation is finished.
+
+**System capability**: SystemCapability.ArkUI.ArkUI.Full
+
+**Example**
+```
+animator.onfinish();
+```
+
+### oncancel
+
+oncancel: () => void
+
+Called when this animation is canceled.
+
+**System capability**: SystemCapability.ArkUI.ArkUI.Full
+
+**Example**
+```
+animator.oncancel();
+```
+
+### onrepeat
+
+onrepeat: () => void
+
+**System capability**: SystemCapability.ArkUI.ArkUI.Full
+
+**Example**
+```
+animator.onrepeat();
+```
+
+Called when this animation repeats.
+
+## AnimatorOptions
+
+Defines animator options.
+**System capability**: SystemCapability.ArkUI.ArkUI.Full
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| duration | number | Yes| Duration for playing the animation, in milliseconds. The default value is **0**.|
+| easing | string | Yes| Animation interpolation curve. The default value is **ease**.|
+| delay | number | Yes| Animation delay duration, in milliseconds. The default value is **0**, indicating that there is no delay.|
+| fill | "none" \| "forwards" \| "backwards" \| "both" | Yes| State of the animated target after the animation is executed. The default value is **none**, which means that the target will retain its end state (defined by the last keyframe) after the animation is executed. |
+| direction | "normal" \| "reverse" \| "alternate" \| "alternate-reverse" | Yes| Animation playback mode. The default value is **normal**.|
+| iterations | number | Yes| Number of times that the animation is played. The default value is **1**. The value **0** means not to play the animation, and **-1** means to play the animation for an unlimited number of times.|
+| begin | number | Yes| Start point of the animation interpolation. If this parameter is not set, the default value **0** is used.|
+| end | number | Yes| End point of the animation interpolation. If this parameter is not set, the default value **1** is used.|
diff --git a/en/application-dev/reference/apis/js-apis-application-MissionSnapshot.md b/en/application-dev/reference/apis/js-apis-application-MissionSnapshot.md
index 4521fcd2b0158e67b20d36ac059cea5642a28179..c850915c4d2743d7ee8f03ce0b96d6a4f7739525 100644
--- a/en/application-dev/reference/apis/js-apis-application-MissionSnapshot.md
+++ b/en/application-dev/reference/apis/js-apis-application-MissionSnapshot.md
@@ -1,6 +1,5 @@
# MissionSnapshot
-
> **NOTE**
>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
@@ -10,7 +9,7 @@ Provides the snapshot of a mission.
## Modules to Import
```
-import abilitymanager from '@ohos.application.abilityManager';
+import missionManager from '@ohos.application.missionManager'
import ElementName from '@ohos.bundle';
import image from '@ohos.multimedia.image';
```
diff --git a/en/application-dev/reference/apis/js-apis-application-Want.md b/en/application-dev/reference/apis/js-apis-application-Want.md
index 19509a5e771ce744b16a8f231faf6f75bccb772b..26c0cd030bcdf36cee488cba5066b2beba38a3d3 100644
--- a/en/application-dev/reference/apis/js-apis-application-Want.md
+++ b/en/application-dev/reference/apis/js-apis-application-Want.md
@@ -1,14 +1,13 @@
# Want
-> **NOTE**
+> **NOTE**
+>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
**Want** is the basic communication component of the system.
-
## Modules to Import
-
```
import Want from '@ohos.application.Want';
```
@@ -17,14 +16,15 @@ import Want from '@ohos.application.Want';
**System capability**: SystemCapability.Ability.AbilityBase
- | Name | Readable/Writable | Type | Mandatory | Description |
- | ----------- | -------- | -------------------- | ---- | ------------------------------------------------------------ |
- | deviceId | Read only | string | No | ID of the device running the ability. |
- | bundleName | Read only | string | No | Bundle name of the ability. If both **bundleName** and **abilityName** are specified in a **Want** object, the **Want** object can directly match the specified ability. |
- | abilityName | Read only | string | No | Name of the ability. If both **package** and **AbilityName** are specified in this field in a **Want** object, the **Want** object can directly match the specified ability. |
- | uri | Read only | string | No | URI information to match. If **uri** is specified in a **Want** object, the **Want** object will match the specified URI information, including **scheme**, **schemeSpecificPart**, **authority**, and **path**. |
- | type | Read only | string | No | MIME type, for example, **text/plain** or **image/***. |
- | flags | Read only | number | No | How the **Want** object will be handled. By default, numbers are passed in. For details, see [flags](js-apis-featureAbility.md#flags). |
- | action | Read only | string | No | Action option. |
- | parameters | Read only | {[key: string]: any} | No | List of parameters in the **Want** object. |
- | entities | Read only | Array\
| No | List of entities. |
+| Name | Readable/Writable| Type | Mandatory| Description |
+| ----------- | -------- | -------------------- | ---- | ------------------------------------------------------------ |
+| deviceId | Read only | string | No | ID of the device running the ability. |
+| bundleName | Read only | string | No | Bundle name of the ability. If both **bundleName** and **abilityName** are specified in a **Want** object, the **Want** object can match a specific ability.|
+| abilityName | Read only | string | No | Name of the ability. If both **package** and **abilityName** are specified in a **Want** object, the **Want** object can match a specific ability.|
+| uri | Read only | string | No | URI information to match. If **uri** is specified in a **Want** object, the **Want** object will match the specified URI information, including **scheme**, **schemeSpecificPart**, **authority**, and **path**.|
+| type | Read only | string | No | MIME type, for example, **text/plain** or **image/***. |
+| flags | Read only | number | No | How the **Want** object will be handled. By default, numbers are passed in. For details, see [flags](js-apis-featureAbility.md#flags).|
+| action | Read only | string | No | Action option. |
+| parameters | Read only | {[key: string]: any} | No | List of parameters in the **Want** object. |
+| entities | Read only | Array\ | No | List of entities. |
+| moduleName9+ | Read only | string | No | Module to which the ability belongs. Different abilities among HAP files in an application may use the same name. If the abilities cannot be distinguished by the combination of **bundleName** and **abilityName**, you can set **moduleName** for better distinguishing.| |
diff --git a/en/application-dev/reference/apis/js-apis-application-ability.md b/en/application-dev/reference/apis/js-apis-application-ability.md
index 136ec10fb630431a12d0455ca5e941249265267e..bdf719b34ed6e7ba0dcc227ff5866c8ae7b87a87 100644
--- a/en/application-dev/reference/apis/js-apis-application-ability.md
+++ b/en/application-dev/reference/apis/js-apis-application-ability.md
@@ -1,15 +1,14 @@
# Ability
->  **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.
-
+> **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.
+> The APIs of this module can be used only in the stage model.
Manages the ability lifecycle and context.
-
## Modules to Import
-
```
import Ability from '@ohos.application.Ability';
```
@@ -23,6 +22,8 @@ import Ability from '@ohos.application.Ability';
| context | [AbilityContext](js-apis-ability-context.md) | Yes| No| Context of an ability.|
| launchWant | [Want](js-apis-application-Want.md) | Yes| No| Parameters for starting the ability.|
| lastRequestWant | [Want](js-apis-application-Want.md) | Yes| No| Parameters used when the ability was started last time.|
+| callee | [Callee](#callee) | Yes| No| Object that invokes the stub service.|
+
## Ability.onCreate
@@ -200,11 +201,12 @@ Called to save data during the ability migration preparation process.
**Example**
```js
+ import AbilityConstant from "@ohos.application.AbilityConstant"
class myAbility extends Ability {
onContinue(wantParams) {
console.log('onContinue');
wantParams["myData"] = "my1234567";
- return true;
+ return AbilityConstant.OnContinueResult.AGREE;
}
}
```
@@ -212,7 +214,7 @@ Called to save data during the ability migration preparation process.
## Ability.onNewWant
-onNewWant(want: Want): void;
+onNewWant(want: Want, launchParams: AbilityConstant.LaunchParam): void;
Called when the ability startup mode is set to singleton.
@@ -223,13 +225,17 @@ Called when the ability startup mode is set to singleton.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | Yes| Want parameters, such as the ability name and bundle name.|
+ | launchParams | AbilityConstant.LaunchParam | Yes| Reason for the ability startup and the last abnormal exit.|
**Example**
```js
class myAbility extends Ability {
- onNewWant(want) {
+ onNewWant(want, launchParams) {
console.log('onNewWant, want:' + want.abilityName);
+ if (launchParams.launchReason === AbilityConstant.LaunchReason.CONTINUATION) {
+ console.log('onNewWant, launchReason is continuation');
+ }
}
}
```
@@ -259,6 +265,32 @@ Called when the configuration of the environment where the ability is running is
}
```
+## Ability.dump
+
+dump(params: Array\): Array\;
+
+Called when the client information is dumped.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
+
+**Parameters**
+
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | params | Array\ | Yes| Parameters in the form of a command.|
+
+**Example**
+
+ ```js
+ class myAbility extends Ability {
+ dump(params) {
+ console.log('dump, params:' + JSON.stringify(params));
+ return ["params"]
+ }
+ }
+ ```
+
+
## Caller
@@ -291,6 +323,9 @@ Sends sequenceable data to the target ability.
```js
import Ability from '@ohos.application.Ability';
class MyMessageAble{ // Custom sequenceable data structure
+ name:""
+ str:""
+ num: 1
constructor(name, str) {
this.name = name;
this.str = str;
@@ -314,7 +349,7 @@ Sends sequenceable data to the target ability.
onWindowStageCreate(windowStage) {
this.context.startAbilityByCall({
bundleName: "com.example.myservice",
- abilityName: "com.example.myservice.MainAbility",
+ abilityName: "MainAbility",
deviceId: ""
}).then((obj) => {
caller = obj;
@@ -361,6 +396,9 @@ Sends sequenceable data to the target ability and obtains the sequenceable data
```js
import Ability from '@ohos.application.Ability';
class MyMessageAble{
+ name:""
+ str:""
+ num: 1
constructor(name, str) {
this.name = name;
this.str = str;
@@ -384,7 +422,7 @@ Sends sequenceable data to the target ability and obtains the sequenceable data
onWindowStageCreate(windowStage) {
this.context.startAbilityByCall({
bundleName: "com.example.myservice",
- abilityName: "com.example.myservice.MainAbility",
+ abilityName: "MainAbility",
deviceId: ""
}).then((obj) => {
caller = obj;
@@ -423,7 +461,7 @@ Releases the caller interface of the target ability.
onWindowStageCreate(windowStage) {
this.context.startAbilityByCall({
bundleName: "com.example.myservice",
- abilityName: "com.example.myservice.MainAbility",
+ abilityName: "MainAbility",
deviceId: ""
}).then((obj) => {
caller = obj;
@@ -445,7 +483,7 @@ Releases the caller interface of the target ability.
onRelease(callback: OnReleaseCallBack): void;
-Registers a callback that is invoked when the Stub on the target ability is disconnected.
+Registers a callback that is invoked when the stub on the target ability is disconnected.
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
@@ -464,7 +502,7 @@ Registers a callback that is invoked when the Stub on the target ability is disc
onWindowStageCreate(windowStage) {
this.context.startAbilityByCall({
bundleName: "com.example.myservice",
- abilityName: "com.example.myservice.MainAbility",
+ abilityName: "MainAbility",
deviceId: ""
}).then((obj) => {
caller = obj;
@@ -509,6 +547,9 @@ Registers a caller notification callback, which is invoked when the target abili
```js
import Ability from '@ohos.application.Ability';
class MyMessageAble{
+ name:""
+ str:""
+ num: 1
constructor(name, str) {
this.name = name;
this.str = str;
diff --git a/en/application-dev/reference/apis/js-apis-application-abilitystage.md b/en/application-dev/reference/apis/js-apis-application-abilitystage.md
index 8e501a482e04e33a18a8040d0183257b7c3e90c4..bb9c758f36dc8456d817cb655303591f7dfa09a7 100644
--- a/en/application-dev/reference/apis/js-apis-application-abilitystage.md
+++ b/en/application-dev/reference/apis/js-apis-application-abilitystage.md
@@ -1,6 +1,6 @@
# AbilityStage
-> **NOTE**
+> **NOTE**
> The initial APIs of this module are supported since API 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
@@ -45,15 +45,15 @@ Called when a specified ability is started.
**Parameters**
- | Name | Type | Mandatory | Description |
- | -------- | -------- | -------- | -------- |
- | want | [Want](js-apis-application-Want.md) | Yes | Information about the ability to start, such as the ability name and bundle name. |
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | want | [Want](js-apis-application-Want.md) | Yes| Information about the ability to start, such as the ability name and bundle name.|
**Return value**
- | Type | Description |
- | -------- | -------- |
- | string | Returns an ability ID. If this ability has been started, no new instance is created and the ability is placed at the top of the stack. Otherwise, a new instance is created and started. |
+ | Type| Description|
+ | -------- | -------- |
+ | string | Returns an ability ID. If this ability has been started, no new instance is created and the ability is placed at the top of the stack. Otherwise, a new instance is created and started.|
**Example**
@@ -77,9 +77,9 @@ Called when the global configuration is updated.
**Parameters**
- | Name | Type | Mandatory | Description |
- | -------- | -------- | -------- | -------- |
- | config | [Configuration](js-apis-configuration.md) | Yes | Callback invoked when the global configuration is updated. The global configuration indicates the configuration of the environment where the application is running and includes the language and color mode. |
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | config | [Configuration](js-apis-configuration.md) | Yes| Callback invoked when the global configuration is updated. The global configuration indicates the configuration of the environment where the application is running and includes the language and color mode.|
**Example**
@@ -92,10 +92,12 @@ Called when the global configuration is updated.
```
## AbilityStage.context
+context: AbilityStageContext;
+
Describes the configuration information about the context.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
- | Name | Type | Description |
- | ----------- | --------------------------- | ------------------------------------------------------------ |
- | context | [AbilityStageContext](js-apis-featureAbility.md) | Called when initialization is performed during ability startup. |
+| Name | Type | Description |
+| ----------- | --------------------------- | ------------------------------------------------------------ |
+| context | [AbilityStageContext](js-apis-featureAbility.md) | Called when initialization is performed during ability startup.|
diff --git a/en/application-dev/reference/apis/js-apis-application-applicationContext.md b/en/application-dev/reference/apis/js-apis-application-applicationContext.md
index 0dfc9de068ba3aef8c84594b18dcad2730034cf0..517d9fb529fce872c5972a1aada50ce9f9b54ec9 100644
--- a/en/application-dev/reference/apis/js-apis-application-applicationContext.md
+++ b/en/application-dev/reference/apis/js-apis-application-applicationContext.md
@@ -1,11 +1,17 @@
# ApplicationContext
-> **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.
-
+> **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.
+> The APIs of this module can be used only in the stage model.
Provides application-level context and APIs for registering and deregistering the ability lifecycle listener in an application.
+## Modules to Import
+
+```
+import Ability from '@ohos.application.Ability';
+```
## How to Use
@@ -36,14 +42,6 @@ Registers a listener to monitor the ability lifecycle of the application.
| ------ | ------------------------------ |
| number | ID of the registered listener. The ID is incremented by 1 each time the listener is registered. When the ID exceeds 2^63-1, **-1** is returned.|
-**Example**
-
- ```js
- let applicationContext = this.context.getApplicationContext();
- console.log("stage applicationContext: " + JSON.stringify(applicationContext));
- let lifecycleid = applicationContext.registerAbilityLifecycleCallback(AbilityLifecycleCallback);
- console.log("registerAbilityLifecycleCallback number: " + JSON.stringify(lifecycleid));
- ```
## ApplicationContext.unregisterAbilityLifecycleCallback
@@ -63,9 +61,47 @@ Deregisters the listener that monitors the ability lifecycle of the application.
**Example**
```js
- let applicationContext = this.context.getApplicationContext();
- console.log("stage applicationContext: " + JSON.stringify(applicationContext));
- applicationContext.unregisterAbilityLifecycleCallback(lifecycleid, (error, data) => {
- console.log("unregisterAbilityLifecycleCallback success, err: " + JSON.stringify(error));
- });
+ import AbilityStage from "@ohos.application.AbilityStage";
+
+ var lifecycleid;
+
+ export default class MyAbilityStage extends AbilityStage {
+ onCreate() {
+ console.log("MyAbilityStage onCreate")
+ let AbilityLifecycleCallback = {
+ onAbilityCreate(ability){
+ console.log("AbilityLifecycleCallback onAbilityCreate ability:" + JSON.stringify(ability));
+ },
+ onAbilityWindowStageCreate(ability){
+ console.log("AbilityLifecycleCallback onAbilityWindowStageCreate ability:" + JSON.stringify(ability));
+ },
+ onAbilityWindowStageDestroy(ability){
+ console.log("AbilityLifecycleCallback onAbilityWindowStageDestroy ability:" + JSON.stringify(ability));
+ },
+ onAbilityDestroy(ability){
+ console.log("AbilityLifecycleCallback onAbilityDestroy ability:" + JSON.stringify(ability));
+ },
+ onAbilityForeground(ability){
+ console.log("AbilityLifecycleCallback onAbilityForeground ability:" + JSON.stringify(ability));
+ },
+ onAbilityBackground(ability){
+ console.log("AbilityLifecycleCallback onAbilityBackground ability:" + JSON.stringify(ability));
+ },
+ onAbilityContinue(ability){
+ console.log("AbilityLifecycleCallback onAbilityContinue ability:" + JSON.stringify(ability));
+ }
+ }
+ // 1. Obtain applicationContext through the context attribute.
+ let applicationContext = this.context.getApplicationContext();
+ // 2. Use applicationContext to register a listener for the ability lifecycle in the application.
+ lifecycleid = applicationContext.registerAbilityLifecycleCallback(AbilityLifecycleCallback);
+ console.log("registerAbilityLifecycleCallback number: " + JSON.stringify(lifecycleid));
+ }
+ onDestroy() {
+ let applicationContext = this.context.getApplicationContext();
+ applicationContext.unregisterAbilityLifecycleCallback(lifecycleid, (error, data) => {
+ console.log("unregisterAbilityLifecycleCallback success, err: " + JSON.stringify(error));
+ });
+ }
+ }
```
diff --git a/en/application-dev/reference/apis/js-apis-application-context.md b/en/application-dev/reference/apis/js-apis-application-context.md
index 38ceb059efc27760cefb03b1c04fdd66a4f614e3..66cd6b7150041bdbf45d4d0e0adf105e0ade044b 100644
--- a/en/application-dev/reference/apis/js-apis-application-context.md
+++ b/en/application-dev/reference/apis/js-apis-application-context.md
@@ -1,8 +1,9 @@
# Context
->  **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.
-
+> **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.
+> The APIs of this module can be used only in the stage model.
Provides the context for running code, including **applicationInfo** and **resourceManager**.
@@ -19,43 +20,43 @@ You must extend **AbilityContext** to implement this module.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
- | Name| Type| Readable| Writable| Description|
+ | Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
-| resourceManager | ResourceManager | Yes| No| **ResourceManager** object.|
-| applicationInfo | ApplicationInfo | Yes| No| Information about the application.|
-| cacheDir | string | Yes| No| Cache directory of the application on the internal storage.|
-| tempDir | string | Yes| No| Temporary file directory of the application.|
-| filesDir | string | Yes| No| File directory of the application on the internal storage.|
-| databaseDir | string | Yes| No| Storage directory of local data.|
-| storageDir | string | Yes| No| Storage directory of lightweight data.|
-| bundleCodeDir | string | Yes| No| Application installation path.|
-| distributedFilesDir | string | Yes| No| Storage directory of distributed application data files.|
-| eventHub | [EventHub](js-apis-eventhub.md) | Yes| No| Event hub information.|
-| area | [AreaMode](#areamode) | Yes| Yes| Area in which the file to be access is located.|
+| resourceManager | ResourceManager | Yes| No| **ResourceManager** object.|
+| applicationInfo | ApplicationInfo | Yes| No| Information about the application.|
+| cacheDir | string | Yes| No| Cache directory of the application on the internal storage.|
+| tempDir | string | Yes| No| Temporary file directory of the application.|
+| filesDir | string | Yes| No| File directory of the application on the internal storage.|
+| databaseDir | string | Yes| No| Storage directory of local data.|
+| storageDir | string | Yes| No| Storage directory of lightweight data.|
+| bundleCodeDir | string | Yes| No| Application installation path.|
+| distributedFilesDir | string | Yes| No| Storage directory of distributed application data files.|
+| eventHub | [EventHub](js-apis-eventhub.md) | Yes| No| Event hub information.|
+| area | [AreaMode](#areamode) | Yes| Yes| Area in which the file to be access is located.|
## Context.createBundleContext
createBundleContext(bundleName: string): Context;
-Creates an application context.
+Creates a context for a given application.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
- | Name| Type| Mandatory| Description|
+ | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
- | bundleName | string | Yes| Application bundle name.|
+ | bundleName | string | Yes| Application bundle name.|
**Return value**
- | Type| Description|
+ | Type| Description|
| -------- | -------- |
- | Context | Context of the application created.|
+ | Context | Context created.|
**Example**
-
+
```js
import AbilityContext from '@ohos.application.Ability'
class MainAbility extends AbilityContext {
@@ -68,6 +69,76 @@ Creates an application context.
```
+## Context.createModuleContext
+
+createModuleContext(moduleName: string): Context;
+
+Creates a context for a given HAP.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**Parameters**
+
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | moduleName | string | Yes| HAP name in the application.|
+
+**Return value**
+
+ | Type| Description|
+ | -------- | -------- |
+ | Context | Context created.|
+
+**Example**
+
+ ```js
+ import AbilityContext from '@ohos.application.Ability'
+ class MainAbility extends AbilityContext {
+ onWindowStageCreate(windowStage) {
+ let moduleName = "module";
+ let context = this.context.createModuleContext(moduleName);
+ }
+}
+
+ ```
+
+
+## Context.createModuleContext
+
+createModuleContext(bundleName: string, moduleName: string): Context;
+
+Creates a context for a given HAP in an application.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**Parameters**
+
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | bundleName | string | Yes| Application bundle name.|
+ | moduleName | string | Yes| HAP name in the application.|
+
+**Return value**
+
+ | Type| Description|
+ | -------- | -------- |
+ | Context | Context created.|
+
+**Example**
+
+ ```js
+ import AbilityContext from '@ohos.application.Ability'
+ class MainAbility extends AbilityContext {
+ onWindowStageCreate(windowStage) {
+ let bundleName = "com.example.bundle";
+ let moduleName = "module";
+ let context = this.context.createModuleContext(bundleName, moduleName);
+ }
+}
+
+ ```
+
+
## Context.getApplicationContext
getApplicationContext(): ApplicationContext;
@@ -83,7 +154,7 @@ Obtains the context of this application.
| ApplicationContext | Current application context.|
**Example**
-
+
```js
// This part is mandatory.
let applicationContext = this.context.getApplicationContext();
diff --git a/en/application-dev/reference/apis/js-apis-appmanager.md b/en/application-dev/reference/apis/js-apis-appmanager.md
index 68e4bb1c64d879b3371533ab1de731ca763d4c9d..96c9bd009552016f88cc361103b15eb725828195 100644
--- a/en/application-dev/reference/apis/js-apis-appmanager.md
+++ b/en/application-dev/reference/apis/js-apis-appmanager.md
@@ -25,9 +25,9 @@ Checks whether this application is undergoing a stability test. This API uses an
**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | callback | AsyncCallback<boolean> | No| Callback used to return the result. If the application is undergoing a stability test, **true** will be returned; otherwise, **false** will be returned.|
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| callback | AsyncCallback<boolean> | No| Callback used to return the result. If the application is undergoing a stability test, **true** will be returned; otherwise, **false** will be returned.|
**Example**
@@ -49,9 +49,9 @@ Checks whether this application is undergoing a stability test. This API uses a
**Return value**
- | Type| Description|
- | -------- | -------- |
- | Promise<boolean> | Promise used to return the result. If the application is undergoing a stability test, **true** will be returned; otherwise, **false** will be returned.|
+| Type| Description|
+| -------- | -------- |
+| Promise<boolean> | Promise used to return the result. If the application is undergoing a stability test, **true** will be returned; otherwise, **false** will be returned.|
**Example**
@@ -75,9 +75,9 @@ Checks whether this application is running on a RAM constrained device. This API
**Return value**
- | Type| Description|
- | -------- | -------- |
- | Promise<boolean> | Promise used to return whether the application is running on a RAM constrained device. If the application is running on a RAM constrained device, **true** will be returned; otherwise, **false** will be returned.|
+| Type| Description|
+| -------- | -------- |
+| Promise<boolean> | Promise used to return whether the application is running on a RAM constrained device. If the application is running on a RAM constrained device, **true** will be returned; otherwise, **false** will be returned.|
**Example**
@@ -99,9 +99,9 @@ Checks whether this application is running on a RAM constrained device. This API
**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | callback | AsyncCallback<boolean> | No| Callback used to return whether the application is running on a RAM constrained device. If the application is running on a RAM constrained device, **true** will be returned; otherwise, **false** will be returned.|
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| callback | AsyncCallback<boolean> | No| Callback used to return whether the application is running on a RAM constrained device. If the application is running on a RAM constrained device, **true** will be returned; otherwise, **false** will be returned.|
**Example**
@@ -122,9 +122,9 @@ Obtains the memory size of this application. This API uses a promise to return t
**Return value**
- | Type| Description|
- | -------- | -------- |
- | Promise<number> | Size of the application memory.|
+| Type| Description|
+| -------- | -------- |
+| Promise<number> | Size of the application memory.|
**Example**
@@ -146,9 +146,9 @@ Obtains the memory size of this application. This API uses an asynchronous callb
**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | callback | AsyncCallback<number> | No| Size of the application memory.|
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| callback | AsyncCallback<number> | No| Size of the application memory.|
**Example**
@@ -160,7 +160,7 @@ Obtains the memory size of this application. This API uses an asynchronous callb
```
## appManager.getProcessRunningInfos8+
-getProcessRunningInfos(): Promise>;
+getProcessRunningInfos(): Promise\>;
Obtains information about the running processes. This API uses a promise to return the result.
@@ -168,9 +168,9 @@ Obtains information about the running processes. This API uses a promise to retu
**Return value**
- | Type| Description|
- | -------- | -------- |
- | Promise> | Promise used to return the process information.|
+| Type| Description|
+| -------- | -------- |
+| Promise\> | Promise used to return the process information.|
**Example**
@@ -184,7 +184,7 @@ Obtains information about the running processes. This API uses a promise to retu
## appManager.getProcessRunningInfos8+
-getProcessRunningInfos(callback: AsyncCallback>): void;
+getProcessRunningInfos(callback: AsyncCallback\>): void;
Obtains information about the running processes. This API uses an asynchronous callback to return the result.
@@ -192,9 +192,9 @@ Obtains information about the running processes. This API uses an asynchronous c
**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | callback | AsyncCallback> | No| Callback used to return the process information.|
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| callback | AsyncCallback\> | No| Callback used to return the process information.|
**Example**
diff --git a/en/application-dev/reference/apis/js-apis-arraylist.md b/en/application-dev/reference/apis/js-apis-arraylist.md
index 2290f5d295d182f700248afc45d131bb51aea79a..a887e9a02b24275e2574ea5fac7ecee0ac49f723 100644
--- a/en/application-dev/reference/apis/js-apis-arraylist.md
+++ b/en/application-dev/reference/apis/js-apis-arraylist.md
@@ -1,25 +1,32 @@
# Linear Container ArrayList
->  **NOTE**
+> **NOTE**
+>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
+**ArrayList** is a linear data structure that is implemented based on arrays. **ArrayList** can dynamically adjust the capacity based on project requirements. It increases the capacity by 50% each time.
+
+Similar to **ArrayList**, **[Vector](js-apis-vector.md)** is also implemented based on arrays and can dynamically adjust the capacity. It increases the capability by 100% each time.
+
+When compared with **[LinkedList](js-apis-linkedlist.md)**, **ArrayList** is more efficient in random access but less efficient in the addition or removal operation, because its addition or removal operation affects the position of other elements in the container.
+
+**Recommended use case**: Use **ArrayList** when elements in a container need to be frequently read.
+
## Modules to Import
```ts
-import ArrayList from '@ohos.util.ArrayList'
+import ArrayList from '@ohos.util.ArrayList';
```
-## System Capabilities
-
-SystemCapability.Utils.Lang
-
## ArrayList
### Attributes
+**System capability**: SystemCapability.Utils.Lang
+
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
-| length | number | Yes| No| Number of entries in an array list (called container later).|
+| length | number | Yes| No| Number of elements in an array list (called container later).|
### constructor
@@ -28,6 +35,8 @@ constructor()
A constructor used to create an **ArrayList** instance.
+**System capability**: SystemCapability.Utils.Lang
+
**Example**
```ts
@@ -39,19 +48,21 @@ let arrayList = new ArrayList();
add(element: T): boolean
-Adds an entry at the end of this container.
+Adds an element at the end of this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| element | T | Yes| Entry to add.|
+| element | T | Yes| Target element.|
**Return value**
| Type| Description|
| -------- | -------- |
-| boolean | Returns **true** if the entry is added successfully; returns **false** otherwise.|
+| boolean | Returns **true** if the element is added successfully; returns **false** otherwise.|
**Example**
@@ -69,14 +80,16 @@ Adds an entry at the end of this container.
insert(element: T, index: number): void
-Inserts an entry at the specified position in this container.
+Inserts an element at the specified position in this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| element | T | Yes| Entry to insert.|
-| index | number | Yes| Index of the position where the entry is to be inserted.|
+| element | T | Yes| Target element.|
+| index | number | Yes| Index of the position where the element is to be inserted.|
**Example**
@@ -91,19 +104,21 @@ arrayList.insert(true, 2);
has(element: T): boolean
-Checks whether this container has the specified entry.
+Checks whether this container has the specified element.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| element | T | Yes| Entry to check.|
+| element | T | Yes| Target element.|
**Return value**
| Type| Description|
| -------- | -------- |
-| boolean | Returns **true** if the specified entry is contained; returns **false** otherwise.|
+| boolean | Returns **true** if the specified element is contained; returns **false** otherwise.|
**Example**
@@ -118,19 +133,21 @@ let result1 = arrayList.has("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
getIndexOf(element: T): number
-Obtains the index of the first occurrence of the specified entry in this container.
+Obtains the index of the first occurrence of the specified element in this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| element | T | Yes| Entry to query.|
+| element | T | Yes| Target element.|
**Return value**
| Type| Description|
| -------- | -------- |
-| number | Returns the position index if obtained; returns **-1** if the specified entry is not found.|
+| number | Returns the position index if obtained; returns **-1** if the specified element is not found.|
**Example**
@@ -150,19 +167,21 @@ let result = arrayList.getIndexOf(2);
getLastIndexOf(element: T): number
-Obtains the index of the last occurrence of the specified entry in this container.
+Obtains the index of the last occurrence of the specified element in this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| element | T | Yes| Entry to query.|
+| element | T | Yes| Target element.|
**Return value**
| Type| Description|
| -------- | -------- |
-| number | Returns the position index if obtained; returns **-1** if the specified entry is not found.|
+| number | Returns the position index if obtained; returns **-1** if the specified element is not found.|
**Example**
@@ -182,19 +201,21 @@ let result = arrayList.getLastIndexOf(2);
removeByIndex(index: number): T
-Removes an entry with the specified position from this container.
+Removes an element with the specified position from this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| index | number | Yes| Position index of the entry to remove.|
+| index | number | Yes| Position index of the target element.|
**Return value**
| Type| Description|
| -------- | -------- |
-| T | Entry removed.|
+| T | Element removed.|
**Example**
@@ -212,19 +233,21 @@ let result = arrayList.removeByIndex(2);
remove(element: T): boolean
-Removes the first occurrence of the specified entry from this container.
+Removes the first occurrence of the specified element from this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| element | T | Yes| Entry to remove.|
+| element | T | Yes| Target element.|
**Return value**
| Type| Description|
| -------- | -------- |
-| boolean | Returns **true** if the entry is removed successfully; returns **false** otherwise.|
+| boolean | Returns **true** if the element is removed successfully; returns **false** otherwise.|
**Example**
@@ -241,7 +264,9 @@ let result = arrayList.remove(2);
removeByRange(fromIndex: number, toIndex: number): void
-Removes from this container all of the entries within a range, including the entry at the start position but not that at the end position.
+Removes from this container all of the elements within a range, including the element at the start position but not that at the end position.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
@@ -268,7 +293,9 @@ arrayList.removeByRange(2, 6);
replaceAllElements(callbackfn: (value: T, index?: number, arrlist?: ArrayList<T>) => T,
thisArg?: Object): void
-Replaces all entries in this container with new entries, and returns the new ones.
+Replaces all elements in this container with new elements, and returns the new ones.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
@@ -281,8 +308,8 @@ callbackfn
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| value | T | Yes| Value of the entry that is currently traversed.|
-| index | number | No| Position index of the entry that is currently traversed.|
+| value | T | Yes| Value of the element that is currently traversed.|
+| index | number | No| Position index of the element that is currently traversed.|
| arrlist | ArrayList<T> | No| Instance that invokes the **replaceAllElements** method.|
**Example**
@@ -306,21 +333,23 @@ arrayList.replaceAllElements((value, index) => {
forEach(callbackfn: (value: T, index?: number, arrlist?: ArrayList<T>) => void,
thisArg?: Object): void
-Uses a callback to traverse the entries in this container and obtain their position indexes.
+Uses a callback to traverse the elements in this container and obtain their position indexes.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| callbackfn | function | Yes| Callback invoked to traverse the entries in the container.|
+| callbackfn | function | Yes| Callback invoked to traverse the elements in the container.|
| thisArg | Object | No| Value to use when the callback is invoked.|
callbackfn
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| value | T | Yes| Value of the entry that is currently traversed.|
-| index | number | No| Position index of the entry that is currently traversed.|
+| value | T | Yes| Value of the element that is currently traversed.|
+| index | number | No| Position index of the element that is currently traversed.|
| arrlist | ArrayList<T> | No| Instance that invokes the **forEach** method.|
**Example**
@@ -332,7 +361,7 @@ arrayList.add(4);
arrayList.add(5);
arrayList.add(4);
arrayList.forEach((value, index) => {
- console.log(value, index);
+ console.log("value:" + value, index);
});
```
@@ -340,7 +369,9 @@ arrayList.forEach((value, index) => {
sort(comparator?: (firstValue: T, secondValue: T) => number): void
-Sorts entries in this container.
+Sorts elements in this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
@@ -352,8 +383,8 @@ comparator
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| firstValue | T | Yes| Previous entry.|
-| secondValue | T | Yes| Next entry.|
+| firstValue | T | Yes| Previous element.|
+| secondValue | T | Yes| Next element.|
**Example**
@@ -363,8 +394,8 @@ arrayList.add(2);
arrayList.add(4);
arrayList.add(5);
arrayList.add(4);
-arrayList.sort(a, (b => a - b));
-arrayList.sort(a, (b => b - a));
+arrayList.sort((a, b) => a - b);
+arrayList.sort((a, b) => b - a);
arrayList.sort();
```
@@ -372,7 +403,9 @@ arrayList.sort();
subArrayList(fromIndex: number, toIndex: number): ArrayList<T>
-Obtains entries within a range in this container, including the entry at the start position but not that at the end position, and returns these entries as a new **ArrayList** instance.
+Obtains elements within a range in this container, including the element at the start position but not that at the end position, and returns these elements as a new **ArrayList** instance.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
@@ -406,6 +439,8 @@ clear(): void
Clears this container and sets its length to **0**.
+**System capability**: SystemCapability.Utils.Lang
+
**Example**
```ts
@@ -423,6 +458,8 @@ clone(): ArrayList<T>
Clones this container and returns a copy. The modification to the copy does not affect the original instance.
+**System capability**: SystemCapability.Utils.Lang
+
**Return value**
@@ -447,6 +484,8 @@ getCapacity(): number
Obtains the capacity of this container.
+**System capability**: SystemCapability.Utils.Lang
+
**Return value**
| Type| Description|
@@ -470,6 +509,8 @@ convertToArray(): Array<T>
Converts this container into an array.
+**System capability**: SystemCapability.Utils.Lang
+
**Return value**
| Type| Description|
@@ -491,7 +532,9 @@ let result = arrayList.convertToArray();
isEmpty(): boolean
-Checks whether this container is empty (contains no entry).
+Checks whether this container is empty (contains no element).
+
+**System capability**: SystemCapability.Utils.Lang
**Return value**
@@ -516,6 +559,8 @@ increaseCapacityTo(newCapacity: number): void
Increases the capacity of this container.
+**System capability**: SystemCapability.Utils.Lang
+
**Parameters**
| Name| Type| Mandatory| Description|
@@ -540,6 +585,8 @@ trimToCurrentLength(): void
Trims the capacity of this container to its current length.
+**System capability**: SystemCapability.Utils.Lang
+
**Example**
```ts
@@ -557,6 +604,8 @@ arrayList.trimToCurrentLength();
Obtains an iterator, each item of which is a JavaScript object.
+**System capability**: SystemCapability.Utils.Lang
+
**Return value**
| Type| Description|
@@ -574,14 +623,14 @@ arrayList.add(4);
// Method 1:
for (let item of arrayList) {
- console.log(item);
+ console.log("value:" + item);
}
// Method 2:
let iter = arrayList[Symbol.iterator]();
let temp = iter.next().value;
while(temp != undefined) {
- console.log(temp);
+ console.log("value:" + temp);
temp = iter.next().value;
}
```
diff --git a/en/application-dev/reference/apis/js-apis-audio.md b/en/application-dev/reference/apis/js-apis-audio.md
index ba1eff24fb67f721a0c756d09382e1c0342b26d8..3a449fb0426baae2532bd3ad2f748d5af49263ec 100644
--- a/en/application-dev/reference/apis/js-apis-audio.md
+++ b/en/application-dev/reference/apis/js-apis-audio.md
@@ -1,13 +1,13 @@
# Audio Management
-> **NOTE**
-> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
+> **NOTE**
+> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
This module provides the following common audio-related functions:
-- [AudioManager](#audiomanager): Audio management.
-- [AudioRenderer](#audiorenderer8): Audio rendering, used to play Pulse Code Modulation (PCM) audio data.
-- [AudioCapturer](#audiocapturer8): Audio capture, used to record PCM audio data.
+- [AudioManager](#audiomanager): audio management.
+- [AudioRenderer](#audiorenderer8): audio rendering, used to play Pulse Code Modulation (PCM) audio data.
+- [AudioCapturer](#audiocapturer8): audio capture, used to record PCM audio data.
## Modules to Import
@@ -15,22 +15,21 @@ This module provides the following common audio-related functions:
import audio from '@ohos.multimedia.audio';
```
+
## audio.getAudioManager
getAudioManager(): AudioManager
Obtains an **AudioManager** instance.
-**System capability:** SystemCapability.Multimedia.Audio.Core
-
-**Return value:**
-
-| Type | Description |
-| ----------------------------- | -------------------- |
-| [AudioManager](#audiomanager) | AudioManager object. |
+**System capability**: SystemCapability.Multimedia.Audio.Core
-**Example:**
+**Return value**
+| Type | Description |
+| ----------------------------- | ------------ |
+| [AudioManager](#audiomanager) | **AudioManager** instance.|
+**Example**
```
var audioManager = audio.getAudioManager();
```
@@ -39,17 +38,18 @@ var audioManager = audio.getAudioManager();
createAudioRenderer(options: AudioRendererOptions, callback: AsyncCallback\): void
-Obtains an **AudioRenderer** instance. This API uses an asynchronous callback to return the renderer instance.
+Obtains an **AudioRenderer** instance. This API uses an asynchronous callback to return the result.
-**System capability:** SystemCapability.Multimedia.Audio.Renderer
+**System capability**: SystemCapability.Multimedia.Audio.Renderer
-**Parameters:**
-| Name | Type | Mandatory | Description |
-| :--------- | :---------------------------------------------- | :-------- | :--------------------------------------------------- |
-| options | [AudioRendererOptions](#audiorendereroptions8) | Yes | Renderer configurations. |
-| callback | AsyncCallback<[AudioRenderer](#audiorenderer8)> | Yes | Callback used to return the audio renderer instance. |
+**Parameters**
-**Example:**
+| Name | Type | Mandatory| Description |
+| -------- | ----------------------------------------------- | ---- | ---------------- |
+| options | [AudioRendererOptions](#audiorendereroptions8) | Yes | Renderer configurations. |
+| callback | AsyncCallback<[AudioRenderer](#audiorenderer8)> | Yes | Callback used to return the **AudioRenderer** instance.|
+
+**Example**
```
import audio from '@ohos.multimedia.audio';
@@ -81,26 +81,28 @@ audio.createAudioRenderer(audioRendererOptions,(err, data) => {
}
});
```
+
## audio.createAudioRenderer8+
-createAudioRenderer(options: AudioRendererOptions): Promise
+createAudioRenderer(options: AudioRendererOptions): Promise
-Obtains an **AudioRenderer** instance. This API uses a promise to return the renderer instance.
+Obtains an **AudioRenderer** instance. This API uses a promise to return the result.
-**System capability:** SystemCapability.Multimedia.Audio.Renderer
+**System capability**: SystemCapability.Multimedia.Audio.Renderer
-**Parameters:**
-| Name | Type | Mandatory | Description |
-| :--------- | :--------------------------------------------- | :-------- | :---------------------------|
-| options | [AudioRendererOptions](#audiorendereroptions8) | Yes | Renderer configurations. |
+**Parameters**
-**Return value:**
+| Name | Type | Mandatory| Description |
+| :------ | :--------------------------------------------- | :--- | :----------- |
+| options | [AudioRendererOptions](#audiorendereroptions8) | Yes | Renderer configurations.|
-| Type | Description |
-| ----------------------------------------- | --------------------------------------------------- |
-| Promise<[AudioRenderer](#audiorenderer8)> | Promise used to return the audio renderer instance. |
+**Return value**
-**Example:**
+| Type | Description |
+| ----------------------------------------- | ---------------- |
+| Promise<[AudioRenderer](#audiorenderer8)> | Promise used to return the **AudioRenderer** instance.|
+
+**Example**
```
import audio from '@ohos.multimedia.audio';
@@ -136,17 +138,18 @@ audio.createAudioRenderer(audioRendererOptions).then((data) => {
createAudioCapturer(options: AudioCapturerOptions, callback: AsyncCallback): void
-Obtains an **AudioCapturer** instance. This API uses an asynchronous callback to return the capturer instance.
+Obtains an **AudioCapturer** instance. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Multimedia.Audio.Capturer
-**System capability:** SystemCapability.Multimedia.Audio.Capturer
+**Parameters**
-**Parameters:**
-| Name | Type | Mandatory | Description |
-| :--------- | :---------------------------------------------- | :-------- | :--------------------------------------------------- |
-| options | [AudioCapturerOptions](#audiocaptureroptions8) | Yes | Capturer configurations. |
-| callback | AsyncCallback<[AudioCapturer](#audiocapturer8)> | Yes | Callback used to return the audio capturer instance. |
+| Name | Type | Mandatory| Description |
+| :------- | :---------------------------------------------- | :--- | :--------------- |
+| options | [AudioCapturerOptions](#audiocaptureroptions8) | Yes | Capturer configurations.|
+| callback | AsyncCallback<[AudioCapturer](#audiocapturer8)> | Yes | Callback used to return the **AudioCapturer** instance.|
-**Example:**
+**Example**
```
import audio from '@ohos.multimedia.audio';
@@ -182,22 +185,23 @@ audio.createAudioCapturer(audioCapturerOptions,(err, data) => {
createAudioCapturer(options: AudioCapturerOptions): Promise
-Obtains an **AudioCapturer** instance. This API uses a promise to return the capturer instance.
+Obtains an **AudioCapturer** instance. This API uses a promise to return the result.
-**System capability:** SystemCapability.Multimedia.Audio.Capturer
+**System capability**: SystemCapability.Multimedia.Audio.Capturer
-**Parameters:**
-| Name | Type | Mandatory | Description |
-| :--------- | :-------------------------------------------- | :-------- | :-------------------------- |
-| options | [AudioCapturerOptions](#audiocaptureroptions8) | Yes | Capturer configurations. |
+**Parameters**
-**Return value:**
+| Name | Type | Mandatory| Description |
+| :------ | :--------------------------------------------- | :--- | :--------------- |
+| options | [AudioCapturerOptions](#audiocaptureroptions8) | Yes | Capturer configurations.|
-| Type | Description |
-| ----------------------------------------- | --------------------------------------------------- |
-| Promise<[AudioCapturer](#audiocapturer8)> | Promise used to return the audio capturer instance. |
+**Return value**
-**Example:**
+| Type | Description |
+| ----------------------------------------- | -------------- |
+| Promise<[AudioCapturer](#audiocapturer8)> | Promise used to return the **AudioCapturer** instance.|
+
+**Example**
```
import audio from '@ohos.multimedia.audio';
@@ -230,432 +234,432 @@ audio.createAudioCapturer(audioCapturerOptions).then((data) => {
## AudioVolumeType
-Enumerates audio stream types.
+Enumerates the audio stream types.
+
+**System capability**: SystemCapability.Multimedia.Audio.Volume
-**System capability:** SystemCapability.Multimedia.Audio.Volume
+| Name | Default Value| Description |
+| ---------------------------- | ------ | ---------- |
+| VOICE_CALL8+ | 0 | Audio stream for voice calls.|
+| RINGTONE | 2 | Audio stream for ringtones. |
+| MEDIA | 3 | Audio stream for media purpose. |
+| VOICE_ASSISTANT8+ | 9 | Audio stream for voice assistant.|
-| Name | Default Value | Description |
-| ---------------------------- | -------------- | --------------------------------- |
-| VOICE_CALL8+ | 0 | Audio stream for voice calls. |
-| RINGTONE | 2 | Audio stream for ringtones. |
-| MEDIA | 3 | Audio stream for media purpose. |
-| VOICE_ASSISTANT8+ | 9 | Audio stream for voice assistant. |
+
+## InterruptMode9+
+
+Enumerates the audio interruption modes.
+
+**System capability**: SystemCapability.Multimedia.Audio.InterruptMode
+
+| Name | Default Value| Description |
+| ---------------------------- | ------ | ---------- |
+| SHARE_MODE | 0 | Share mode.|
+| INDEPENDENT_MODE| 1 | Independent mode. |
## DeviceFlag
-Enumerates audio device flags.
+Enumerates the audio device flags.
-**System capability:** SystemCapability.Multimedia.Audio.Device
+**System capability**: SystemCapability.Multimedia.Audio.Device
-| Name | Default Value | Description |
-| ------------------- | ------------- | -------------- |
-| OUTPUT_DEVICES_FLAG | 1 | Output device. |
-| INPUT_DEVICES_FLAG | 2 | Input device. |
-| ALL_DEVICES_FLAG | 3 | All devices. |
+| Name | Default Value| Description |
+| ------------------- | ------ | ---------- |
+| OUTPUT_DEVICES_FLAG | 1 | Output device.|
+| INPUT_DEVICES_FLAG | 2 | Input device.|
+| ALL_DEVICES_FLAG | 3 | All devices.|
## DeviceRole
-Enumerates audio device roles.
+Enumerates the audio device roles.
+
+**System capability**: SystemCapability.Multimedia.Audio.Device
-**System capability:** SystemCapability.Multimedia.Audio.Device
+| Name | Default Value| Description |
+| ------------- | ------ | -------------- |
+| INPUT_DEVICE | 1 | Input role.|
+| OUTPUT_DEVICE | 2 | Output role.|
-| Name | Default Value | Description |
-| ------------- | ------------- | ------------ |
-| INPUT_DEVICE | 1 | Input role. |
-| OUTPUT_DEVICE | 2 | Output role. |
## DeviceType
-Enumerates audio device types.
+Enumerates the audio device types.
-**System capability:** SystemCapability.Multimedia.Audio.Device
+**System capability**: SystemCapability.Multimedia.Audio.Device
-| Name | Default Value | Description |
-| ---------------- | ------------- | ------------------------------------------------------------------------ |
-| INVALID | 0 | Invalid device. |
-| EARPIECE | 1 | Earpiece. |
-| SPEAKER | 2 | Speaker. |
-| WIRED_HEADSET | 3 | Wired headset. |
-| WIRED_HEADPHONES | 4 | Wired headset without microphone. |
-| BLUETOOTH_SCO | 7 | Bluetooth device using Synchronous Connection Oriented (SCO) links. |
-| BLUETOOTH_A2DP | 8 | Bluetooth device using Advanced Audio Distribution Profile (A2DP) links. |
-| MIC | 15 | Microphone. |
-| USB_HEADSET | 22 | USB Type-C headset. |
+| Name | Default Value| Description |
+| ---------------- | ------ | --------------------------------------------------------- |
+| INVALID | 0 | Invalid device. |
+| EARPIECE | 1 | Earpiece. |
+| SPEAKER | 2 | Speaker. |
+| WIRED_HEADSET | 3 | Wired headset with a microphone. |
+| WIRED_HEADPHONES | 4 | Wired headset without microphone. |
+| BLUETOOTH_SCO | 7 | Bluetooth device using Synchronous Connection Oriented (SCO) links. |
+| BLUETOOTH_A2DP | 8 | Bluetooth device using Advanced Audio Distribution Profile (A2DP) links.|
+| MIC | 15 | Microphone. |
+| USB_HEADSET | 22 | USB Type-C headset. |
## ActiveDeviceType
Enumerates the active device types.
-**System capability:** SystemCapability.Multimedia.Audio.Device
+**System capability**: SystemCapability.Multimedia.Audio.Device
-| Name | Default Value | Description |
-| ------------- | ------------- | ---------------------------------------------------------------------- |
-| SPEAKER | 2 | Speaker. |
-| BLUETOOTH_SCO | 7 | Bluetooth device using the SCO links. |
+| Name | Default Value| Description |
+| ------------- | ------ | ---------------------------------------------------- |
+| SPEAKER | 2 | Speaker. |
+| BLUETOOTH_SCO | 7 | Bluetooth device using the SCO links.|
## AudioRingMode
-Enumerates ringer modes.
+Enumerates the ringer modes.
-**System capability:** SystemCapability.Multimedia.Audio.Communication
+**System capability**: SystemCapability.Multimedia.Audio.Communication
-| Name | Default Value | Description |
-| ------------------- | ------------- | ---------------- |
-| RINGER_MODE_SILENT | 0 | Silent mode. |
-| RINGER_MODE_VIBRATE | 1 | Vibration mode. |
-| RINGER_MODE_NORMAL | 2 | Normal mode. |
+| Name | Default Value| Description |
+| ------------------- | ------ | ---------- |
+| RINGER_MODE_SILENT | 0 | Silent mode.|
+| RINGER_MODE_VIBRATE | 1 | Vibration mode.|
+| RINGER_MODE_NORMAL | 2 | Normal mode.|
## AudioSampleFormat8+
-Enumerates the audio sample formats.
+Enumerate the audio sample formats.
-**System capability:** SystemCapability.Multimedia.Audio.Core
+**System capability**: SystemCapability.Multimedia.Audio.Core
-| Name | Default Value | Description |
-| :-------------------- | :------------ | :------------------------------------ |
-| SAMPLE_FORMAT_INVALID | -1 | Invalid format. |
-| SAMPLE_FORMAT_U8 | 0 | Unsigned 8 bit integer. |
-| SAMPLE_FORMAT_S16LE | 1 | Signed 16 bit integer, little endian. |
-| SAMPLE_FORMAT_S24LE | 2 | Signed 24 bit integer, little endian. |
-| SAMPLE_FORMAT_S32LE | 3 | Signed 32 bit integer, little endian. |
+| Name | Default Value| Description |
+| --------------------- | ------ | -------------------------- |
+| SAMPLE_FORMAT_INVALID | -1 | Invalid format. |
+| SAMPLE_FORMAT_U8 | 0 | Unsigned 8-bit integer. |
+| SAMPLE_FORMAT_S16LE | 1 | Signed 16-bit integer, little endian.|
+| SAMPLE_FORMAT_S24LE | 2 | Signed 24-bit integer, little endian.|
+| SAMPLE_FORMAT_S32LE | 3 | Signed 32-bit integer, little endian.|
## AudioChannel8+
Enumerates the audio channels.
-**System capability:** SystemCapability.Multimedia.Audio.Core
+**System capability**: SystemCapability.Multimedia.Audio.Core
-| Name | Default Value | Description |
-| :-------- | :------------ | :--------------- |
-| CHANNEL_1 | 0x1 << 0 | Channel count 1. |
-| CHANNEL_2 | 0x1 << 1 | Channel count 2. |
+| Name | Default Value | Description |
+| --------- | -------- | -------- |
+| CHANNEL_1 | 0x1 << 0 | Mono.|
+| CHANNEL_2 | 0x1 << 1 | Dual-channel.|
## AudioSamplingRate8+
Enumerates the audio sampling rates.
-**System capability:** SystemCapability.Multimedia.Audio.Core
-
-| Name | Default Value | Description |
-| :---------------- | :------------ | :------------------- |
-| SAMPLE_RATE_8000 | 8000 | Sampling rate 8000. |
-| SAMPLE_RATE_11025 | 11025 | Sampling rate 11025. |
-| SAMPLE_RATE_12000 | 12000 | Sampling rate 12000. |
-| SAMPLE_RATE_16000 | 16000 | Sampling rate 16000. |
-| SAMPLE_RATE_22050 | 22050 | Sampling rate 22050. |
-| SAMPLE_RATE_24000 | 24000 | Sampling rate 24000. |
-| SAMPLE_RATE_32000 | 32000 | Sampling rate 32000. |
-| SAMPLE_RATE_44100 | 44100 | Sampling rate 44100. |
-| SAMPLE_RATE_48000 | 48000 | Sampling rate 48000. |
-| SAMPLE_RATE_64000 | 64000 | Sampling rate 64000. |
-| SAMPLE_RATE_96000 | 96000 | Sampling rate 96000. |
-
+**System capability**: SystemCapability.Multimedia.Audio.Core
+
+| Name | Default Value| Description |
+| ----------------- | ------ | --------------- |
+| SAMPLE_RATE_8000 | 8000 | The sampling rate is 8000. |
+| SAMPLE_RATE_11025 | 11025 | The sampling rate is 11025.|
+| SAMPLE_RATE_12000 | 12000 | The sampling rate is 12000.|
+| SAMPLE_RATE_16000 | 16000 | The sampling rate is 16000.|
+| SAMPLE_RATE_22050 | 22050 | The sampling rate is 22050.|
+| SAMPLE_RATE_24000 | 24000 | The sampling rate is 24000.|
+| SAMPLE_RATE_32000 | 32000 | The sampling rate is 32000.|
+| SAMPLE_RATE_44100 | 44100 | The sampling rate is 44100.|
+| SAMPLE_RATE_48000 | 48000 | The sampling rate is 48000.|
+| SAMPLE_RATE_64000 | 64000 | The sampling rate is 64000.|
+| SAMPLE_RATE_96000 | 96000 | The sampling rate is 96000.|
## AudioEncodingType8+
Enumerates the audio encoding types.
-**System capability:** SystemCapability.Multimedia.Audio.Core
-
-| Name | Default Value | Description |
-| :-------------------- | :------------- | :---------------- |
-| ENCODING_TYPE_INVALID | -1 | Invalid. |
-| ENCODING_TYPE_RAW | 0 | PCM encoding. |
+**System capability**: SystemCapability.Multimedia.Audio.Core
+| Name | Default Value| Description |
+| --------------------- | ------ | --------- |
+| ENCODING_TYPE_INVALID | -1 | Invalid. |
+| ENCODING_TYPE_RAW | 0 | PCM encoding.|
## ContentType
-Enumerates the content types.
-
-**System capability:** SystemCapability.Multimedia.Audio.Core
+Enumerates the audio content types.
-| Name | Default Value | Description |
-| :----------------------------------| :------------ | :---------------------- |
-| CONTENT_TYPE_UNKNOWN | 0 | Unknown content. |
-| CONTENT_TYPE_SPEECH | 1 | Speech content. |
-| CONTENT_TYPE_MUSIC | 2 | Music content. |
-| CONTENT_TYPE_MOVIE | 3 | Movie content. |
-| CONTENT_TYPE_SONIFICATION | 4 | Sonification content. |
-| CONTENT_TYPE_RINGTONE8+ | 5 | Ringtone content. |
+**System capability**: SystemCapability.Multimedia.Audio.Core
+| Name | Default Value| Description |
+| ---------------------------------- | ------ | ---------- |
+| CONTENT_TYPE_UNKNOWN | 0 | Unknown content.|
+| CONTENT_TYPE_SPEECH | 1 | Speech. |
+| CONTENT_TYPE_MUSIC | 2 | Music. |
+| CONTENT_TYPE_MOVIE | 3 | Movie. |
+| CONTENT_TYPE_SONIFICATION | 4 | Sonification content.|
+| CONTENT_TYPE_RINGTONE8+ | 5 | Ringtone. |
## StreamUsage
-Enumerates the stream usage.
+Enumerates the audio stream usage.
-**System capability:** SystemCapability.Multimedia.Audio.Core
-
-| Name | Default Value | Description |
-| :--------------------------------- | :------------ | :-------------------------------- |
-| STREAM_USAGE_UNKNOWN | 0 | Unknown usage. |
-| STREAM_USAGE_MEDIA | 1 | Media usage. |
-| STREAM_USAGE_VOICE_COMMUNICATION | 2 | Voice communication usage. |
-| STREAM_USAGE_NOTIFICATION_RINGTONE | 6 | Notification or ringtone usage. |
+**System capability**: SystemCapability.Multimedia.Audio.Core
+| Name | Default Value| Description |
+| ---------------------------------- | ------ | ---------- |
+| STREAM_USAGE_UNKNOWN | 0 | Unknown usage.|
+| STREAM_USAGE_MEDIA | 1 | Used for media. |
+| STREAM_USAGE_VOICE_COMMUNICATION | 2 | Used for voice communication.|
+| STREAM_USAGE_NOTIFICATION_RINGTONE | 6 | Used for notification.|
## AudioState8+
Enumerates the audio states.
-**System capability:** SystemCapability.Multimedia.Audio.Core
-
-| Name | Default Value | Description |
-| :------------- | :------------ | :--------------------------- |
-| STATE_INVALID | -1 | Invalid state. |
-| STATE_NEW | 0 | Creating new instance state. |
-| STATE_PREPARED | 1 | Prepared state. |
-| STATE_RUNNING | 2 | Running state. |
-| STATE_STOPPED | 3 | Stopped state. |
-| STATE_RELEASED | 4 | Released state. |
-| STATE_PAUSED | 5 | Paused state. |
+**System capability**: SystemCapability.Multimedia.Audio.Core
+| Name | Default Value| Description |
+| -------------- | ------ | ---------------- |
+| STATE_INVALID | -1 | Invalid state. |
+| STATE_NEW | 0 | Creating instance state.|
+| STATE_PREPARED | 1 | Prepared. |
+| STATE_RUNNING | 2 | Running. |
+| STATE_STOPPED | 3 | Stopped. |
+| STATE_RELEASED | 4 | Released. |
+| STATE_PAUSED | 5 | Paused. |
## AudioRendererRate8+
Enumerates the audio renderer rates.
-**System capability:** SystemCapability.Multimedia.Audio.Renderer
+**System capability**: SystemCapability.Multimedia.Audio.Renderer
-| Name | Default Value | Description |
-| :----------------- | :------------ | :------------ |
-| RENDER_RATE_NORMAL | 0 | Normal rate. |
-| RENDER_RATE_DOUBLE | 1 | Double rate. |
-| RENDER_RATE_HALF | 2 | Half rate. |
+| Name | Default Value| Description |
+| ------------------ | ------ | ---------- |
+| RENDER_RATE_NORMAL | 0 | Normal rate.|
+| RENDER_RATE_DOUBLE | 1 | Double rate. |
+| RENDER_RATE_HALF | 2 | Half rate. |
## InterruptType
-Enumerates the interrupt types.
-
-**System capability:** SystemCapability.Multimedia.Audio.Renderer
+Enumerates the audio interruption types.
-| Name | Default Value | Description |
-| :------------------- | :------------ | :----------------------------------- |
-| INTERRUPT_TYPE_BEGIN | 1 | Audio playback interruption started. |
-| INTERRUPT_TYPE_END | 2 | Audio playback interruption ended. |
+**System capability**: SystemCapability.Multimedia.Audio.Renderer
+| Name | Default Value| Description |
+| -------------------- | ------ | ---------------------- |
+| INTERRUPT_TYPE_BEGIN | 1 | Audio interruption started.|
+| INTERRUPT_TYPE_END | 2 | Audio interruption ended.|
## InterruptForceType9+
-Enumerates the interrupt force types.
+Enumerates the types of force that causes audio interruption.
-**System capability:** SystemCapability.Multimedia.Audio.Renderer
+**System capability**: SystemCapability.Multimedia.Audio.Renderer
-| Name | Default Value | Description |
-| :-------------- | :------------ | :----------------------------------------- |
-| INTERRUPT_FORCE | 0 | Forced action taken by system. |
-| INTERRUPT_SHARE | 1 | App can choose to take action or ignore. |
+| Name | Default Value| Description |
+| --------------- | ------ | ------------------------------------ |
+| INTERRUPT_FORCE | 0 | Forced action taken by the system. |
+| INTERRUPT_SHARE | 1 | The application can choose to take action or ignore.|
## InterruptHint
-Enumerates the interrupt hints.
+Enumerates the hints provided along with audio interruption.
-**System capability:** SystemCapability.Multimedia.Audio.Renderer
+**System capability**: SystemCapability.Multimedia.Audio.Renderer
-| Name | Default Value | Description |
-| :--------------------------------- | :------------ | :--------------------------- |
-| INTERRUPT_HINT_NONE8+ | 0 | None. |
-| INTERRUPT_HINT_RESUME | 1 | Resume the playback. |
-| INTERRUPT_HINT_PAUSE | 2 | Paused/Pause the playback. |
-| INTERRUPT_HINT_STOP | 3 | Stopped/Stop the playback. |
-| INTERRUPT_HINT_DUCK | 4 | Ducked the playback. |
-| INTERRUPT_HINT_UNDUCK8+ | 5 | Unducked the playback. |
+| Name | Default Value| Description |
+| ---------------------------------- | ------ | -------------------------------------------- |
+| INTERRUPT_HINT_NONE8+ | 0 | None. |
+| INTERRUPT_HINT_RESUME | 1 | Resume the playback. |
+| INTERRUPT_HINT_PAUSE | 2 | Paused/Pause the playback. |
+| INTERRUPT_HINT_STOP | 3 | Stopped/Stop the playback. |
+| INTERRUPT_HINT_DUCK | 4 | Ducked the playback. (In ducking, the audio volume is reduced, but not silenced.)|
+| INTERRUPT_HINT_UNDUCK8+ | 5 | Unducked the playback. |
## InterruptActionType
-Enumerates the interrupt event return types.
+Enumerates the returned event types for audio interruption events.
-This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.
+**System capability**: SystemCapability.Multimedia.Audio.Renderer
-**System capability:** SystemCapability.Multimedia.Audio.Renderer
-
-| Name | Default Value | Description |
-| :------------- | :------------ | :---------------------------------------- |
-| TYPE_ACTIVATED | 0 | Audio interrupt activated. |
-| TYPE_INTERRUPT | 1 | Audio interrupted. |
+| Name | Default Value| Description |
+| -------------- | ------ | ------------------ |
+| TYPE_ACTIVATED | 0 | Focus gain event.|
+| TYPE_INTERRUPT | 1 | Audio interruption event.|
## AudioStreamInfo8+
Describes audio stream information.
-**System capability:** SystemCapability.Multimedia.Audio.Core
+**System capability**: SystemCapability.Multimedia.Audio.Core
-| Name | Type | Mandatory | Description |
-| :------------ | :---------------------------------------- | :-------- | :-------------------- |
-| samplingRate | [AudioSamplingRate](#audiosamplingrate8) | Yes | Sampling rate. |
-| channels | [AudioChannel](#audiochannel8) | Yes | Audio channels. |
-| sampleFormat | [AudioSampleFormat](#audiosampleformat8) | Yes | Audio sample format. |
-| encodingType | [AudioEncodingType](#audioencodingtype8) | Yes | Audio encoding type. |
+| Name | Type | Mandatory| Description |
+| ------------ | ---------------------------------------- | ---- | ------------------ |
+| samplingRate | [AudioSamplingRate](#audiosamplingrate8) | Yes | Audio sampling rate.|
+| channels | [AudioChannel](#audiochannel8) | Yes | Number of audio channels.|
+| sampleFormat | [AudioSampleFormat](#audiosampleformat8) | Yes | Audio sample format. |
+| encodingType | [AudioEncodingType](#audioencodingtype8) | Yes | Audio encoding type. |
## AudioRendererInfo8+
Describes audio renderer information.
-**System capability:** SystemCapability.Multimedia.Audio.Core
+**System capability**: SystemCapability.Multimedia.Audio.Core
-| Name | Type | Mandatory | Description |
-| :------------ | :-------------------------- | :-------- | :-------------------- |
-| contentType | [ContentType](#contenttype) | Yes | Content type. |
-| usage | [StreamUsage](#streamusage) | Yes | Stream usage. |
-| rendererFlags | number | Yes | Audio renderer flags. |
+| Name | Type | Mandatory| Description |
+| ------------- | --------------------------- | ---- | ---------------- |
+| content | [ContentType](#contenttype) | Yes | Audio content type. |
+| usage | [StreamUsage](#streamusage) | Yes | Audio stream usage.|
+| rendererFlags | number | Yes | Audio renderer flags.|
## AudioRendererOptions8+
-Describes audio renderer configuration options.
+Describes audio renderer configurations.
-**System capability:** SystemCapability.Multimedia.Audio.Renderer
+**System capability**: SystemCapability.Multimedia.Audio.Renderer
-| Name | Type | Mandatory | Description |
-| :------------ | :-----------------------------------------| :-------- | :-------------------- |
-| streamInfo | [AudioStreamInfo](#audiostreaminfo8) | Yes | Stream information. |
-| rendererInfo | [AudioRendererInfo](#audiorendererinfo8) | Yes | Renderer information. |
+| Name | Type | Mandatory| Description |
+| ------------ | ---------------------------------------- | ---- | ---------------- |
+| streamInfo | [AudioStreamInfo](#audiostreaminfo8) | Yes | Audio stream information.|
+| rendererInfo | [AudioRendererInfo](#audiorendererinfo8) | Yes | Audio renderer information.|
-## AudioCapturerInfo8+
-
-Describes audio capturer information.
+## InterruptEvent9+
-**System capability:** SystemCapability.Multimedia.Audio.Core
+Describes the interruption event received by the application when playback is interrupted.
-| Name | Type | Mandatory | Description |
-| :---------------| :------------------------- | :-------- | :-------------------- |
-| source | [SourceType](#sourcetype) | Yes | Audio source type. |
-| capturerFlags | number | Yes | Audio capturer flags. |
+**System capability**: SystemCapability.Multimedia.Audio.Renderer
-## AudioCapturerOptions8+
+| Name | Type | Mandatory| Description |
+| --------- | ------------------------------------------ | ---- | ------------------------------------ |
+| eventType | [InterruptType](#interrupttype) | Yes | Whether the interruption has started or ended. |
+| forceType | [InterruptForceType](#interruptforcetype9) | Yes | Whether the interruption is taken by the system or to be taken by the application.|
+| hintType | [InterruptHint](#interrupthint) | Yes | Hint provided along the interruption. |
-Describes audio capturer configuration options.
+## AudioInterrupt
-**System capability:** SystemCapability.Multimedia.Audio.Capturer
+Describes input parameters of audio interruption events.
-| Name | Type | Mandatory | Description |
-| :------------ | :-----------------------------------------| :-------- | :-------------------- |
-| streamInfo | [AudioStreamInfo](#audiostreaminfo8) | Yes | Stream information. |
-| capturerInfo | [AudioCapturerInfo](#audiocapturerinfo8) | Yes | Capturer information. |
+**System capability**: SystemCapability.Multimedia.Audio.Renderer
-## InterruptEvent9+
+| Name | Type | Mandatory| Description |
+| --------------- | --------------------------- | ---- | ------------------------------------------------------------ |
+| streamUsage | [StreamUsage](#streamusage) | Yes | Audio stream usage. |
+| contentType | [ContentType](#contenttype) | Yes | Audio content type. |
+| pauseWhenDucked | boolean | Yes | Whether audio playback can be paused during audio interruption. The value **true** means that audio playback can be paused during audio interruption, and **false** means the opposite.|
-Describes the interrupt event received by the app when playback is interrupted.
+## InterruptAction
-**System capability:** SystemCapability.Multimedia.Audio.Renderer
+Describes the callback invoked for audio interruption or focus gain events.
-| Name | Type | Mandatory | Description |
-| :-------- | :-------------------------------------------- | :-------- | :---------------------------------------------------------------- |
-| eventType | [InterruptType](#interrupttype) | Yes | Whether the interruption has started or finished. |
-| forceType | [InterruptForceType](#interruptforcetype9) | Yes | Whether the action is taken by system or to be taken by the app. |
-| hintType | [InterruptHint](#interrupthint) | Yes | Type of action. |
+**System capability**: SystemCapability.Multimedia.Audio.Renderer
-## AudioInterrupt
+| Name | Type | Mandatory| Description |
+| ---------- | ------------------------------------------- | ---- | ------------------------------------------------------------ |
+| actionType | [InterruptActionType](#interruptactiontype) | Yes | Returned event type. The value **TYPE_ACTIVATED** means the focus gain event, and **TYPE_INTERRUPT** means the audio interruption event.|
+| type | [InterruptType](#interrupttype) | No | Type of the audio interruption event. |
+| hint | [InterruptHint](#interrupthint) | No | Hint provided along with the audio interruption event. |
+| activated | boolean | No | Whether the focus is gained or released. The value **true** means that the focus is gained or released, and **false** means that the focus fails to be gained or released.|
-The parameters passed in by the audio listener event.
+## VolumeEvent8+
-This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.
+Describes the event received by the application when the volume is changed.
-**System capability:** SystemCapability.Multimedia.Audio.Renderer
+This is a system API and cannot be called by third-party applications.
-| Name | Type | Mandatory | Description |
-| --------------- | --------------------------- | ---- | ------------------------------------------------------------ |
-| streamUsage | [StreamUsage](#streamusage) | Yes | Audio stream usage type. |
-| contentType | [ContentType](#contenttype) | Yes | Audio interrupt media type. |
-| pauseWhenDucked | boolean | Yes | Whether audio playback can be paused when audio is interrupted (true means audio playback can be paused during audio interruptions and false means the opposite). |
+**System capability**: SystemCapability.Multimedia.Audio.Volume
-## InterruptAction
+| Name | Type | Mandatory| Description |
+| ---------- | ----------------------------------- | ---- | -------------------------------------------------------- |
+| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type. |
+| volume | number | Yes | Volume level. The value range can be obtained by calling **getMinVolume** and **getMaxVolume**.|
+| updateUi | boolean | Yes | Whether to show the volume change in UI. |
-Callback method for the audio interrupt or audio interrupt activated event.
+## DeviceChangeAction
-This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.
+Describes the device connection status and device information.
-**System capability:** SystemCapability.Multimedia.Audio.Renderer
+**System capability**: SystemCapability.Multimedia.Audio.Device
-| Name | Type | Mandatory | Description |
-| ---------- | ------------------------------------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
-| actionType | [InterruptActionType](#interruptactiontype) | Yes | Event return type. TYPE_ACTIVATED is the audio interrupt activated event, and TYPE_INTERRUPT is the audio interrupt event. |
-| type | [InterruptType](#interrupttype) | No | Interrupt event type. |
-| hint | [InterruptHint](#interrupthint) | No | Interrupt event prompts. |
-| activated | boolean | No | Acquire/release focus. true indicates that the focus acquisition/release is successful, and false indicates that the focus acquisition/release fails. |
+| Name | Type | Mandatory| Description |
+| :---------------- | :------------------------------------------------ | :--- | :----------------- |
+| type | [DeviceChangeType](#devicechangetype) | Yes | Device connection status.|
+| deviceDescriptors | [AudioDeviceDescriptors](#audiodevicedescriptors) | Yes | Device information. |
-## VolumeEvent8+
-Describes the volume event received by the app when the volume is changed.
+## DeviceChangeType
-This is a system API and cannot be called by third-party applications.
+Enumerates the device connection statuses.
-**System capability:** SystemCapability.Multimedia.Audio.Volume
+**System capability**: SystemCapability.Multimedia.Audio.Device
-| Name | Type | Mandatory | Description |
-| :--------- | :---------------------------------- | :-------- | :--------------------------------------- |
-| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Volume type of the current stream. |
-| volume | number | Yes | Volume level. |
-| updateUi | boolean | Yes | Whether to show the volume change in UI. |
+| Name | Default Value| Description |
+| :--------- | :----- | :------------- |
+| CONNECT | 0 | Connected. |
+| DISCONNECT | 1 | Disconnected.|
-## DeviceChangeAction
-
-Describes the device change type and device information.
+## AudioCapturerOptions8+
-**System capability:** SystemCapability.Multimedia.Audio.Device
+Describes audio capturer configurations.
-| Name | Type | Mandatory | Description |
-| :------------------ | :------------------------------------------------ | :-------- | :------------------ |
-| type | [DeviceChangeType](#devicechangetype) | Yes | Device change type. |
-| deviceDescriptors | [AudioDeviceDescriptors](#audiodevicedescriptors) | Yes | Device information. |
+**System capability**: SystemCapability.Multimedia.Audio.Capturer
+| Name | Type | Mandatory| Description |
+| ------------ | --------------------------------------- | ---- | ---------------- |
+| streamInfo | [AudioStreamInfo](#audiostreaminfo8) | Yes | Audio stream information.|
+| capturerInfo | [AudioCapturerInfo](#audiocapturerinfo) | Yes | Audio capturer information.|
-## DeviceChangeType
+## AudioCapturerInfo8+
-Enumerates device change types.
+Describes audio capturer information.
-**System capability:** SystemCapability.Multimedia.Audio.Device
+**System capability**: SystemCapability.Multimedia.Audio.Core
-| Name | Default Value | Description |
-| :--------------------- | :------------ | :-------------------- |
-| CONNECT | 0 | Device connection. |
-| DISCONNECT | 1 | Device disconnection. |
+| Name | Type | Mandatory| Description |
+| :------------ | :------------------------ | :--- | :--------------- |
+| source | [SourceType](#sourcetype) | Yes | Audio source type. |
+| capturerFlags | number | Yes | Audio capturer flags.|
## SourceType8+
-Enumerates source types.
-
-**System capability:** SystemCapability.Multimedia.Audio.Core
+Enumerates the audio source types.
-| Name | Default Value | Description |
-| :----------------------------------------------------------------------------------------------------------------------------------------------------------- | :------------ | :------------------------------- |
-| SOURCE_TYPE_INVALID | -1 | Invalid source type. |
-| SOURCE_TYPE_MIC | 0 | Mic source type. |
-| SOURCE_TYPE_VOICE_COMMUNICATION(This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR) | 7 | Voice communication source type. |
+**System capability**: SystemCapability.Multimedia.Audio.Core
+| Name | Default Value| Description |
+| :------------------------------ | :----- | :--------------------- |
+| SOURCE_TYPE_INVALID | -1 | Invalid audio source. |
+| SOURCE_TYPE_MIC | 0 | Mic source. |
+| SOURCE_TYPE_VOICE_COMMUNICATION | 7 | Voice communication source.|
## AudioScene8+
-Enumerates audio scenes.
+Enumerates the audio scenes.
-**System capability:** SystemCapability.Multimedia.Audio.Communication
+**System capability**: SystemCapability.Multimedia.Audio.Communication
-| Name | Default Value | Description |
-| :------------------------------------------------------------------------------------ | :------------ | :---------------------- |
-| AUDIO_SCENE_DEFAULT | 0 | Default audio scene. |
-| AUDIO_SCENE_RINGING(system API, not supported by third-party applications) | 1 | Ringing audio scene. |
-| AUDIO_SCENE_PHONE_CALL(system API, not supported by third-party applications) | 2 | Phone call audio scene. |
-| AUDIO_SCENE_VOICE_CHAT | 3 | Voice chat audio scene. |
+| Name | Default Value| Description |
+| :--------------------- | :----- | :-------------------------------------------- |
+| AUDIO_SCENE_DEFAULT | 0 | Default audio scene. |
+| AUDIO_SCENE_RINGING | 1 | Ringing audio scene.
This is a system API and cannot be called by third-party applications.|
+| AUDIO_SCENE_PHONE_CALL | 2 | Phone call audio scene.
This is a system API and cannot be called by third-party applications.|
+| AUDIO_SCENE_VOICE_CHAT | 3 | Voice chat audio scene. |
## AudioManager
-Implements audio volume and audio device management. Before calling the interface of AudioManager, you need to create an instance through [getAudioManager](#audiogetaudiomanager).
+Implements audio volume and audio device management. Before calling any API in **AudioManager**, you must use [getAudioManager](#audiogetaudiomanager) to create an **AudioManager** instance.
### setVolume
-setVolume\(volumeType: AudioVolumeType, volume: number, callback: AsyncCallback\): void
+setVolume(volumeType: AudioVolumeType, volume: number, callback: AsyncCallback<void>): void
Sets the volume for a stream. This API uses an asynchronous callback to return the result.
-**System capability:** SystemCapability.Multimedia.Audio.Volume
+**System capability**: SystemCapability.Multimedia.Audio.Volume
-**Parameters:**
+**Parameters**
-| Name | Type | Mandatory | Description |
-| ---------- | ----------------------------------- | --------- | ---------------------------------------------------------------------------------------- |
-| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Volume stream type. |
-| volume | number | Yes | Volume to set. The value range can be obtained by calling getMinVolume and getMaxVolume. |
-| callback | AsyncCallback | Yes | Callback used to return the result. |
+| Name | Type | Mandatory| Description |
+| ---------- | ----------------------------------- | ---- | -------------------------------------------------------- |
+| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type. |
+| volume | number | Yes | Volume to set. The value range can be obtained by calling **getMinVolume** and **getMaxVolume**.|
+| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
-**Example:**
+**Example**
```
audioManager.setVolume(audio.AudioVolumeType.MEDIA, 10, (err) => {
@@ -666,28 +670,29 @@ audioManager.setVolume(audio.AudioVolumeType.MEDIA, 10, (err) => {
console.log('Callback invoked to indicate a successful volume setting.');
});
```
+
### setVolume
-setVolume\(volumeType: AudioVolumeType, volume: number\): Promise
+setVolume(volumeType: AudioVolumeType, volume: number): Promise<void>
Sets the volume for a stream. This API uses a promise to return the result.
-**System capability:** SystemCapability.Multimedia.Audio.Volume
+**System capability**: SystemCapability.Multimedia.Audio.Volume
-**Parameters:**
+**Parameters**
-| Name | Type | Mandatory | Description |
-| ---------- | ----------------------------------- | --------- | ---------------------------------------------------------------------------------------- |
-| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Volume stream type. |
-| volume | number | Yes | Volume to set. The value range can be obtained by calling getMinVolume and getMaxVolume. |
+| Name | Type | Mandatory| Description |
+| ---------- | ----------------------------------- | ---- | -------------------------------------------------------- |
+| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type. |
+| volume | number | Yes | Volume to set. The value range can be obtained by calling **getMinVolume** and **getMaxVolume**.|
-**Return value:**
+**Return value**
-| Type | Description |
-| ------------------- | ----------------------------------- |
-| Promise | Promise used to return the result. |
+| Type | Description |
+| ------------------- | ----------------------------- |
+| Promise<void> | Promise used to return the result.|
-**Example:**
+**Example**
```
audioManager.setVolume(audio.AudioVolumeType.MEDIA, 10).then(() => {
@@ -697,20 +702,20 @@ audioManager.setVolume(audio.AudioVolumeType.MEDIA, 10).then(() => {
### getVolume
-getVolume\(volumeType: AudioVolumeType, callback: AsyncCallback\): void
+getVolume(volumeType: AudioVolumeType, callback: AsyncCallback<number>): void
-Obtains the volume of a stream. This API uses an asynchronous callback to return the query result.
+Obtains the volume of a stream. This API uses an asynchronous callback to return the result.
-**System capability:** SystemCapability.Multimedia.Audio.Volume
+**System capability**: SystemCapability.Multimedia.Audio.Volume
-**Parameters:**
+**Parameters**
-| Name | Type | Mandatory | Description |
-| ---------- | ----------------------------------- | --------- | ------------------------------------ |
-| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type. |
-| callback | AsyncCallback | Yes | Callback used to return the volume. |
+| Name | Type | Mandatory| Description |
+| ---------- | ----------------------------------- | ---- | ------------------ |
+| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type. |
+| callback | AsyncCallback<number> | Yes | Callback used to return the volume.|
-**Example:**
+**Example**
```
audioManager.getVolume(audio.AudioVolumeType.MEDIA, (err, value) => {
@@ -722,28 +727,27 @@ audioManager.getVolume(audio.AudioVolumeType.MEDIA, (err, value) => {
});
```
-
### getVolume
-getVolume\(volumeType: AudioVolumeType\): Promise
+getVolume(volumeType: AudioVolumeType): Promise<number>
-Obtains the volume of a stream. This API uses a promise to return the query result.
+Obtains the volume of a stream. This API uses a promise to return the result.
-**System capability:** SystemCapability.Multimedia.Audio.Volume
+**System capability**: SystemCapability.Multimedia.Audio.Volume
-**Parameters:**
+**Parameters**
-| Name | Type | Mandatory | Description |
-| ---------- | ----------------------------------- | --------- | ------------------------------------ |
-| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type. |
+| Name | Type | Mandatory| Description |
+| ---------- | ----------------------------------- | ---- | ------------ |
+| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type.|
-**Return value:**
+**Return value**
-| Type | Description |
-| ------------------- | ----------------------------------- |
-| Promise | Promise used to return the result. |
+| Type | Description |
+| --------------------- | ------------------------- |
+| Promise<number> | Promise used to return the volume.|
-**Example:**
+**Example**
```
audioManager.getVolume(audio.AudioVolumeType.MEDIA).then((value) => {
@@ -753,20 +757,20 @@ audioManager.getVolume(audio.AudioVolumeType.MEDIA).then((value) => {
### getMinVolume
-getMinVolume\(volumeType: AudioVolumeType, callback: AsyncCallback\): void
+getMinVolume(volumeType: AudioVolumeType, callback: AsyncCallback<number>): void
-Obtains the minimum volume allowed for a stream. This API uses an asynchronous callback to return the query result.
+Obtains the minimum volume allowed for a stream. This API uses an asynchronous callback to return the result.
-**System capability:** SystemCapability.Multimedia.Audio.Volume
+**System capability**: SystemCapability.Multimedia.Audio.Volume
-**Parameters:**
+**Parameters**
-| Name | Type | Mandatory | Description |
-| ---------- | ----------------------------------- | --------- | ------------------------------------ |
-| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type. |
-| callback | AsyncCallback | Yes | Callback used to return the volume. |
+| Name | Type | Mandatory| Description |
+| ---------- | ----------------------------------- | ---- | ------------------ |
+| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type. |
+| callback | AsyncCallback<number> | Yes | Callback used to return the minimum volume.|
-**Example:**
+**Example**
```
audioManager.getMinVolume(audio.AudioVolumeType.MEDIA, (err, value) => {
@@ -778,28 +782,27 @@ audioManager.getMinVolume(audio.AudioVolumeType.MEDIA, (err, value) => {
});
```
-
### getMinVolume
-getMinVolume\(volumeType: AudioVolumeType\): Promise
+getMinVolume(volumeType: AudioVolumeType): Promise<number>
-Obtains the minimum volume allowed for a stream. This API uses a promise to return the query result.
+Obtains the minimum volume allowed for a stream. This API uses a promise to return the result.
-**System capability:** SystemCapability.Multimedia.Audio.Volume
+**System capability**: SystemCapability.Multimedia.Audio.Volume
-**Parameters:**
+**Parameters**
-| Name | Type | Mandatory | Description |
-| ---------- | ----------------------------------- | --------- | ------------------------------------ |
-| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type. |
+| Name | Type | Mandatory| Description |
+| ---------- | ----------------------------------- | ---- | ------------ |
+| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type.|
-**Return value:**
+**Return value**
-| Type | Description |
-| ------------------- | ----------------------------------- |
-| Promise | Promise used to return the result. |
+| Type | Description |
+| --------------------- | ------------------------- |
+| Promise<number> | Promise used to return the minimum volume.|
-**Example:**
+**Example**
```
audioManager.getMinVolume(audio.AudioVolumeType.MEDIA).then((value) => {
@@ -809,20 +812,20 @@ audioManager.getMinVolume(audio.AudioVolumeType.MEDIA).then((value) => {
### getMaxVolume
-getMaxVolume\(volumeType: AudioVolumeType, callback: AsyncCallback\): void
+getMaxVolume(volumeType: AudioVolumeType, callback: AsyncCallback<number>): void
-Obtains the maximum volume allowed for a stream. This API uses an asynchronous callback to return the query result.
+Obtains the maximum volume allowed for a stream. This API uses an asynchronous callback to return the result.
-**System capability:** SystemCapability.Multimedia.Audio.Volume
+**System capability**: SystemCapability.Multimedia.Audio.Volume
-**Parameters:**
+**Parameters**
-| Name | Type | Mandatory | Description |
-| ---------- | ----------------------------------- | --------- | ------------------------------------ |
-| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type. |
-| callback | AsyncCallback | Yes | Callback used to return the volume. |
+| Name | Type | Mandatory| Description |
+| ---------- | ----------------------------------- | ---- | ---------------------- |
+| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type. |
+| callback | AsyncCallback<number> | Yes | Callback used to return the maximum volume.|
-**Example:**
+**Example**
```
audioManager.getMaxVolume(audio.AudioVolumeType.MEDIA, (err, value) => {
@@ -834,28 +837,27 @@ audioManager.getMaxVolume(audio.AudioVolumeType.MEDIA, (err, value) => {
});
```
-
### getMaxVolume
-getMaxVolume\(volumeType: AudioVolumeType\): Promise
+getMaxVolume(volumeType: AudioVolumeType): Promise<number>
-Obtains the maximum volume allowed for a stream. This API uses a promise to return the query result.
+Obtains the maximum volume allowed for a stream. This API uses a promise to return the result.
-**System capability:** SystemCapability.Multimedia.Audio.Volume
+**System capability**: SystemCapability.Multimedia.Audio.Volume
-**Parameters:**
+**Parameters**
-| Name | Type | Mandatory | Description |
-| ---------- | ----------------------------------- | --------- | ------------------------------------ |
-| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type. |
+| Name | Type | Mandatory| Description |
+| ---------- | ----------------------------------- | ---- | ------------ |
+| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type.|
-**Return value:**
+**Return value**
-| Type | Description |
-| ------------------- | ----------------------------------- |
-| Promise | Promise used to return the result. |
+| Type | Description |
+| --------------------- | ----------------------------- |
+| Promise<number> | Promise used to return the maximum volume.|
-**Example:**
+**Example**
```
audioManager.getMaxVolume(audio.AudioVolumeType.MEDIA).then((data) => {
@@ -865,21 +867,21 @@ audioManager.getMaxVolume(audio.AudioVolumeType.MEDIA).then((data) => {
### mute
-mute\(volumeType: AudioVolumeType, mute: boolean, callback: AsyncCallback\): void
+mute(volumeType: AudioVolumeType, mute: boolean, callback: AsyncCallback<void>): void
-Mutes a stream. This API uses an asynchronous callback to return the result.
+Mutes or unmutes a stream. This API uses an asynchronous callback to return the result.
-**System capability:** SystemCapability.Multimedia.Audio.Volume
+**System capability**: SystemCapability.Multimedia.Audio.Volume
-**Parameters:**
+**Parameters**
-| Name | Type | Mandatory | Description |
-| ---------- | ----------------------------------- | --------- | ------------------------------------------------------------------------------------------ |
-| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type. |
-| mute | boolean | Yes | Mute status to set. The value true means to mute the stream, and false means the opposite. |
-| callback | AsyncCallback | Yes | Callback used to return the volume. |
+| Name | Type | Mandatory| Description |
+| ---------- | ----------------------------------- | ---- | ------------------------------------- |
+| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type. |
+| mute | boolean | Yes | Mute status to set. The value **true** means to mute the stream, and **false** means the opposite.|
+| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
-**Example:**
+**Example**
```
audioManager.mute(audio.AudioVolumeType.MEDIA, true, (err) => {
@@ -891,29 +893,29 @@ audioManager.mute(audio.AudioVolumeType.MEDIA, true, (err) => {
});
```
-
### mute
-mute\(volumeType: AudioVolumeType, mute: boolean\): Promise
+mute(volumeType: AudioVolumeType, mute: boolean): Promise<void>
-Mutes a stream. This API uses a promise to return the result.
+Mutes or unmutes a stream. This API uses a promise to return the result.
-**System capability:** SystemCapability.Multimedia.Audio.Volume
+**System capability**: SystemCapability.Multimedia.Audio.Volume
-**Parameters:**
+**Parameters**
-| Name | Type | Mandatory | Description |
-| ---------- | ----------------------------------- | --------- | ------------------------------------------------------------------------------------------ |
-| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type. |
-| mute | boolean | Yes | Mute status to set. The value true means to mute the stream, and false means the opposite. |
+| Name | Type | Mandatory| Description |
+| ---------- | ----------------------------------- | ---- | ------------------------------------- |
+| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type. |
+| mute | boolean | Yes | Mute status to set. The value **true** means to mute the stream, and **false** means the opposite.|
-**Return value:**
+**Return value**
-| Type | Description |
-| ------------------- | ----------------------------------- |
-| Promise | Promise used to return the result. |
+| Type | Description |
+| ------------------- | ----------------------------- |
+| Promise<void> | Promise used to return the result.|
+
+**Example**
-**Example:**
```
audioManager.mute(audio.AudioVolumeType.MEDIA, true).then(() => {
@@ -924,20 +926,20 @@ audioManager.mute(audio.AudioVolumeType.MEDIA, true).then(() => {
### isMute
-isMute\(volumeType: AudioVolumeType, callback: AsyncCallback\): void
+isMute(volumeType: AudioVolumeType, callback: AsyncCallback<boolean>): void
-Checks whether a stream is muted. This API uses an asynchronous callback to return the query result.
+Checks whether a stream is muted. This API uses an asynchronous callback to return the result.
-**System capability:** SystemCapability.Multimedia.Audio.Volume
+**System capability**: SystemCapability.Multimedia.Audio.Volume
-**Parameters:**
+**Parameters**
-| Name | Type | Mandatory | Description |
-| ---------- | ----------------------------------- | --------- | ----------------------------------------------------------------------------------------------------------------------------------- |
-| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type. |
-| callback | AsyncCallback | Yes | Callback used to return the mute status of the stream. The value true means that the stream is muted, and false means the opposite.|
+| Name | Type | Mandatory| Description |
+| ---------- | ----------------------------------- | ---- | ----------------------------------------------- |
+| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type. |
+| callback | AsyncCallback<boolean> | Yes | Callback used to return the mute status of the stream. The value **true** means that the stream is muted, and **false** means the opposite.|
-**Example:**
+**Example**
```
audioManager.isMute(audio.AudioVolumeType.MEDIA, (err, value) => {
@@ -952,25 +954,25 @@ audioManager.isMute(audio.AudioVolumeType.MEDIA, (err, value) => {
### isMute
-isMute\(volumeType: AudioVolumeType\): Promise
+isMute(volumeType: AudioVolumeType): Promise<boolean>
-Checks whether a stream is muted. This API uses a promise to return the result.
+Checks whether a stream is muted. This method uses a promise to return the result.
-**System capability:** SystemCapability.Multimedia.Audio.Volume
+**System capability**: SystemCapability.Multimedia.Audio.Volume
-**Parameters:**
+**Parameters**
-| Name | Type | Mandatory | Description |
-| ---------- | ----------------------------------- | --------- | ------------------- |
-| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type. |
+| Name | Type | Mandatory| Description |
+| ---------- | ----------------------------------- | ---- | ------------ |
+| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type.|
-**Return value:**
+**Return value**
-| Type | Description |
-| ------------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
-| Promise | Promise used to return the mute status of the stream. The value true means that the stream is muted, and false means the opposite. |
+| Type | Description |
+| ---------------------- | ------------------------------------------------------ |
+| Promise<boolean> | Promise used to return the mute status of the stream. The value **true** means that the stream is muted, and **false** means the opposite.|
-**Example:**
+**Example**
```
audioManager.isMute(audio.AudioVolumeType.MEDIA).then((value) => {
@@ -980,20 +982,20 @@ audioManager.isMute(audio.AudioVolumeType.MEDIA).then((value) => {
### isActive
-isActive\(volumeType: AudioVolumeType, callback: AsyncCallback\)
+isActive(volumeType: AudioVolumeType, callback: AsyncCallback<boolean>): void
-Checks whether a stream is active. This API uses an asynchronous callback to return the query result.
+Checks whether a stream is active. This API uses an asynchronous callback to return the result.
-**System capability:** SystemCapability.Multimedia.Audio.Volume
+**System capability**: SystemCapability.Multimedia.Audio.Volume
-**Parameters:**
+**Parameters**
-| Name | Type | Mandatory | Description |
-| ---------- | ----------------------------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------- |
-| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type. |
-| callback | AsyncCallback | Yes | Callback used to return the active status of the stream. The value true means that the stream is active, and false means the opposite.|
+| Name | Type | Mandatory| Description |
+| ---------- | ----------------------------------- | ---- | ------------------------------------------------- |
+| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type. |
+| callback | AsyncCallback<boolean> | Yes | Callback used to return the active status of the stream. The value **true** means that the stream is active, and **false** means the opposite.|
-**Example:**
+**Example**
```
audioManager.isActive(audio.AudioVolumeType.MEDIA, (err, value) => {
@@ -1005,28 +1007,27 @@ audioManager.isActive(audio.AudioVolumeType.MEDIA, (err, value) => {
});
```
-
### isActive
-isActive\(volumeType: AudioVolumeType\): Promise
+isActive(volumeType: AudioVolumeType): Promise<boolean>
-Checks whether a stream is active. This API uses a promise to return the query result.
+Checks whether a stream is active. This method uses a promise to return the result.
-**System capability:** SystemCapability.Multimedia.Audio.Volume
+**System capability**: SystemCapability.Multimedia.Audio.Volume
-**Parameters:**
+**Parameters**
-| Name | Type | Mandatory | Description |
-| ---------- | ----------------------------------- | --------- | ------------------ |
-| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type. |
+| Name | Type | Mandatory| Description |
+| ---------- | ----------------------------------- | ---- | ------------ |
+| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type.|
-**Return value:**
+**Return value**
-| Type | Description |
-| ------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
-| Promise | Promise used to return the active status of the stream. The value true means that the stream is active, and false means the opposite. |
+| Type | Description |
+| ---------------------- | -------------------------------------------------------- |
+| Promise<boolean> | Promise used to return the active status of the stream. The value **true** means that the stream is active, and **false** means the opposite.|
-**Example:**
+**Example**
```
audioManager.isActive(audio.AudioVolumeType.MEDIA).then((value) => {
@@ -1034,23 +1035,22 @@ audioManager.isActive(audio.AudioVolumeType.MEDIA).then((value) => {
});
```
-
### setRingerMode
-setRingerMode\(mode: AudioRingMode, callback: AsyncCallback\): void
+setRingerMode(mode: AudioRingMode, callback: AsyncCallback<void>): void
Sets the ringer mode. This API uses an asynchronous callback to return the result.
-**System capability:** SystemCapability.Multimedia.Audio.Communication
+**System capability**: SystemCapability.Multimedia.Audio.Communication
-**Parameters:**
+**Parameters**
-| Name | Type | Mandatory | Description |
-| ---------- | ----------------------------------- | --------- | ----------------------------------- |
-| mode | [AudioRingMode](#audioringmode) | Yes | Ringer mode. |
-| callback | AsyncCallback | Yes | Callback used to return the result. |
+| Name | Type | Mandatory| Description |
+| -------- | ------------------------------- | ---- | ------------------------ |
+| mode | [AudioRingMode](#audioringmode) | Yes | Ringer mode. |
+| callback | AsyncCallback<void> | Yes | Callback used to return the result.|
-**Example:**
+**Example**
```
audioManager.setRingerMode(audio.AudioRingMode.RINGER_MODE_NORMAL, (err) => {
@@ -1062,28 +1062,27 @@ audioManager.setRingerMode(audio.AudioRingMode.RINGER_MODE_NORMAL, (err) => {
});
```
-
### setRingerMode
-setRingerMode\(mode: AudioRingMode\): Promise
+setRingerMode(mode: AudioRingMode): Promise<void>
Sets the ringer mode. This API uses a promise to return the result.
-**System capability:** SystemCapability.Multimedia.Audio.Communication
+**System capability**: SystemCapability.Multimedia.Audio.Communication
-**Parameters:**
+**Parameters**
-| Name | Type | Mandatory | Description |
-| ---------- | ----------------------------------- | --------- | ----------------------------------- |
-| mode | [AudioRingMode](#audioringmode) | Yes | Ringer mode. |
+| Name| Type | Mandatory| Description |
+| ------ | ------------------------------- | ---- | -------------- |
+| mode | [AudioRingMode](#audioringmode) | Yes | Ringer mode.|
-**Return value:**
+**Return value**
-| Type | Description |
-| ------------------- | ----------------------------------- |
-| Promise | Promise used to return the result. |
+| Type | Description |
+| ------------------- | ------------------------------- |
+| Promise<void> | Promise used to return the result.|
-**Example:**
+**Example**
```
audioManager.setRingerMode(audio.AudioRingMode.RINGER_MODE_NORMAL).then(() => {
@@ -1094,19 +1093,19 @@ audioManager.setRingerMode(audio.AudioRingMode.RINGER_MODE_NORMAL).then(() => {
### getRingerMode
-getRingerMode\(callback: AsyncCallback\): void
+getRingerMode(callback: AsyncCallback<AudioRingMode>): void
-Obtains the ringer mode. This API uses an asynchronous callback to return the query result.
+Obtains the ringer mode. This API uses an asynchronous callback to return the result.
-**System capability:** SystemCapability.Multimedia.Audio.Communication
+**System capability**: SystemCapability.Multimedia.Audio.Communication
-**Parameters:**
+**Parameters**
-| Name | Type | Mandatory | Description |
-| ---------- | ----------------------------------------------- | --------- | ---------------------------------------- |
-| callback | AsyncCallback<[AudioRingMode](#audioringmode)> | Yes | Callback used to return the ringer mode. |
+| Name | Type | Mandatory| Description |
+| -------- | ---------------------------------------------------- | ---- | ------------------------ |
+| callback | AsyncCallback<[AudioRingMode](#audioringmode)> | Yes | Callback used to return the ringer mode.|
-**Example:**
+**Example**
```
audioManager.getRingerMode((err, value) => {
@@ -1121,19 +1120,19 @@ audioManager.getRingerMode((err, value) => {
### getRingerMode
-getRingerMode\(\): Promise
+getRingerMode(): Promise<AudioRingMode>
-Obtains the ringer mode. This API uses a promise to return the query result.
+Obtains the ringer mode. This API uses a promise to return the result.
-**System capability:** SystemCapability.Multimedia.Audio.Communication
+**System capability**: SystemCapability.Multimedia.Audio.Communication
-**Return value:**
+**Return value**
-| Type | Description |
-| ---------------------------------------------- | --------------------------------------- |
-| Promise<[AudioRingMode](#audioringmode)> | Promise used to return the ringer mode. |
+| Type | Description |
+| ---------------------------------------------- | ------------------------------- |
+| Promise<[AudioRingMode](#audioringmode)> | Promise used to return the ringer mode.|
-**Example:**
+**Example**
```
audioManager.getRingerMode().then((value) => {
@@ -1141,27 +1140,28 @@ audioManager.getRingerMode().then((value) => {
});
```
-
### setAudioParameter
-setAudioParameter\(key: string, value: string, callback: AsyncCallback\): void
+setAudioParameter(key: string, value: string, callback: AsyncCallback<void>): void
Sets an audio parameter. This API uses an asynchronous callback to return the result.
-**System capability:** SystemCapability.Multimedia.Audio.Core
+This API is used to extend the audio configuration based on the hardware capability. The supported audio parameters vary according to the device and can be obtained from the device manual. The example below is for reference only.
-**Parameters:**
+**System capability**: SystemCapability.Multimedia.Audio.Core
-| Name | Type | Mandatory | Description |
-| --------- | ----------------------| --------- | ------------------------------------- |
-| key | string | Yes | Key of the audio parameter to set. |
-| value | string | Yes | Value of the audio parameter to set. |
-| callback | AsyncCallback | Yes | Callback used to return the result. |
+**Parameters**
-**Example:**
+| Name | Type | Mandatory| Description |
+| -------- | ------------------------- | ---- | ------------------------ |
+| key | string | Yes | Key of the audio parameter to set. |
+| value | string | Yes | Value of the audio parameter to set. |
+| callback | AsyncCallback<void> | Yes | Callback used to return the result.|
+
+**Example**
```
-audioManager.setAudioParameter('PBits per sample', '8 bit', (err) => {
+audioManager.setAudioParameter('key_example', 'value_example', (err) => {
if (err) {
console.error('Failed to set the audio parameter. ${err.message}');
return;
@@ -1170,56 +1170,58 @@ audioManager.setAudioParameter('PBits per sample', '8 bit', (err) => {
});
```
-
### setAudioParameter
-setAudioParameter\(key: string, value: string\): Promise
+setAudioParameter(key: string, value: string): Promise<void>
Sets an audio parameter. This API uses a promise to return the result.
-**System capability:** SystemCapability.Multimedia.Audio.Core
+This API is used to extend the audio configuration based on the hardware capability. The supported audio parameters vary according to the device and can be obtained from the device manual. The example below is for reference only.
-**Parameters:**
+**System capability**: SystemCapability.Multimedia.Audio.Core
-| Name | Type | Mandatory | Description |
-| --------- | ----------------------| --------- | ------------------------------------- |
-| key | string | Yes | Key of the audio parameter to set. |
-| value | string | Yes | Value of the audio parameter to set. |
+**Parameters**
-**Return value:**
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | ---------------------- |
+| key | string | Yes | Key of the audio parameter to set.|
+| value | string | Yes | Value of the audio parameter to set.|
-| Type | Description |
-| ------------------- | ----------------------------------- |
-| Promise | Promise used to return the result. |
+**Return value**
-**Example:**
+| Type | Description |
+| ------------------- | ------------------------------- |
+| Promise<void> | Promise used to return the result.|
+
+**Example**
```
-audioManager.setAudioParameter('PBits per sample', '8 bit').then(() => {
+audioManager.setAudioParameter('key_example', 'value_example').then(() => {
console.log('Promise returned to indicate a successful setting of the audio parameter.');
});
```
-
### getAudioParameter
-getAudioParameter\(key: string, callback: AsyncCallback\)
+getAudioParameter(key: string, callback: AsyncCallback<string>): void
-Obtains the value of an audio parameter. This API uses an asynchronous callback to return the query result.
+Obtains the value of an audio parameter. This API uses an asynchronous callback to return the result.
-**System capability:** SystemCapability.Multimedia.Audio.Core
+This API is used to extend the audio configuration based on the hardware capability. The supported audio parameters vary according to the device and can be obtained from the device manual. The example below is for reference only.
-**Parameters:**
+**System capability**: SystemCapability.Multimedia.Audio.Core
-| Name | Type | Mandatory | Description |
-| --------- | ----------------------| --------- | ---------------------------------------------------------- |
-| key | string | Yes | Key of the audio parameter whose value is to be obtained. |
-| callback | AsyncCallback | Yes | Callback used to return the value of the audio parameter. |
+**Parameters**
-**Example:**
+| Name | Type | Mandatory| Description |
+| -------- | --------------------------- | ---- | ---------------------------- |
+| key | string | Yes | Key of the audio parameter whose value is to be obtained. |
+| callback | AsyncCallback<string> | Yes | Callback used to return the value of the audio parameter.|
+
+**Example**
```
-audioManager.getAudioParameter('PBits per sample', (err, value) => {
+audioManager.getAudioParameter('key_example', (err, value) => {
if (err) {
console.error('Failed to obtain the value of the audio parameter. ${err.message}');
return;
@@ -1228,53 +1230,52 @@ audioManager.getAudioParameter('PBits per sample', (err, value) => {
});
```
-
### getAudioParameter
-getAudioParameter\(key: string\): Promise
+getAudioParameter(key: string): Promise<string>
-Obtains the value of an audio parameter. This API uses a promise to return the query result.
+Obtains the value of an audio parameter. This API uses a promise to return the result.
-**System capability:** SystemCapability.Multimedia.Audio.Core
+This API is used to extend the audio configuration based on the hardware capability. The supported audio parameters vary according to the device and can be obtained from the device manual. The example below is for reference only.
-**Parameters:**
+**System capability**: SystemCapability.Multimedia.Audio.Core
-| Name | Type | Mandatory | Description |
-| --------- | ----------------------| --------- | ----------------------------------------------------------- |
-| key | string | Yes | Key of the audio parameter whose value is to be obtained. |
+**Parameters**
-**Return value:**
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | ---------------------- |
+| key | string | Yes | Key of the audio parameter whose value is to be obtained.|
-| Type | Description |
-| ------------------- | ----------------------------------- |
-| Promise | Promise used to return the value of the audio parameter. |
+**Return value**
-**Example:**
+| Type | Description |
+| --------------------- | ----------------------------------- |
+| Promise<string> | Promise used to return the value of the audio parameter.|
+
+**Example**
```
-audioManager.getAudioParameter('PBits per sample').then((value) => {
+audioManager.getAudioParameter('key_example').then((value) => {
console.log('Promise returned to indicate that the value of the audio parameter is obtained.' + value);
});
```
-
### getDevices
-getDevices\(deviceFlag: DeviceFlag, callback: AsyncCallback\): void
+getDevices(deviceFlag: DeviceFlag, callback: AsyncCallback<AudioDeviceDescriptors>): void
-Obtains the audio devices with a specific flag. This API uses an asynchronous callback to return the query result.
+Obtains the audio devices with a specific flag. This API uses an asynchronous callback to return the result.
-**System capability:** SystemCapability.Multimedia.Audio.Device
+**System capability**: SystemCapability.Multimedia.Audio.Device
-**Parameters:**
+**Parameters**
-| Name | Type | Mandatory | Description |
-| --------- | ---------------------------------------------------------------- | --------- | ----------------------------------------- |
-| deviceFlag | [DeviceFlag](#deviceflag) | Yes | Audio device flag. |
-| callback | AsyncCallback<[AudioDeviceDescriptors](#audiodevicedescriptors)> | Yes | Callback used to return the device list. |
-
-**Example:**
+| Name | Type | Mandatory| Description |
+| ---------- | ------------------------------------------------------------ | ---- | -------------------- |
+| deviceFlag | [DeviceFlag](#deviceflag) | Yes | Audio device flag. |
+| callback | AsyncCallback<[AudioDeviceDescriptors](#audiodevicedescriptors)> | Yes | Callback used to return the device list.|
+**Example**
```
audioManager.getDevices(audio.DeviceFlag.OUTPUT_DEVICES_FLAG, (err, value) => {
if (err) {
@@ -1285,29 +1286,27 @@ audioManager.getDevices(audio.DeviceFlag.OUTPUT_DEVICES_FLAG, (err, value) => {
});
```
-
-
### getDevices
-getDevices\(deviceFlag: DeviceFlag\): Promise
+getDevices(deviceFlag: DeviceFlag): Promise<AudioDeviceDescriptors>
-Obtains the audio devices with a specific flag. This API uses a promise to return the query result.
+Obtains the audio devices with a specific flag. This API uses a promise to return the result.
-**System capability:** SystemCapability.Multimedia.Audio.Device
+**System capability**: SystemCapability.Multimedia.Audio.Device
-**Parameters:**
+**Parameters**
-| Name | Type | Mandatory | Description |
-| --------- | --------------------------- | --------- | ------------------- |
-| deviceFlag | [DeviceFlag](#deviceflag) | Yes | Audio device flag. |
+| Name | Type | Mandatory| Description |
+| ---------- | ------------------------- | ---- | ---------------- |
+| deviceFlag | [DeviceFlag](#deviceflag) | Yes | Audio device flag.|
-**Return value:**
+**Return value**
-| Type | Description |
-| ----------------------------------------------------------- | ---------------------------------------- |
-| Promise<[AudioDeviceDescriptors](#audiodevicedescriptors)> | Promise used to return the device list. |
+| Type | Description |
+| ------------------------------------------------------------ | ------------------------- |
+| Promise<[AudioDeviceDescriptors](#audiodevicedescriptors)> | Promise used to return the device list.|
-**Example:**
+**Example**
```
audioManager.getDevices(audio.DeviceFlag.OUTPUT_DEVICES_FLAG).then((data) => {
@@ -1317,21 +1316,21 @@ audioManager.getDevices(audio.DeviceFlag.OUTPUT_DEVICES_FLAG).then((data) => {
### setDeviceActive
-setDeviceActive\(deviceType: DeviceType, active: boolean, callback: AsyncCallback\): void
+setDeviceActive(deviceType: ActiveDeviceType, active: boolean, callback: AsyncCallback<void>): void
Sets a device to the active state. This API uses an asynchronous callback to return the result.
-**System capability:** SystemCapability.Multimedia.Audio.Device
+**System capability**: SystemCapability.Multimedia.Audio.Device
-**Parameters:**
+**Parameters**
-| Name | Type | Mandatory | Description |
-| --------- | ---------------------------------------| --------- | ---------------------------------------------------------------------------------------------------------------- |
-| deviceType | [ActiveDeviceType](#activedevicetype) | Yes | Audio device type. |
-| active | boolean | Yes | Active status to set. The value true means to set the device to the active status, and false means the opposite. |
-| callback | AsyncCallback | Yes | Callback used to return the result. |
+| Name | Type | Mandatory| Description |
+| ---------- | ------------------------------------- | ---- | ------------------------ |
+| deviceType | [ActiveDeviceType](#activedevicetype) | Yes | Audio device type. |
+| active | boolean | Yes | Active state to set. The value **true** means to set the device to the active state, and **false** means the opposite. |
+| callback | AsyncCallback<void> | Yes | Callback used to return the result.|
-**Example:**
+**Example**
```
audioManager.setDeviceActive(audio.ActiveDeviceType.SPEAKER, true, (err) => {
@@ -1343,31 +1342,29 @@ audioManager.setDeviceActive(audio.ActiveDeviceType.SPEAKER, true, (err) => {
});
```
-
-
### setDeviceActive
-setDeviceActive\(deviceType: DeviceType, active: boolean\): Promise
+setDeviceActive(deviceType: ActiveDeviceType, active: boolean): Promise<void>
Sets a device to the active state. This API uses a promise to return the result.
-**System capability:** SystemCapability.Multimedia.Audio.Device
+**System capability**: SystemCapability.Multimedia.Audio.Device
-**Parameters:**
+**Parameters**
-| Name | Type | Mandatory | Description |
-| --------- | ---------------------------------------| --------- | ---------------------------------------------------------------------------------------------------------------- |
-| deviceType | [ActiveDeviceType](#activedevicetype) | Yes | Audio device type. |
-| active | boolean | Yes | Active status to set. The value true means to set the device to the active status, and false means the opposite. |
+| Name | Type | Mandatory| Description |
+| ---------- | ------------------------------------- | ---- | ------------------ |
+| deviceType | [ActiveDeviceType](#activedevicetype) | Yes | Audio device type.|
+| active | boolean | Yes | Active state to set. The value **true** means to set the device to the active state, and **false** means the opposite. |
-**Return value:**
+**Return value**
-| Type | Description |
-| ------------------- | ----------------------------------- |
-| Promise | Promise used to return the result. |
+| Type | Description |
+| ------------------- | ------------------------------- |
+| Promise<void> | Promise used to return the result.|
+**Example**
-**Example:**
```
audioManager.setDeviceActive(audio.ActiveDeviceType.SPEAKER, true).then(() => {
@@ -1375,23 +1372,22 @@ audioManager.setDeviceActive(audio.ActiveDeviceType.SPEAKER, true).then(() => {
});
```
-
### isDeviceActive
-isDeviceActive\(deviceType: DeviceType, callback: AsyncCallback\): void
+isDeviceActive(deviceType: ActiveDeviceType, callback: AsyncCallback<boolean>): void
-Checks whether a device is active. This API uses an asynchronous callback to return the query result.
+Checks whether a device is active. This API uses an asynchronous callback to return the result.
-**System capability:** SystemCapability.Multimedia.Audio.Device
+**System capability**: SystemCapability.Multimedia.Audio.Device
-**Parameters:**
+**Parameters**
-| Name | Type | Mandatory | Description |
-| --------- | ---------------------------------------| --------- | -------------------------------------------------------- |
-| deviceType | [ActiveDeviceType](#activedevicetype) | Yes | Audio device type. |
-| callback | AsyncCallback | Yes | Callback used to return the active status of the device. |
+| Name | Type | Mandatory| Description |
+| ---------- | ------------------------------------- | ---- | ------------------------ |
+| deviceType | [ActiveDeviceType](#activedevicetype) | Yes | Audio device type. |
+| callback | AsyncCallback<boolean> | Yes | Callback used to return the active state of the device.|
-**Example:**
+**Example**
```
audioManager.isDeviceActive(audio.ActiveDeviceType.SPEAKER, (err, value) => {
@@ -1406,25 +1402,25 @@ audioManager.isDeviceActive(audio.ActiveDeviceType.SPEAKER, (err, value) => {
### isDeviceActive
-isDeviceActive\(deviceType: DeviceType\): Promise
+isDeviceActive(deviceType: ActiveDeviceType): Promise<boolean>
-Checks whether a device is active. This API uses a promise to return the query result.
+Checks whether a device is active. This API uses a promise to return the result.
-**System capability:** SystemCapability.Multimedia.Audio.Device
+**System capability**: SystemCapability.Multimedia.Audio.Device
-**Parameters:**
+**Parameters**
-| Name | Type | Mandatory | Description |
-| --------- | ---------------------------------------| --------- | ----------------------------------------- |
-| deviceType | [ActiveDeviceType](#activedevicetype) | Yes | Audio device type. |
+| Name | Type | Mandatory| Description |
+| ---------- | ------------------------------------- | ---- | ------------------ |
+| deviceType | [ActiveDeviceType](#activedevicetype) | Yes | Audio device type.|
-**Return value:**
+**Return value**
-| Type | Description |
-| ------------------- | ----------------------------------- |
-| Promise | Promise used to return the active status of the device. |
+| Type | Description |
+| ---------------------- | ------------------------------- |
+| Promise<boolean> | Promise used to return the active state of the device.|
-**Example:**
+**Example**
```
audioManager.isDeviceActive(audio.ActiveDeviceType.SPEAKER).then((value) => {
@@ -1432,23 +1428,22 @@ audioManager.isDeviceActive(audio.ActiveDeviceType.SPEAKER).then((value) => {
});
```
-
### setMicrophoneMute
-setMicrophoneMute\(mute: boolean, callback: AsyncCallback\): void
+setMicrophoneMute(mute: boolean, callback: AsyncCallback<void>): void
Mutes or unmutes the microphone. This API uses an asynchronous callback to return the result.
-**System capability:** SystemCapability.Multimedia.Audio.Device
+**System capability**: SystemCapability.Multimedia.Audio.Device
-**Parameters:**
+**Parameters**
-| Name | Type | Mandatory | Description |
-| --------- | -------------------- | --------- | ---------------------------------------------------------------------------------------------- |
-| mute | boolean | Yes | Mute status to set. The value true means to mute the microphone, and false means the opposite. |
-| callback | AsyncCallback | Yes | Callback used to return the result. |
+| Name | Type | Mandatory| Description |
+| -------- | ------------------------- | ---- | --------------------------------------------- |
+| mute | boolean | Yes | Mute status to set. The value **true** means to mute the microphone, and **false** means the opposite.|
+| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
-**Example:**
+**Example**
```
audioManager.setMicrophoneMute(true, (err) => {
@@ -1460,30 +1455,27 @@ audioManager.setMicrophoneMute(true, (err) => {
});
```
-
### setMicrophoneMute
-setMicrophoneMute\(mute: boolean\): Promise
+setMicrophoneMute(mute: boolean): Promise<void>
Mutes or unmutes the microphone. This API uses a promise to return the result.
-**System capability:** SystemCapability.Multimedia.Audio.Device
-
-**Parameters:**
+**System capability**: SystemCapability.Multimedia.Audio.Device
-| Name | Type | Mandatory | Description |
-| --------- | -------------------- | --------- | ---------------------------------------------------------------------------------------------- |
-| mute | boolean | Yes | Mute status to set. The value true means to mute the microphone, and false means the opposite. |
+**Parameters**
-**Return value:**
+| Name| Type | Mandatory| Description |
+| ------ | ------- | ---- | --------------------------------------------- |
+| mute | boolean | Yes | Mute status to set. The value **true** means to mute the microphone, and **false** means the opposite.|
-| Type | Description |
-| ------------------- | ----------------------------------- |
-| Promise | Promise used to return the result. |
+**Return value**
-
+| Type | Description |
+| ------------------- | ------------------------------- |
+| Promise<void> | Promise used to return the result.|
-**Example:**
+**Example**
```
audioManager.setMicrophoneMute(true).then(() => {
@@ -1491,25 +1483,23 @@ audioManager.setMicrophoneMute(true).then(() => {
});
```
-
### isMicrophoneMute
-isMicrophoneMute\(callback: AsyncCallback\): void
+isMicrophoneMute(callback: AsyncCallback<boolean>): void
-Checks whether the microphone is muted. This API uses an asynchronous callback to return the query result.
+Checks whether the microphone is muted. This API uses an asynchronous callback to return the result.
-**System capability:** SystemCapability.Multimedia.Audio.Device
+**System capability**: SystemCapability.Multimedia.Audio.Device
-**Parameters:**
+**Parameters**
-| Name | Type | Mandatory | Description |
-| --------- | -------------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
-| callback | AsyncCallback | Yes | Callback used to return the mute status of the microphone. The value true means that the microphone is muted, and false means the opposite. |
+| Name | Type | Mandatory| Description |
+| -------- | ---------------------------- | ---- | ------------------------------------------------------- |
+| callback | AsyncCallback<boolean> | Yes | Callback used to return the mute status of the microphone. The value **true** means that the microphone is muted, and **false** means the opposite.|
-**Example:**
+**Example**
```
-var audioManager = audio.getAudioManager();
audioManager.isMicrophoneMute((err, value) => {
if (err) {
console.error('Failed to obtain the mute status of the microphone. ${err.message}');
@@ -1519,25 +1509,24 @@ audioManager.isMicrophoneMute((err, value) => {
});
```
-
### isMicrophoneMute
-isMicrophoneMute\(\): Promise
+isMicrophoneMute(): Promise<boolean>
+
+Checks whether the microphone is muted. This API uses a promise to return the result.
-Checks whether the microphone is muted. This API uses a promise to return the query result.
+**System capability**: SystemCapability.Multimedia.Audio.Device
-**System capability:** SystemCapability.Multimedia.Audio.Device
+**Return value**
-**Return value:**
+| Type | Description |
+| ---------------------- | ------------------------------------------------------------ |
+| Promise<boolean> | Promise used to return the mute status of the microphone. The value **true** means that the microphone is muted, and **false** means the opposite.|
-| Type | Description |
-| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
-| Promise | Promise used to return the mute status of the microphone. The value true means that the microphone is muted, and false means the opposite. |
+**Example**
-**Example:**
```
-var audioManager = audio.getAudioManager();
audioManager.isMicrophoneMute().then((value) => {
console.log('Promise returned to indicate that the mute status of the microphone is obtained.', + value);
});
@@ -1547,20 +1536,20 @@ audioManager.isMicrophoneMute().then((value) => {
on(type: 'volumeChange', callback: Callback\): void
-Subscribes to system volume change events. This API uses a callback to get volume change events.
+Subscribes to system volume change events.
This is a system API and cannot be called by third-party applications.
-**System capability:** SystemCapability.Multimedia.Audio.Volume
+**System capability**: SystemCapability.Multimedia.Audio.Volume
-**Parameters:**
+**Parameters**
-| Name | Type | Mandatory | Description |
-| :------- | :--------------------------------------| :-------------| :------------------------------------------------------------------------------------------------------------------------------------------------------------ |
-| type | string | Yes | Type of the event to subscribe to. The value 'volumeChange' means the system volume change event, which is triggered when a system volume change is detected. |
-| callback | Callback<[VolumeEvent](#volumeevent8)> | Yes | Callback used to get the system volume change event. |
+| Name | Type | Mandatory| Description |
+| -------- | -------------------------------------- | ---- | ------------------------------------------------------------ |
+| type | string | Yes | Type of event to subscribe to. The value **volumeChange** means the system volume change event, which is triggered when a system volume change is detected.|
+| callback | Callback<[VolumeEvent](#volumeevent8)> | Yes | Callback used to return the system volume change event. |
-**Example:**
+**Example**
```
audioManager.on('volumeChange', (volumeEvent) => {
@@ -1570,25 +1559,24 @@ audioManager.on('volumeChange', (volumeEvent) => {
});
```
-
### on('ringerModeChange')8+
on(type: 'ringerModeChange', callback: Callback\): void
-Subscribes to ringer mode change events. This API uses a callback to get ringer mode changes.
+Subscribes to ringer mode change events.
This is a system API and cannot be called by third-party applications.
-**System capability:** SystemCapability.Multimedia.Audio.Communication
+**System capability**: SystemCapability.Multimedia.Audio.Communication
-**Parameters:**
+**Parameters**
-| Name | Type | Mandatory | Description |
-| :------- | :----------------------------------------- | :-------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| type | string | Yes | Type of the event to subscribe to. The value 'ringerModeChange' means the ringer mode change event, which is triggered when a ringer mode change is detected. |
-| callback | Callback<[AudioRingMode](#audioringmode)> | Yes | Callback used to get the updated ringer mode. |
+| Name | Type | Mandatory| Description |
+| -------- | ----------------------------------------- | ---- | ------------------------------------------------------------ |
+| type | string | Yes | Type of event to subscribe to. The value **ringerModeChange** means the ringer mode change event, which is triggered when a ringer mode change is detected.|
+| callback | Callback<[AudioRingMode](#audioringmode)> | Yes | Callback used to return the updated ringer mode. |
-**Example:**
+**Example**
```
audioManager.on('ringerModeChange', (ringerMode) => {
@@ -1600,18 +1588,18 @@ audioManager.on('ringerModeChange', (ringerMode) => {
on(type: 'deviceChange', callback: Callback): void
-Subscribes to device change events. When a device is connected/disconnected, registered clients will receive the callback.
+Subscribes to device change events. When a device is connected or disconnected, registered clients will receive the callback.
-**System capability:** SystemCapability.Multimedia.Audio.Device
+**System capability**: SystemCapability.Multimedia.Audio.Device
-**Parameters:**
+**Parameters**
-| Name | Type | Mandatory | Description |
-| :------- | :-------------------------------------------------- | :---------| :---------------------------------------------------------------------------------------------------------------------------------------------- |
-| type | string | Yes | Type of the event to subscribe to. The value 'deviceChange' means the device change event, which is triggered when a device change is detected. |
-| callback | Callback<[DeviceChangeAction](#devicechangeaction)> | Yes | Callback used to obtain the device update details. |
+| Name | Type | Mandatory| Description |
+| :------- | :--------------------------------------------------- | :--- | :----------------------------------------- |
+| type | string | Yes | Type of event to subscribe to. The value **deviceChange** means the device change event, which is triggered when a device connection status change is detected.|
+| callback | Callback<[DeviceChangeAction](#DeviceChangeAction)\> | Yes | Callback used to return the device update details. |
-**Example:**
+**Example**
```
audioManager.on('deviceChange', (deviceChanged) => {
@@ -1626,20 +1614,18 @@ audioManager.on('deviceChange', (deviceChanged) => {
off(type: 'deviceChange', callback?: Callback): void
-Unsubscribes from audio device connection change events.
+Unsubscribes from device change events.
-This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.
+**System capability**: SystemCapability.Multimedia.Audio.Device
-**System capability:** SystemCapability.Multimedia.Audio.Device
+**Parameters**
-**Parameters:**
+| Name | Type | Mandatory| Description |
+| -------- | --------------------------------------------------- | ---- | ------------------------------------------ |
+| type | string | Yes | Type of event to unsubscribe from. The value **deviceChange** means the device change event, which is triggered when a device connection status change is detected.|
+| callback | Callback<[DeviceChangeAction](#DeviceChangeAction)> | No | Callback used to return the device update details. |
-| Name | Type | Mandatory | Description |
-| :------- | :-------------------------------------------------- | :---------| :-------------------------------------------------- |
-| type | string | Yes | Type of the event to unsubscribe from. |
-| callback | Callback<[DeviceChangeAction](#devicechangeaction)> | No | Callback used to obtain the device update details. |
-
-**Example:**
+**Example**
```
audioManager.off('deviceChange', (deviceChanged) => {
@@ -1647,26 +1633,23 @@ audioManager.off('deviceChange', (deviceChanged) => {
});
```
-
### on('interrupt')
on(type: 'interrupt', interrupt: AudioInterrupt, callback: Callback\): void
-Subscribes to audio interrupt events. When the application's audio is interrupted by another playback event, the application will receive the callback.
-
-This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.
+Subscribes to audio interruption events. When the application's audio is interrupted by another playback event, the application will receive the callback.
-**System capability:** SystemCapability.Multimedia.Audio.Renderer
+**System capability**: SystemCapability.Multimedia.Audio.Renderer
-**Parameters:**
+**Parameters**
-| Name | Type | Mandatory | Description |
-| --------- | --------------------------------------------- | ---- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| type | string | Yes | Type of event to subscribe to. The value 'interrupt' means the audio interrupt event, which is triggered when the audio playback of the current application is interrupted by another application.|
-| interrupt | AudioInterrupt | Yes | Audio interrupt event type. |
-| callback | Callback<[InterruptAction](#interruptaction)> | Yes | Audio interrupt event callback method. |
+| Name | Type | Mandatory| Description |
+| --------- | --------------------------------------------- | ---- | ------------------------------------------------------------ |
+| type | string | Yes | Type of event to subscribe to. The value **interrupt** means the audio interruption event, which is triggered when the audio playback of the current application is interrupted by another application.|
+| interrupt | AudioInterrupt | Yes | Audio interruption event type. |
+| callback | Callback<[InterruptAction](#interruptaction)> | Yes | Callback invoked for the audio interruption event. |
-**Example:**
+**Example**
```
var interAudioInterrupt = {
@@ -1690,21 +1673,19 @@ audioManager.on('interrupt', interAudioInterrupt, (InterruptAction) => {
off(type: 'interrupt', interrupt: AudioInterrupt, callback?: Callback\): void
-Unsubscribes from audio interrupt events.
+Unsubscribes from audio interruption events.
-This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.
+**System capability**: SystemCapability.Multimedia.Audio.Renderer
-**System capability:** SystemCapability.Multimedia.Audio.Renderer
+**Parameters**
-**Parameters:**
+| Name | Type | Mandatory| Description |
+| --------- | --------------------------------------------- | ---- | ------------------------------------------------------------ |
+| type | string | Yes | Type of event to unsubscribe from. The value **interrupt** means the audio interruption event, which is triggered when the audio playback of the current application is interrupted by another application.|
+| interrupt | AudioInterrupt | Yes | Audio interruption event type. |
+| callback | Callback<[InterruptAction](#interruptaction)> | No | Callback invoked for the audio interruption event. |
-| Name | Type | Mandatory | Description |
-| --------- | --------------------------------------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
-| type | string | Yes | Type of event to unsubscribe from. The value 'interrupt' means the audio interrupt event, which is triggered when the audio playback of the current application is interrupted by another application. |
-| interrupt | AudioInterrupt | Yes | Audio interrupt event type. |
-| callback | Callback<[InterruptAction](#interruptaction)> | No | Audio interrupt event callback method. |
-
-**Example:**
+**Example**
```
var interAudioInterrupt = {
@@ -1720,25 +1701,24 @@ audioManager.off('interrupt', interAudioInterrupt, (InterruptAction) => {
});
```
-
### setAudioScene8+
setAudioScene\(scene: AudioScene, callback: AsyncCallback\): void
-Sets the audio scene mode to change audio strategies. This API uses an asynchronous callback to return the result.
+Sets an audio scene. This API uses an asynchronous callback to return the result.
This is a system API and cannot be called by third-party applications.
-**System capability:** SystemCapability.Multimedia.Audio.Communication
+**System capability**: SystemCapability.Multimedia.Audio.Communication
-**Parameters:**
+**Parameters**
-| Name | Type | Mandatory | Description |
-| :------- | :------------------------------------ | :-------- | :---------------------------------- |
-| scene | AudioScene | Yes | Audio scene mode. |
-| callback | AsyncCallback | Yes | Callback used to return the result. |
+| Name | Type | Mandatory| Description |
+| :------- | :----------------------------------- | :--- | :------------------- |
+| scene | AudioScene | Yes | Audio scene to set. |
+| callback | AsyncCallback | Yes | Callback used to return the result.|
-**Example:**
+**Example**
```
audioManager.setAudioScene(audio.AudioScene.AUDIO_SCENE_PHONE_CALL, (err) => {
@@ -1750,32 +1730,29 @@ audioManager.setAudioScene(audio.AudioScene.AUDIO_SCENE_PHONE_CALL, (err) => {
});
```
-
### setAudioScene8+
setAudioScene\(scene: AudioScene\): Promise
-Sets the audio scene mode to change audio strategies. This API uses a promise to return the result.
+Sets an audio scene. This API uses a promise to return the result.
This is a system API and cannot be called by third-party applications.
-**System capability:** SystemCapability.Multimedia.Audio.Communication
-
-**Parameters:**
+**System capability**: SystemCapability.Multimedia.Audio.Communication
-| Name | Type | Mandatory | Description |
-| :------- | :-------------------------------------- | :-------- | :---------------- |
-| scene | AudioScene | Yes | Audio scene mode. |
+**Parameters**
+| Name| Type | Mandatory| Description |
+| :----- | :----------------------------------- | :--- | :------------- |
+| scene | AudioScene | Yes | Audio scene to set.|
-**Return value:**
+**Return value**
-| Type | Description |
-| :------------- | :---------------------------------- |
-| Promise | Promise used to return the result. |
+| Type | Description |
+| :------------- | :------------------- |
+| Promise | Promise used to return the result.|
-
-**Example:**
+**Example**
```
audioManager.setAudioScene(audio.AudioScene.AUDIO_SCENE_PHONE_CALL).then(() => {
@@ -1785,22 +1762,21 @@ audioManager.setAudioScene(audio.AudioScene.AUDIO_SCENE_PHONE_CALL).then(() => {
});
```
-
### getAudioScene8+
getAudioScene\(callback: AsyncCallback\): void
-Obtains the audio scene mode. This API uses an asynchronous callback to return the query result.
+Obtains the audio scene. This API uses an asynchronous callback to return the result.
-**System capability:** SystemCapability.Multimedia.Audio.Communication
+**System capability**: SystemCapability.Multimedia.Audio.Communication
-**Parameters:**
+**Parameters**
-| Name | Type | Mandatory | Description |
-| :------- | :-------------------------------------------------- | :-------- | :-------------------------------------------- |
-| callback | AsyncCallback<AudioScene> | Yes | Callback used to return the audio scene mode. |
+| Name | Type | Mandatory| Description |
+| :------- | :-------------------------------------------------- | :--- | :--------------------------- |
+| callback | AsyncCallback<AudioScene> | Yes | Callback used to return the audio scene.|
-**Example:**
+**Example**
```
audioManager.getAudioScene((err, value) => {
@@ -1817,18 +1793,17 @@ audioManager.getAudioScene((err, value) => {
getAudioScene\(\): Promise
-Obtains the audio scene mode. This API uses a promise to return the query result.
+Obtains the audio scene. This API uses a promise to return the result.
-**System capability:** SystemCapability.Multimedia.Audio.Communication
+**System capability**: SystemCapability.Multimedia.Audio.Communication
-**Return value:**
+**Return value**
-| Type | Description |
-| :-------------------------------------------- | :------------------------------------------- |
-| Promise<AudioScene> | Promise used to return the audio scene mode. |
+| Type | Description |
+| :-------------------------------------------- | :--------------------------- |
+| Promise<AudioScene> | Promise used to return the audio scene.|
-
-**Example:**
+**Example**
```
audioManager.getAudioScene().then((value) => {
@@ -1842,20 +1817,18 @@ audioManager.getAudioScene().then((value) => {
Describes an audio device.
-**System capability:** SystemCapability.Multimedia.Audio.Device
+**System capability**: SystemCapability.Multimedia.Audio.Device
-| Name | Type | Readable | Writable | Description |
-| ---------- | ------------------------- | -------- | -------- | ------------------ |
-| deviceRole | [DeviceRole](#devicerole) | Yes | No | Audio device role. |
-| deviceType | [DeviceType](#devicetype) | Yes | No | Audio device type. |
+| Name | Type | Readable| Writable| Description |
+| ---------- | ------------------------- | ---- | ---- | ---------- |
+| deviceRole | [DeviceRole](#devicerole) | Yes | No | Device role.|
+| deviceType | [DeviceType](#devicetype) | Yes | No | Device type.|
## AudioDeviceDescriptors
Array of [AudioDeviceDescriptor](#audiodevicedescriptor), which is read-only.
-**System capability:** SystemCapability.Multimedia.Audio.Device
-
-**Example:**
+**Example**
```
import audio from '@ohos.multimedia.audio';
@@ -1880,45 +1853,40 @@ promise.then(function (value) {
}
});
```
-## AudioRenderer8+
-
-Provides related APIs for audio rendering. Before calling the AudioRenderer API, you need to create an instance through [createAudioRenderer](#audiocreateaudiorenderer8).
-
-**System capability:** SystemCapability.Multimedia.Audio.Renderer
-### state8+
+## AudioRenderer8+
-readonly state: AudioState
+Provides APIs for audio rendering. Before calling any API in **AudioRenderer**, you must use [createAudioRenderer](#audiocreateaudiorenderer8) to create an **AudioRenderer** instance.
-Defines the current render state.
+### Attributes
-**System capability:** SystemCapability.Multimedia.Audio.Renderer
+**System capability**: SystemCapability.Multimedia.Audio.Renderer
-| Name | Type | Readable | Writable | Description |
-| :---- | :-------------------------- | :------- | :------- | :------------------ |
-| state | [AudioState](#audiostate8) | Yes | No | Audio render state. |
+| Name | Type | Readable| Writable| Description |
+| ----- | -------------------------- | ---- | ---- | ------------------ |
+| state8+ | [AudioState](#audiostate8) | Yes | No | Audio renderer state.|
-**Example:**
+**Example**
```
- var state = audioRenderer.state;
+var state = audioRenderer.state;
```
### getRendererInfo8+
getRendererInfo(callback: AsyncCallback): void
-Obtains the renderer information provided while creating a renderer instance. This API uses an asynchronous callback to return the result.
+Obtains the renderer information of this **AudioRenderer** instance. This API uses an asynchronous callback to return the result.
-**System capability:** SystemCapability.Multimedia.Audio.Renderer
+**System capability**: SystemCapability.Multimedia.Audio.Renderer
-**Parameters:**
+**Parameters**
-| Name | Type | Mandatory | Description |
-| :------- | :------------------------------------------------------- | :-------- | :------------------------------------------------ |
-| callback | AsyncCallback<[AudioRendererInfo](#audiorendererinfo8)> | Yes | Callback used to return the renderer information. |
+| Name | Type | Mandatory| Description |
+| :------- | :------------------------------------------------------- | :--- | :--------------------- |
+| callback | AsyncCallback<[AudioRendererInfo](#audiorendererinfo8)\> | Yes | Callback used to return the renderer information.|
-**Example:**
+**Example**
```
audioRenderer.getRendererInfo((err, rendererInfo) => {
@@ -1929,22 +1897,21 @@ audioRenderer.getRendererInfo((err, rendererInfo) => {
});
```
-
### getRendererInfo8+
getRendererInfo(): Promise
-Obtains the renderer information provided while creating a renderer instance. This API uses a promise to return the result.
+Obtains the renderer information of this **AudioRenderer** instance. This API uses a promise to return the result.
-**System capability:** SystemCapability.Multimedia.Audio.Renderer
+**System capability**: SystemCapability.Multimedia.Audio.Renderer
-**Return value:**
+**Return value**
-| Type | Description |
-| :-------------------------------------------------- | :----------------------------------------------- |
-| Promise<[AudioRendererInfo](#audiorendererinfo8)> | Promise used to return the renderer information. |
+| Type | Description |
+| -------------------------------------------------- | ------------------------------- |
+| Promise<[AudioRendererInfo](#audiorendererinfo8)\> | Promise used to return the renderer information.|
-**Example:**
+**Example**
```
var resultFlag = true;
@@ -1957,24 +1924,23 @@ audioRenderer.getRendererInfo().then((rendererInfo) => {
console.log('AudioFrameworkRenderLog: RendererInfo :ERROR: '+err.message);
resultFlag = false;
});
-
```
### getStreamInfo8+
getStreamInfo(callback: AsyncCallback): void
-Obtains the renderer stream information. This API uses an asynchronous callback to return the result.
+Obtains the stream information of this **AudioRenderer** instance. This API uses an asynchronous callback to return the result.
-**System capability:** SystemCapability.Multimedia.Audio.Renderer
+**System capability**: SystemCapability.Multimedia.Audio.Renderer
-**Parameters:**
+**Parameters**
-| Name | Type | Mandatory | Description |
-| :------- | :------------------------------------------------------ | :-------- | :---------------------------------------------- |
-| callback | AsyncCallback<[AudioStreamInfo](#audiostreaminfo8)\> | Yes | Callback used to return the stream information. |
+| Name | Type | Mandatory| Description |
+| :------- | :--------------------------------------------------- | :--- | :------------------- |
+| callback | AsyncCallback<[AudioStreamInfo](#audiostreaminfo8)\> | Yes | Callback used to return the stream information.|
-**Example:**
+**Example**
```
audioRenderer.getStreamInfo((err, streamInfo) => {
@@ -1990,17 +1956,17 @@ audioRenderer.getStreamInfo((err, streamInfo) => {
getStreamInfo(): Promise
-Obtains the renderer stream information. This API uses a promise to return the result.
+Obtains the stream information of this **AudioRenderer** instance. This API uses a promise to return the result.
-**System capability:** SystemCapability.Multimedia.Audio.Renderer
+**System capability**: SystemCapability.Multimedia.Audio.Renderer
-**Return value:**
+**Return value**
-| Type | Description |
-| :------------------------------------------------- | :--------------------------------------------- |
-| Promise<[AudioStreamInfo](#audiostreaminfo8)\> | Promise used to return the stream information. |
+| Type | Description |
+| :--------------------------------------------- | :--------------------- |
+| Promise<[AudioStreamInfo](#audiostreaminfo8)\> | Promise used to return the stream information.|
-**Example:**
+**Example**
```
audioRenderer.getStreamInfo().then((streamInfo) => {
@@ -2012,7 +1978,6 @@ audioRenderer.getStreamInfo().then((streamInfo) => {
}).catch((err) => {
console.log('ERROR: '+err.message);
});
-
```
### start8+
@@ -2021,16 +1986,15 @@ start(callback: AsyncCallback): void
Starts the renderer. This API uses an asynchronous callback to return the result.
-**System capability:** SystemCapability.Multimedia.Audio.Renderer
+**System capability**: SystemCapability.Multimedia.Audio.Renderer
-**Parameters:**
+**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:**
+**Example**
```
audioRenderer.start((err) => {
@@ -2048,15 +2012,15 @@ start(): Promise
Starts the renderer. This API uses a promise to return the result.
-**System capability:** SystemCapability.Multimedia.Audio.Renderer
+**System capability**: SystemCapability.Multimedia.Audio.Renderer
-**Return value:**
+**Return value**
-| Type | Description |
-| :------------- | :--------------------------------- |
-| Promise | Promise used to return the result. |
+| Type | Description |
+| -------------- | ------------------------- |
+| Promise\ | Promise used to return the result.|
-**Example:**
+**Example**
```
audioRenderer.start().then(() => {
@@ -2066,23 +2030,21 @@ audioRenderer.start().then(() => {
});
```
-
### pause8+
pause(callback: AsyncCallback\): void
Pauses rendering. This API uses an asynchronous callback to return the result.
-**System capability:** SystemCapability.Multimedia.Audio.Renderer
+**System capability**: SystemCapability.Multimedia.Audio.Renderer
-**Parameters:**
+**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:**
+**Example**
```
audioRenderer.pause((err) => {
@@ -2100,15 +2062,15 @@ pause(): Promise\