The **avSession** module provides APIs for media playback control so that applications can access the system's Media Controller.
This module provides the following common features related to media sessions:
-[AVSession](#section652893): used to set session metadata, playback state information, and more.
-[AVSessionController](#section974602): used to obtain session IDs, send commands and events to sessions, and obtain the session metadata and playback state information.
-[AVSession](#avsession): used to set session metadata, playback state information, and more.
-[AVSessionController](#avsessioncontroller): used to obtain session IDs, send commands and events to sessions, and obtain the session metadata and playback state information.
> **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.
>
> All the APIs provided by this module are system APIs.
## Modules to Import
...
...
@@ -28,7 +30,7 @@ Creates a media session. This API uses a promise to return the result. An abilit
| type | [AVSessionType](#avsessiontype) | Yes | Session type, which can be audio or video. |
| callback | AsyncCallback<[AVSession](#avsession)\> | Yes | Callback used to return the media session obtained, which can be used to obtain the session ID, set the metadata and playback state information, and send key events.|
...
...
@@ -87,7 +89,7 @@ For details about the error codes, see [AVSession Management Error Codes](../err
@@ -770,7 +772,7 @@ avSession.sendSystemControlCommand(avcommand, function (err) {
});
```
## AVSession<a name="section652893"></a>
## AVSession
An **AVSession** object is created by calling [avSession.createAVSession](#avsessioncreateavsession). The object enables you to obtain the session ID and set the metadata and playback state.
...
...
@@ -815,8 +817,8 @@ For details about the error codes, see [AVSession Management Error Codes](../err
| ability | [WantAgent](js-apis-app-ability-wantAgent.md) | Yes | Application attributes, such as the bundle name, ability name, and deviceID. |
| callback | AsyncCallback<void\> | Yes | Callback used to return the result. If the setting is successful, **err** is **undefined**; otherwise, **err** is an error object.|
**Error codes**
...
...
@@ -1079,8 +1081,8 @@ For details about the error codes, see [AVSession Management Error Codes](../err
An AV session controller is created by calling [avSession.createController](#avsessioncreatecontroller). Through the AV session controller, you can query the session ID, send commands and events to a session, and obtain session metadata and playback state information.
...
...
@@ -1977,9 +1979,9 @@ For details about the error codes, see [AVSession Management Error Codes](../err
| callback | AsyncCallback<void\> | Yes | Callback used to return the result. If the event is sent, **err** is **undefined**. Otherwise, **err** is an error object.|
| callback | AsyncCallback<void\> | Yes | Callback used to return the result. If the event is sent, **err** is **undefined**; otherwise, **err** is an error object.|
**Error codes**
...
...
@@ -2226,11 +2228,11 @@ For details about the error codes, see [AVSession Management Error Codes](../err
| Promise<[WantAgent](js-apis-wantAgent.md)\> | Promise used to return the object saved by calling [setLaunchAbility](#setlaunchability). The object includes the application attribute, such as the bundle name, ability name, and device ID.|
| Promise<[WantAgent](js-apis-app-ability-wantAgent.md)\> | Promise used to return the object saved by calling [setLaunchAbility](#setlaunchability). The object includes the application attribute, such as the bundle name, ability name, and device ID.|
**Error codes**
...
...
@@ -2267,9 +2269,9 @@ For details about the error codes, see [AVSession Management Error Codes](../err
| callback | AsyncCallback<[WantAgent](js-apis-wantAgent.md)\> | Yes | Callback used to return the object saved by calling [setLaunchAbility](#setlaunchability). The object includes the application attribute, such as the bundle name, ability name, and device ID.|
| callback | AsyncCallback<[WantAgent](js-apis-app-ability-wantAgent.md)\> | Yes | Callback used to return the object saved by calling [setLaunchAbility](#setlaunchability). The object includes the application attribute, such as the bundle name, ability name, and device ID.|
**Error codes**
...
...
@@ -2303,9 +2305,9 @@ For details about the error codes, see [AVSession Management Error Codes](../err