1e41f4b71Sopenharmony_ci# @ohos.multimedia.avsession (媒体会话管理)
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ci媒体会话管理提供媒体播控相关功能的接口,目的是让应用接入播控中心。
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ci该模块提供以下媒体会话相关的常用功能:
6e41f4b71Sopenharmony_ci
7e41f4b71Sopenharmony_ci- [AVSession](#avsession10) : 会话,可用于设置元数据、播放状态信息等操作。
8e41f4b71Sopenharmony_ci- [AVSessionController](#avsessioncontroller10): 会话控制器,可用于查看会话ID,完成对会话发送命令及事件,获取会话元数据、播放状态信息等操作。
9e41f4b71Sopenharmony_ci- [AVCastController](#avcastcontroller10): 投播控制器,可用于投播场景下,完成播放控制、远端播放状态监听、远端播放状态信息获取等操作。
10e41f4b71Sopenharmony_ci
11e41f4b71Sopenharmony_ci> **说明:**
12e41f4b71Sopenharmony_ci>
13e41f4b71Sopenharmony_ci> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
14e41f4b71Sopenharmony_ci
15e41f4b71Sopenharmony_ci## 导入模块
16e41f4b71Sopenharmony_ci
17e41f4b71Sopenharmony_ci```ts
18e41f4b71Sopenharmony_ciimport { avSession } from '@kit.AVSessionKit';
19e41f4b71Sopenharmony_ci```
20e41f4b71Sopenharmony_ci
21e41f4b71Sopenharmony_ci## avSession.createAVSession<sup>10+</sup>
22e41f4b71Sopenharmony_ci
23e41f4b71Sopenharmony_cicreateAVSession(context: Context, tag: string, type: AVSessionType): Promise\<AVSession>
24e41f4b71Sopenharmony_ci
25e41f4b71Sopenharmony_ci创建会话对象,一个Ability只能存在一个会话,重复创建会失败,结果通过Promise异步回调方式返回。
26e41f4b71Sopenharmony_ci
27e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
28e41f4b71Sopenharmony_ci
29e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
30e41f4b71Sopenharmony_ci
31e41f4b71Sopenharmony_ci**参数:**
32e41f4b71Sopenharmony_ci
33e41f4b71Sopenharmony_ci| 参数名 | 类型                            | 必填 | 说明                           |
34e41f4b71Sopenharmony_ci| ------ | ------------------------------- | ---- | ------------------------------ |
35e41f4b71Sopenharmony_ci| context| [Context](../apis-ability-kit/js-apis-inner-app-context.md) | 是| 需要使用UIAbilityContext,用于系统获取应用组件的相关信息。 |
36e41f4b71Sopenharmony_ci| tag    | string                          | 是   | 会话的自定义名称。             |
37e41f4b71Sopenharmony_ci| type   | [AVSessionType](#avsessiontype10) | 是   | 会话类型。 |
38e41f4b71Sopenharmony_ci
39e41f4b71Sopenharmony_ci**返回值:**
40e41f4b71Sopenharmony_ci
41e41f4b71Sopenharmony_ci| 类型                              | 说明                                                         |
42e41f4b71Sopenharmony_ci| --------------------------------- | ------------------------------------------------------------ |
43e41f4b71Sopenharmony_ci| Promise<[AVSession](#avsession10)\> | Promise对象。回调返回会话实例对象,可用于获取会话ID,以及设置元数据、播放状态,发送按键事件等操作。|
44e41f4b71Sopenharmony_ci
45e41f4b71Sopenharmony_ci**错误码:**
46e41f4b71Sopenharmony_ci
47e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
48e41f4b71Sopenharmony_ci
49e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
50e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
51e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Parameter verification failed. |
52e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
53e41f4b71Sopenharmony_ci
54e41f4b71Sopenharmony_ci**示例:**
55e41f4b71Sopenharmony_ci
56e41f4b71Sopenharmony_ci```ts
57e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
58e41f4b71Sopenharmony_ci
59e41f4b71Sopenharmony_cilet currentAVSession: avSession.AVSession;
60e41f4b71Sopenharmony_cilet tag = "createNewSession";
61e41f4b71Sopenharmony_cilet context: Context = getContext(this);
62e41f4b71Sopenharmony_cilet sessionId: string;  // 供后续函数入参使用
63e41f4b71Sopenharmony_ci
64e41f4b71Sopenharmony_ciavSession.createAVSession(context, tag, "audio").then((data: avSession.AVSession) => {
65e41f4b71Sopenharmony_ci  currentAVSession = data;
66e41f4b71Sopenharmony_ci  sessionId = currentAVSession.sessionId;
67e41f4b71Sopenharmony_ci  console.info(`CreateAVSession : SUCCESS : sessionId = ${sessionId}`);
68e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
69e41f4b71Sopenharmony_ci  console.info(`CreateAVSession BusinessError: code: ${err.code}, message: ${err.message}`);
70e41f4b71Sopenharmony_ci});
71e41f4b71Sopenharmony_ci```
72e41f4b71Sopenharmony_ci
73e41f4b71Sopenharmony_ci## avSession.createAVSession<sup>10+</sup>
74e41f4b71Sopenharmony_ci
75e41f4b71Sopenharmony_cicreateAVSession(context: Context, tag: string, type: AVSessionType, callback: AsyncCallback\<AVSession>): void
76e41f4b71Sopenharmony_ci
77e41f4b71Sopenharmony_ci创建会话对象,一个Ability只能存在一个会话,重复创建会失败,结果通过callback异步回调方式返回。
78e41f4b71Sopenharmony_ci
79e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
80e41f4b71Sopenharmony_ci
81e41f4b71Sopenharmony_ci**参数:**
82e41f4b71Sopenharmony_ci
83e41f4b71Sopenharmony_ci| 参数名   | 类型                                    | 必填 | 说明                                                         |
84e41f4b71Sopenharmony_ci| -------- | --------------------------------------- | ---- | ------------------------------------------------------------ |
85e41f4b71Sopenharmony_ci| context| [Context](../apis-ability-kit/js-apis-inner-app-context.md) | 是| 需要使用UIAbilityContext,用于系统获取应用组件的相关信息。     |
86e41f4b71Sopenharmony_ci| tag      | string                                  | 是   | 会话的自定义名称。                                           |
87e41f4b71Sopenharmony_ci| type     | [AVSessionType](#avsessiontype10)         | 是   | 会话类型。                               |
88e41f4b71Sopenharmony_ci| callback | AsyncCallback<[AVSession](#avsession10)\> | 是   | 回调函数。回调返回会话实例对象,可用于获取会话ID,以及设置元数据、播放状态,发送按键事件等操作。 |
89e41f4b71Sopenharmony_ci
90e41f4b71Sopenharmony_ci**错误码:**
91e41f4b71Sopenharmony_ci
92e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
93e41f4b71Sopenharmony_ci
94e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
95e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
96e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Parameter verification failed. |
97e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
98e41f4b71Sopenharmony_ci
99e41f4b71Sopenharmony_ci**示例:**
100e41f4b71Sopenharmony_ci
101e41f4b71Sopenharmony_ci```ts
102e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
103e41f4b71Sopenharmony_ci
104e41f4b71Sopenharmony_cilet currentAVSession: avSession.AVSession;
105e41f4b71Sopenharmony_cilet tag = "createNewSession";
106e41f4b71Sopenharmony_cilet context: Context = getContext(this);
107e41f4b71Sopenharmony_cilet sessionId: string;  // 供后续函数入参使用
108e41f4b71Sopenharmony_ci
109e41f4b71Sopenharmony_ciavSession.createAVSession(context, tag, "audio", (err: BusinessError, data: avSession.AVSession) => {
110e41f4b71Sopenharmony_ci  if (err) {
111e41f4b71Sopenharmony_ci    console.error(`CreateAVSession BusinessError: code: ${err.code}, message: ${err.message}`);
112e41f4b71Sopenharmony_ci  } else {
113e41f4b71Sopenharmony_ci    currentAVSession = data;
114e41f4b71Sopenharmony_ci    sessionId = currentAVSession.sessionId;
115e41f4b71Sopenharmony_ci    console.info(`CreateAVSession : SUCCESS : sessionId = ${sessionId}`);
116e41f4b71Sopenharmony_ci  }
117e41f4b71Sopenharmony_ci});
118e41f4b71Sopenharmony_ci```
119e41f4b71Sopenharmony_ci
120e41f4b71Sopenharmony_ci## ProtocolType<sup>11+</sup>
121e41f4b71Sopenharmony_ci
122e41f4b71Sopenharmony_ci远端设备支持的协议类型的枚举。
123e41f4b71Sopenharmony_ci
124e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
125e41f4b71Sopenharmony_ci
126e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.AVCast
127e41f4b71Sopenharmony_ci
128e41f4b71Sopenharmony_ci| 名称                        | 值   | 说明         |
129e41f4b71Sopenharmony_ci| --------------------------- | ---- | ----------- |
130e41f4b71Sopenharmony_ci| TYPE_LOCAL<sup>11+</sup>      | 0    | 本地设备,包括设备本身的内置扬声器或音频插孔、A2DP 设备。 |
131e41f4b71Sopenharmony_ci| TYPE_CAST_PLUS_STREAM<sup>11+</sup>      | 2    | Cast+的Stream模式。表示媒体正在其他设备上展示。 |
132e41f4b71Sopenharmony_ci| TYPE_DLNA<sup>12+</sup>      | 4    | DLNA协议。表示媒体正在其他设备上展示。 |
133e41f4b71Sopenharmony_ci
134e41f4b71Sopenharmony_ci## AVSessionType<sup>10+<sup>
135e41f4b71Sopenharmony_ci
136e41f4b71Sopenharmony_citype AVSessionType = 'audio' | 'video' | 'voice_call' | 'video_call'
137e41f4b71Sopenharmony_ci
138e41f4b71Sopenharmony_ci当前会话支持的会话类型。
139e41f4b71Sopenharmony_ci
140e41f4b71Sopenharmony_ci该类型可取的值为下表字符串。
141e41f4b71Sopenharmony_ci
142e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
143e41f4b71Sopenharmony_ci
144e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
145e41f4b71Sopenharmony_ci
146e41f4b71Sopenharmony_ci| 类型  | 说明 |
147e41f4b71Sopenharmony_ci| -----  | ---- |
148e41f4b71Sopenharmony_ci| 'audio' | 音频 |
149e41f4b71Sopenharmony_ci| 'video' | 视频 |
150e41f4b71Sopenharmony_ci| 'voice_call'<sup>11+<sup> | 音频通话 |
151e41f4b71Sopenharmony_ci| 'video_call'<sup>12+<sup> | 视频通话 |
152e41f4b71Sopenharmony_ci
153e41f4b71Sopenharmony_ci## AVSession<sup>10+</sup>
154e41f4b71Sopenharmony_ci
155e41f4b71Sopenharmony_ci调用[avSession.createAVSession](#avsessioncreateavsession10)后,返回会话的实例,可以获得会话ID,完成设置元数据,播放状态信息等操作。
156e41f4b71Sopenharmony_ci
157e41f4b71Sopenharmony_ci### 属性
158e41f4b71Sopenharmony_ci
159e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
160e41f4b71Sopenharmony_ci
161e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
162e41f4b71Sopenharmony_ci
163e41f4b71Sopenharmony_ci| 名称      | 类型   | 可读 | 可写 | 说明                          |
164e41f4b71Sopenharmony_ci| :-------- | :----- | :--- | :--- | :---------------------------- |
165e41f4b71Sopenharmony_ci| sessionId | string | 是   | 否   | AVSession对象唯一的会话标识。 |
166e41f4b71Sopenharmony_ci| sessionType| [AVSessionType](#avsessiontype10) | 是   | 否   | AVSession会话类型。 |
167e41f4b71Sopenharmony_ci
168e41f4b71Sopenharmony_ci**示例:**
169e41f4b71Sopenharmony_ci
170e41f4b71Sopenharmony_ci```ts
171e41f4b71Sopenharmony_cilet sessionId: string = currentAVSession.sessionId;
172e41f4b71Sopenharmony_cilet sessionType: avSession.AVSessionType = currentAVSession.sessionType;
173e41f4b71Sopenharmony_ci```
174e41f4b71Sopenharmony_ci
175e41f4b71Sopenharmony_ci### setAVMetadata<sup>10+</sup>
176e41f4b71Sopenharmony_ci
177e41f4b71Sopenharmony_cisetAVMetadata(data: AVMetadata): Promise\<void>
178e41f4b71Sopenharmony_ci
179e41f4b71Sopenharmony_ci设置会话元数据。结果通过Promise异步回调方式返回。
180e41f4b71Sopenharmony_ci
181e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
182e41f4b71Sopenharmony_ci
183e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
184e41f4b71Sopenharmony_ci
185e41f4b71Sopenharmony_ci**参数:**
186e41f4b71Sopenharmony_ci
187e41f4b71Sopenharmony_ci| 参数名 | 类型                      | 必填 | 说明         |
188e41f4b71Sopenharmony_ci| ------ | ------------------------- | ---- | ------------ |
189e41f4b71Sopenharmony_ci| data   | [AVMetadata](#avmetadata10) | 是   | 会话元数据。 |
190e41f4b71Sopenharmony_ci
191e41f4b71Sopenharmony_ci**返回值:**
192e41f4b71Sopenharmony_ci
193e41f4b71Sopenharmony_ci| 类型           | 说明                          |
194e41f4b71Sopenharmony_ci| -------------- | ----------------------------- |
195e41f4b71Sopenharmony_ci| Promise\<void> | Promise对象。当元数据设置成功,无返回结果,否则返回错误对象。 |
196e41f4b71Sopenharmony_ci
197e41f4b71Sopenharmony_ci**错误码:**
198e41f4b71Sopenharmony_ci
199e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
200e41f4b71Sopenharmony_ci
201e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
202e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
203e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Parameter verification failed. |
204e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
205e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
206e41f4b71Sopenharmony_ci
207e41f4b71Sopenharmony_ci**示例:**
208e41f4b71Sopenharmony_ci
209e41f4b71Sopenharmony_ci```ts
210e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
211e41f4b71Sopenharmony_ci
212e41f4b71Sopenharmony_cilet metadata: avSession.AVMetadata = {
213e41f4b71Sopenharmony_ci  assetId: "121278",
214e41f4b71Sopenharmony_ci  title: "lose yourself",
215e41f4b71Sopenharmony_ci  artist: "Eminem",
216e41f4b71Sopenharmony_ci  author: "ST",
217e41f4b71Sopenharmony_ci  album: "Slim shady",
218e41f4b71Sopenharmony_ci  writer: "ST",
219e41f4b71Sopenharmony_ci  composer: "ST",
220e41f4b71Sopenharmony_ci  duration: 2222,
221e41f4b71Sopenharmony_ci  mediaImage: "https://www.example.com/example.jpg",
222e41f4b71Sopenharmony_ci  subtitle: "8 Mile",
223e41f4b71Sopenharmony_ci  description: "Rap",
224e41f4b71Sopenharmony_ci  // LRC中有两类元素:一种是时间标签+歌词,一种是ID标签。
225e41f4b71Sopenharmony_ci  // 例如:[00:25.44]xxx\r\n[00:26.44]xxx\r\n
226e41f4b71Sopenharmony_ci  lyric: "lrc格式歌词内容",
227e41f4b71Sopenharmony_ci  previousAssetId: "121277",
228e41f4b71Sopenharmony_ci  nextAssetId: "121279"
229e41f4b71Sopenharmony_ci};
230e41f4b71Sopenharmony_cicurrentAVSession.setAVMetadata(metadata).then(() => {
231e41f4b71Sopenharmony_ci  console.info('SetAVMetadata successfully');
232e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
233e41f4b71Sopenharmony_ci  console.error(`SetAVMetadata BusinessError: code: ${err.code}, message: ${err.message}`);
234e41f4b71Sopenharmony_ci});
235e41f4b71Sopenharmony_ci```
236e41f4b71Sopenharmony_ci
237e41f4b71Sopenharmony_ci### setAVMetadata<sup>10+</sup>
238e41f4b71Sopenharmony_ci
239e41f4b71Sopenharmony_cisetAVMetadata(data: AVMetadata, callback: AsyncCallback\<void>): void
240e41f4b71Sopenharmony_ci
241e41f4b71Sopenharmony_ci设置会话元数据。结果通过callback异步回调方式返回。
242e41f4b71Sopenharmony_ci
243e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
244e41f4b71Sopenharmony_ci
245e41f4b71Sopenharmony_ci**参数:**
246e41f4b71Sopenharmony_ci
247e41f4b71Sopenharmony_ci| 参数名   | 类型                      | 必填 | 说明                                  |
248e41f4b71Sopenharmony_ci| -------- | ------------------------- | ---- | ------------------------------------- |
249e41f4b71Sopenharmony_ci| data     | [AVMetadata](#avmetadata10) | 是   | 会话元数据。                          |
250e41f4b71Sopenharmony_ci| callback | AsyncCallback\<void>      | 是   | 回调函数。当元数据设置成功,err为undefined,否则返回错误对象。 |
251e41f4b71Sopenharmony_ci
252e41f4b71Sopenharmony_ci**错误码:**
253e41f4b71Sopenharmony_ci
254e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
255e41f4b71Sopenharmony_ci
256e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
257e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
258e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Parameter verification failed. |
259e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
260e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
261e41f4b71Sopenharmony_ci
262e41f4b71Sopenharmony_ci**示例:**
263e41f4b71Sopenharmony_ci
264e41f4b71Sopenharmony_ci```ts
265e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
266e41f4b71Sopenharmony_ci
267e41f4b71Sopenharmony_cilet metadata: avSession.AVMetadata = {
268e41f4b71Sopenharmony_ci  assetId: "121278",
269e41f4b71Sopenharmony_ci  title: "lose yourself",
270e41f4b71Sopenharmony_ci  artist: "Eminem",
271e41f4b71Sopenharmony_ci  author: "ST",
272e41f4b71Sopenharmony_ci  album: "Slim shady",
273e41f4b71Sopenharmony_ci  writer: "ST",
274e41f4b71Sopenharmony_ci  composer: "ST",
275e41f4b71Sopenharmony_ci  duration: 2222,
276e41f4b71Sopenharmony_ci  mediaImage: "https://www.example.com/example.jpg",
277e41f4b71Sopenharmony_ci  subtitle: "8 Mile",
278e41f4b71Sopenharmony_ci  description: "Rap",
279e41f4b71Sopenharmony_ci  // LRC中有两类元素:一种是时间标签+歌词,一种是ID标签。
280e41f4b71Sopenharmony_ci  // 例如:[00:25.44]xxx\r\n[00:26.44]xxx\r\n
281e41f4b71Sopenharmony_ci  lyric: "lrc格式歌词内容",
282e41f4b71Sopenharmony_ci  previousAssetId: "121277",
283e41f4b71Sopenharmony_ci  nextAssetId: "121279"
284e41f4b71Sopenharmony_ci};
285e41f4b71Sopenharmony_cicurrentAVSession.setAVMetadata(metadata, (err: BusinessError) => {
286e41f4b71Sopenharmony_ci  if (err) {
287e41f4b71Sopenharmony_ci    console.error(`SetAVMetadata BusinessError: code: ${err.code}, message: ${err.message}`);
288e41f4b71Sopenharmony_ci  } else {
289e41f4b71Sopenharmony_ci    console.info('SetAVMetadata successfully');
290e41f4b71Sopenharmony_ci  }
291e41f4b71Sopenharmony_ci});
292e41f4b71Sopenharmony_ci```
293e41f4b71Sopenharmony_ci
294e41f4b71Sopenharmony_ci### setCallMetadata<sup>11+</sup>
295e41f4b71Sopenharmony_ci
296e41f4b71Sopenharmony_cisetCallMetadata(data: CallMetadata): Promise\<void>
297e41f4b71Sopenharmony_ci
298e41f4b71Sopenharmony_ci设置通话会话元数据。结果通过Promise异步回调方式返回。
299e41f4b71Sopenharmony_ci
300e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
301e41f4b71Sopenharmony_ci
302e41f4b71Sopenharmony_ci**参数:**
303e41f4b71Sopenharmony_ci
304e41f4b71Sopenharmony_ci| 参数名 | 类型                      | 必填 | 说明         |
305e41f4b71Sopenharmony_ci| ------ | ------------------------- | ---- | ------------ |
306e41f4b71Sopenharmony_ci| data   | [CallMetadata](#callmetadata11) | 是   | 通话会话元数据。 |
307e41f4b71Sopenharmony_ci
308e41f4b71Sopenharmony_ci**返回值:**
309e41f4b71Sopenharmony_ci
310e41f4b71Sopenharmony_ci| 类型           | 说明                          |
311e41f4b71Sopenharmony_ci| -------------- | ----------------------------- |
312e41f4b71Sopenharmony_ci| Promise\<void> | Promise对象。当通话元数据设置成功,无返回结果,否则返回错误对象。 |
313e41f4b71Sopenharmony_ci
314e41f4b71Sopenharmony_ci**错误码:**
315e41f4b71Sopenharmony_ci
316e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
317e41f4b71Sopenharmony_ci
318e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
319e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
320e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 3.Parameter verification failed. |
321e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
322e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
323e41f4b71Sopenharmony_ci
324e41f4b71Sopenharmony_ci**示例:**
325e41f4b71Sopenharmony_ci
326e41f4b71Sopenharmony_ci```ts
327e41f4b71Sopenharmony_ciimport { image } from '@kit.ImageKit';
328e41f4b71Sopenharmony_ciimport { resourceManager } from '@kit.LocalizationKit';
329e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
330e41f4b71Sopenharmony_ci
331e41f4b71Sopenharmony_cilet value = await resourceManager.getSystemResourceManager().getRawFileContent('IMAGE_URI');
332e41f4b71Sopenharmony_ci    let imageSource = await image.createImageSource(value.buffer);
333e41f4b71Sopenharmony_ci    let imagePixel = await imageSource.createPixelMap({desiredSize:{width: 150, height: 150}});
334e41f4b71Sopenharmony_ci    let calldata: avSession.CallMetadata = {
335e41f4b71Sopenharmony_ci      name: "xiaoming",
336e41f4b71Sopenharmony_ci      phoneNumber: "111xxxxxxxx",
337e41f4b71Sopenharmony_ci      avatar: imagePixel
338e41f4b71Sopenharmony_ci    };
339e41f4b71Sopenharmony_cicurrentAVSession.setCallMetadata(calldata).then(() => {
340e41f4b71Sopenharmony_ci  console.info('setCallMetadata successfully');
341e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
342e41f4b71Sopenharmony_ci  console.error(`setCallMetadata BusinessError: code: ${err.code}, message: ${err.message}`);
343e41f4b71Sopenharmony_ci});
344e41f4b71Sopenharmony_ci```
345e41f4b71Sopenharmony_ci
346e41f4b71Sopenharmony_ci### setCallMetadata<sup>11+</sup>
347e41f4b71Sopenharmony_ci
348e41f4b71Sopenharmony_cisetCallMetadata(data: CallMetadata, callback: AsyncCallback\<void>): void
349e41f4b71Sopenharmony_ci
350e41f4b71Sopenharmony_ci设置通话会话元数据。结果通过callback异步回调方式返回。
351e41f4b71Sopenharmony_ci
352e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
353e41f4b71Sopenharmony_ci
354e41f4b71Sopenharmony_ci**参数:**
355e41f4b71Sopenharmony_ci
356e41f4b71Sopenharmony_ci| 参数名   | 类型                      | 必填 | 说明                                  |
357e41f4b71Sopenharmony_ci| -------- | ------------------------- | ---- | ------------------------------------- |
358e41f4b71Sopenharmony_ci| data     | [CallMetadata](#callmetadata11) | 是   | 通话会话元数据。                          |
359e41f4b71Sopenharmony_ci| callback | AsyncCallback\<void>      | 是   | 回调函数。当通话元数据设置成功,err为undefined,否则返回错误对象。 |
360e41f4b71Sopenharmony_ci
361e41f4b71Sopenharmony_ci**错误码:**
362e41f4b71Sopenharmony_ci
363e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
364e41f4b71Sopenharmony_ci
365e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
366e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
367e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 3.Parameter verification failed. |
368e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
369e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
370e41f4b71Sopenharmony_ci
371e41f4b71Sopenharmony_ci**示例:**
372e41f4b71Sopenharmony_ci
373e41f4b71Sopenharmony_ci```ts
374e41f4b71Sopenharmony_ciimport { image } from '@kit.ImageKit';
375e41f4b71Sopenharmony_ciimport { resourceManager } from '@kit.LocalizationKit';
376e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
377e41f4b71Sopenharmony_ci
378e41f4b71Sopenharmony_ciasync function setCallMetadata() {
379e41f4b71Sopenharmony_ci  let value = await resourceManager.getSystemResourceManager().getRawFileContent('IMAGE_URI');
380e41f4b71Sopenharmony_ci  let imageSource = await image.createImageSource(value.buffer);
381e41f4b71Sopenharmony_ci  let imagePixel = await imageSource.createPixelMap({desiredSize:{width: 150, height: 150}});
382e41f4b71Sopenharmony_ci  let calldata: avSession.CallMetadata = {
383e41f4b71Sopenharmony_ci    name: "xiaoming",
384e41f4b71Sopenharmony_ci    phoneNumber: "111xxxxxxxx",
385e41f4b71Sopenharmony_ci    avatar: imagePixel
386e41f4b71Sopenharmony_ci  };
387e41f4b71Sopenharmony_ci  currentAVSession.setCallMetadata(calldata, (err: BusinessError) => {
388e41f4b71Sopenharmony_ci    if (err) {
389e41f4b71Sopenharmony_ci      console.error(`setCallMetadata BusinessError: code: ${err.code}, message: ${err.message}`);
390e41f4b71Sopenharmony_ci    } else {
391e41f4b71Sopenharmony_ci      console.info('setCallMetadata successfully');
392e41f4b71Sopenharmony_ci    }
393e41f4b71Sopenharmony_ci  });
394e41f4b71Sopenharmony_ci}
395e41f4b71Sopenharmony_ci```
396e41f4b71Sopenharmony_ci
397e41f4b71Sopenharmony_ci### setAVCallState<sup>11+</sup>
398e41f4b71Sopenharmony_ci
399e41f4b71Sopenharmony_cisetAVCallState(state: AVCallState): Promise\<void>
400e41f4b71Sopenharmony_ci
401e41f4b71Sopenharmony_ci设置通话状态。结果通过Promise异步回调方式返回。
402e41f4b71Sopenharmony_ci
403e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
404e41f4b71Sopenharmony_ci
405e41f4b71Sopenharmony_ci**参数:**
406e41f4b71Sopenharmony_ci
407e41f4b71Sopenharmony_ci| 参数名 | 类型                      | 必填 | 说明         |
408e41f4b71Sopenharmony_ci| ------ | ------------------------- | ---- | ------------ |
409e41f4b71Sopenharmony_ci| state   | [AVCallState](#avcallstate11) | 是   | 通话状态。 |
410e41f4b71Sopenharmony_ci
411e41f4b71Sopenharmony_ci**返回值:**
412e41f4b71Sopenharmony_ci
413e41f4b71Sopenharmony_ci| 类型           | 说明                          |
414e41f4b71Sopenharmony_ci| -------------- | ----------------------------- |
415e41f4b71Sopenharmony_ci| Promise\<void> | Promise对象。当通话元数据设置成功,无返回结果,否则返回错误对象。 |
416e41f4b71Sopenharmony_ci
417e41f4b71Sopenharmony_ci**错误码:**
418e41f4b71Sopenharmony_ci
419e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
420e41f4b71Sopenharmony_ci
421e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
422e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
423e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Parameter verification failed. |
424e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
425e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
426e41f4b71Sopenharmony_ci
427e41f4b71Sopenharmony_ci**示例:**
428e41f4b71Sopenharmony_ci
429e41f4b71Sopenharmony_ci```ts
430e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
431e41f4b71Sopenharmony_ci
432e41f4b71Sopenharmony_cilet calldata: avSession.AVCallState = {
433e41f4b71Sopenharmony_ci  state: avSession.CallState.CALL_STATE_ACTIVE,
434e41f4b71Sopenharmony_ci  muted: false
435e41f4b71Sopenharmony_ci};
436e41f4b71Sopenharmony_cicurrentAVSession.setAVCallState(calldata).then(() => {
437e41f4b71Sopenharmony_ci  console.info('setAVCallState successfully');
438e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
439e41f4b71Sopenharmony_ci  console.error(`setAVCallState BusinessError: code: ${err.code}, message: ${err.message}`);
440e41f4b71Sopenharmony_ci});
441e41f4b71Sopenharmony_ci```
442e41f4b71Sopenharmony_ci
443e41f4b71Sopenharmony_ci### setAVCallState<sup>11+</sup>
444e41f4b71Sopenharmony_ci
445e41f4b71Sopenharmony_cisetAVCallState(state: AVCallState, callback: AsyncCallback\<void>): void
446e41f4b71Sopenharmony_ci
447e41f4b71Sopenharmony_ci设置通话状态。结果通过callback异步回调方式返回。
448e41f4b71Sopenharmony_ci
449e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
450e41f4b71Sopenharmony_ci
451e41f4b71Sopenharmony_ci**参数:**
452e41f4b71Sopenharmony_ci
453e41f4b71Sopenharmony_ci| 参数名   | 类型                      | 必填 | 说明                                  |
454e41f4b71Sopenharmony_ci| -------- | ------------------------- | ---- | ------------------------------------- |
455e41f4b71Sopenharmony_ci| state     | [AVCallState](#avcallstate11) | 是   | 通话状态。                          |
456e41f4b71Sopenharmony_ci| callback | AsyncCallback\<void>      | 是   | 回调函数。当通话元数据设置成功,err为undefined,否则返回错误对象。 |
457e41f4b71Sopenharmony_ci
458e41f4b71Sopenharmony_ci**错误码:**
459e41f4b71Sopenharmony_ci
460e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
461e41f4b71Sopenharmony_ci
462e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
463e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
464e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Parameter verification failed. |
465e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
466e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
467e41f4b71Sopenharmony_ci
468e41f4b71Sopenharmony_ci**示例:**
469e41f4b71Sopenharmony_ci
470e41f4b71Sopenharmony_ci```ts
471e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
472e41f4b71Sopenharmony_ci
473e41f4b71Sopenharmony_cilet avcalldata: avSession.AVCallState = {
474e41f4b71Sopenharmony_ci  state: avSession.CallState.CALL_STATE_ACTIVE,
475e41f4b71Sopenharmony_ci  muted: false
476e41f4b71Sopenharmony_ci};
477e41f4b71Sopenharmony_cicurrentAVSession.setAVCallState(avcalldata, (err: BusinessError) => {
478e41f4b71Sopenharmony_ci  if (err) {
479e41f4b71Sopenharmony_ci    console.error(`setAVCallState BusinessError: code: ${err.code}, message: ${err.message}`);
480e41f4b71Sopenharmony_ci  } else {
481e41f4b71Sopenharmony_ci    console.info('setAVCallState successfully');
482e41f4b71Sopenharmony_ci  }
483e41f4b71Sopenharmony_ci});
484e41f4b71Sopenharmony_ci```
485e41f4b71Sopenharmony_ci
486e41f4b71Sopenharmony_ci### setAVPlaybackState<sup>10+</sup>
487e41f4b71Sopenharmony_ci
488e41f4b71Sopenharmony_cisetAVPlaybackState(state: AVPlaybackState): Promise\<void>
489e41f4b71Sopenharmony_ci
490e41f4b71Sopenharmony_ci设置会话播放状态。结果通过Promise异步回调方式返回。
491e41f4b71Sopenharmony_ci
492e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
493e41f4b71Sopenharmony_ci
494e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
495e41f4b71Sopenharmony_ci
496e41f4b71Sopenharmony_ci**参数:**
497e41f4b71Sopenharmony_ci
498e41f4b71Sopenharmony_ci| 参数名 | 类型                                | 必填 | 说明                                           |
499e41f4b71Sopenharmony_ci| ------ | ----------------------------------- | ---- | ---------------------------------------------- |
500e41f4b71Sopenharmony_ci| state   | [AVPlaybackState](#avplaybackstate10) | 是   | 会话播放状态,包括状态、倍数、循环模式等信息。 |
501e41f4b71Sopenharmony_ci
502e41f4b71Sopenharmony_ci**返回值:**
503e41f4b71Sopenharmony_ci
504e41f4b71Sopenharmony_ci| 类型           | 说明                          |
505e41f4b71Sopenharmony_ci| -------------- | ----------------------------- |
506e41f4b71Sopenharmony_ci| Promise\<void> | Promise对象。当播放状态设置成功,无返回结果,否则返回错误对象。 |
507e41f4b71Sopenharmony_ci
508e41f4b71Sopenharmony_ci**错误码:**
509e41f4b71Sopenharmony_ci
510e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
511e41f4b71Sopenharmony_ci
512e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
513e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
514e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Parameter verification failed. |
515e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
516e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
517e41f4b71Sopenharmony_ci
518e41f4b71Sopenharmony_ci**示例:**
519e41f4b71Sopenharmony_ci
520e41f4b71Sopenharmony_ci```ts
521e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
522e41f4b71Sopenharmony_ci
523e41f4b71Sopenharmony_cilet playbackState: avSession.AVPlaybackState = {
524e41f4b71Sopenharmony_ci  state:avSession.PlaybackState.PLAYBACK_STATE_PLAY,
525e41f4b71Sopenharmony_ci  speed: 1.0,
526e41f4b71Sopenharmony_ci  position:{elapsedTime:10, updateTime:(new Date()).getTime()},
527e41f4b71Sopenharmony_ci  bufferedTime:1000,
528e41f4b71Sopenharmony_ci  loopMode:avSession.LoopMode.LOOP_MODE_SINGLE,
529e41f4b71Sopenharmony_ci  isFavorite:true
530e41f4b71Sopenharmony_ci};
531e41f4b71Sopenharmony_cicurrentAVSession.setAVPlaybackState(playbackState).then(() => {
532e41f4b71Sopenharmony_ci  console.info('SetAVPlaybackState successfully');
533e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
534e41f4b71Sopenharmony_ci  console.error(`SetAVPlaybackState BusinessError: code: ${err.code}, message: ${err.message}`);
535e41f4b71Sopenharmony_ci});
536e41f4b71Sopenharmony_ci```
537e41f4b71Sopenharmony_ci
538e41f4b71Sopenharmony_ci### setAVPlaybackState<sup>10+</sup>
539e41f4b71Sopenharmony_ci
540e41f4b71Sopenharmony_cisetAVPlaybackState(state: AVPlaybackState, callback: AsyncCallback\<void>): void
541e41f4b71Sopenharmony_ci
542e41f4b71Sopenharmony_ci设置会话播放状态。结果通过callback异步回调方式返回。
543e41f4b71Sopenharmony_ci
544e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
545e41f4b71Sopenharmony_ci
546e41f4b71Sopenharmony_ci**参数:**
547e41f4b71Sopenharmony_ci
548e41f4b71Sopenharmony_ci| 参数名   | 类型                                | 必填 | 说明                                           |
549e41f4b71Sopenharmony_ci| -------- | ----------------------------------- | ---- | ---------------------------------------------- |
550e41f4b71Sopenharmony_ci| state     | [AVPlaybackState](#avplaybackstate10) | 是   | 会话播放状态,包括状态、倍数、循环模式等信息。 |
551e41f4b71Sopenharmony_ci| callback | AsyncCallback\<void>                | 是   | 回调函数。当播放状态设置成功,err为undefined,否则返回错误对象。          |
552e41f4b71Sopenharmony_ci
553e41f4b71Sopenharmony_ci**错误码:**
554e41f4b71Sopenharmony_ci
555e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
556e41f4b71Sopenharmony_ci
557e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
558e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
559e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Parameter verification failed. |
560e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
561e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
562e41f4b71Sopenharmony_ci
563e41f4b71Sopenharmony_ci**示例:**
564e41f4b71Sopenharmony_ci
565e41f4b71Sopenharmony_ci```ts
566e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
567e41f4b71Sopenharmony_ci
568e41f4b71Sopenharmony_cilet PlaybackState: avSession.AVPlaybackState = {
569e41f4b71Sopenharmony_ci  state:avSession.PlaybackState.PLAYBACK_STATE_PLAY,
570e41f4b71Sopenharmony_ci  speed: 1.0,
571e41f4b71Sopenharmony_ci  position:{elapsedTime:10, updateTime:(new Date()).getTime()},
572e41f4b71Sopenharmony_ci  bufferedTime:1000,
573e41f4b71Sopenharmony_ci  loopMode:avSession.LoopMode.LOOP_MODE_SINGLE,
574e41f4b71Sopenharmony_ci  isFavorite:true
575e41f4b71Sopenharmony_ci};
576e41f4b71Sopenharmony_cicurrentAVSession.setAVPlaybackState(PlaybackState, (err: BusinessError) => {
577e41f4b71Sopenharmony_ci  if (err) {
578e41f4b71Sopenharmony_ci    console.error(`SetAVPlaybackState BusinessError: code: ${err.code}, message: ${err.message}`);
579e41f4b71Sopenharmony_ci  } else {
580e41f4b71Sopenharmony_ci    console.info('SetAVPlaybackState successfully');
581e41f4b71Sopenharmony_ci  }
582e41f4b71Sopenharmony_ci});
583e41f4b71Sopenharmony_ci```
584e41f4b71Sopenharmony_ci
585e41f4b71Sopenharmony_ci### setLaunchAbility<sup>10+</sup>
586e41f4b71Sopenharmony_ci
587e41f4b71Sopenharmony_cisetLaunchAbility(ability: WantAgent): Promise\<void>
588e41f4b71Sopenharmony_ci
589e41f4b71Sopenharmony_ci设置一个WantAgent用于拉起会话的Ability。结果通过Promise异步回调方式返回。
590e41f4b71Sopenharmony_ci
591e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
592e41f4b71Sopenharmony_ci
593e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
594e41f4b71Sopenharmony_ci
595e41f4b71Sopenharmony_ci**参数:**
596e41f4b71Sopenharmony_ci
597e41f4b71Sopenharmony_ci| 参数名  | 类型                                          | 必填 | 说明                                                        |
598e41f4b71Sopenharmony_ci| ------- | --------------------------------------------- | ---- | ----------------------------------------------------------- |
599e41f4b71Sopenharmony_ci| ability | [WantAgent](../apis-ability-kit/js-apis-app-ability-wantAgent.md) | 是   | 应用的相关属性信息,如bundleName,abilityName,deviceId等。 |
600e41f4b71Sopenharmony_ci
601e41f4b71Sopenharmony_ci**返回值:**
602e41f4b71Sopenharmony_ci
603e41f4b71Sopenharmony_ci| 类型           | 说明                          |
604e41f4b71Sopenharmony_ci| -------------- | ----------------------------- |
605e41f4b71Sopenharmony_ci| Promise\<void> | Promise对象。当Ability设置成功,无返回结果,否则返回错误对象。 |
606e41f4b71Sopenharmony_ci
607e41f4b71Sopenharmony_ci**错误码:**
608e41f4b71Sopenharmony_ci
609e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
610e41f4b71Sopenharmony_ci
611e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
612e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
613e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Parameter verification failed. |
614e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
615e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
616e41f4b71Sopenharmony_ci
617e41f4b71Sopenharmony_ci**示例:**
618e41f4b71Sopenharmony_ci
619e41f4b71Sopenharmony_ci```ts
620e41f4b71Sopenharmony_ciimport { wantAgent } from '@kit.AbilityKit';
621e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
622e41f4b71Sopenharmony_ci
623e41f4b71Sopenharmony_ci// WantAgentInfo对象
624e41f4b71Sopenharmony_cilet wantAgentInfo: wantAgent.WantAgentInfo = {
625e41f4b71Sopenharmony_ci  wants: [
626e41f4b71Sopenharmony_ci    {
627e41f4b71Sopenharmony_ci      deviceId: "deviceId",
628e41f4b71Sopenharmony_ci      bundleName: "com.example.myapplication",
629e41f4b71Sopenharmony_ci      abilityName: "EntryAbility",
630e41f4b71Sopenharmony_ci      action: "action1",
631e41f4b71Sopenharmony_ci      entities: ["entity1"],
632e41f4b71Sopenharmony_ci      type: "MIMETYPE",
633e41f4b71Sopenharmony_ci      uri: "key = {true,true,false}",
634e41f4b71Sopenharmony_ci      parameters:
635e41f4b71Sopenharmony_ci        {
636e41f4b71Sopenharmony_ci          mykey0: 2222,
637e41f4b71Sopenharmony_ci          mykey1: [1, 2, 3],
638e41f4b71Sopenharmony_ci          mykey2: "[1, 2, 3]",
639e41f4b71Sopenharmony_ci          mykey3: "ssssssssssssssssssssssssss",
640e41f4b71Sopenharmony_ci          mykey4: [false, true, false],
641e41f4b71Sopenharmony_ci          mykey5: ["qqqqq", "wwwwww", "aaaaaaaaaaaaaaaaa"],
642e41f4b71Sopenharmony_ci          mykey6: true
643e41f4b71Sopenharmony_ci        }
644e41f4b71Sopenharmony_ci    }
645e41f4b71Sopenharmony_ci  ],
646e41f4b71Sopenharmony_ci  operationType: wantAgent.OperationType.START_ABILITIES,
647e41f4b71Sopenharmony_ci  requestCode: 0,
648e41f4b71Sopenharmony_ci  wantAgentFlags:[wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
649e41f4b71Sopenharmony_ci}
650e41f4b71Sopenharmony_ci
651e41f4b71Sopenharmony_ciwantAgent.getWantAgent(wantAgentInfo).then((agent) => {
652e41f4b71Sopenharmony_ci  currentAVSession.setLaunchAbility(agent).then(() => {
653e41f4b71Sopenharmony_ci    console.info('SetLaunchAbility successfully');
654e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
655e41f4b71Sopenharmony_ci    console.error(`SetLaunchAbility BusinessError: code: ${err.code}, message: ${err.message}`);
656e41f4b71Sopenharmony_ci  });
657e41f4b71Sopenharmony_ci});
658e41f4b71Sopenharmony_ci```
659e41f4b71Sopenharmony_ci
660e41f4b71Sopenharmony_ci### setLaunchAbility<sup>10+</sup>
661e41f4b71Sopenharmony_ci
662e41f4b71Sopenharmony_cisetLaunchAbility(ability: WantAgent, callback: AsyncCallback\<void>): void
663e41f4b71Sopenharmony_ci
664e41f4b71Sopenharmony_ci设置一个WantAgent用于拉起会话的Ability。结果通过callback异步回调方式返回。
665e41f4b71Sopenharmony_ci
666e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
667e41f4b71Sopenharmony_ci
668e41f4b71Sopenharmony_ci**参数:**
669e41f4b71Sopenharmony_ci
670e41f4b71Sopenharmony_ci| 参数名   | 类型                                          | 必填 | 说明                                                         |
671e41f4b71Sopenharmony_ci| -------- | --------------------------------------------- | ---- | ------------------------------------------------------------ |
672e41f4b71Sopenharmony_ci| ability  | [WantAgent](../apis-ability-kit/js-apis-app-ability-wantAgent.md) | 是   | 应用的相关属性信息,如bundleName,abilityName,deviceId等。  |
673e41f4b71Sopenharmony_ci| callback | AsyncCallback\<void>                          | 是   | 回调函数。当Ability设置成功,err为undefined,否则返回错误对象。 |
674e41f4b71Sopenharmony_ci
675e41f4b71Sopenharmony_ci**错误码:**
676e41f4b71Sopenharmony_ci
677e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
678e41f4b71Sopenharmony_ci
679e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
680e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
681e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Parameter verification failed. |
682e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
683e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
684e41f4b71Sopenharmony_ci
685e41f4b71Sopenharmony_ci**示例:**
686e41f4b71Sopenharmony_ci
687e41f4b71Sopenharmony_ci```ts
688e41f4b71Sopenharmony_ciimport { wantAgent } from '@kit.AbilityKit';
689e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
690e41f4b71Sopenharmony_ci
691e41f4b71Sopenharmony_ci// WantAgentInfo对象
692e41f4b71Sopenharmony_cilet wantAgentInfo: wantAgent.WantAgentInfo = {
693e41f4b71Sopenharmony_ci  wants: [
694e41f4b71Sopenharmony_ci    {
695e41f4b71Sopenharmony_ci      deviceId: "deviceId",
696e41f4b71Sopenharmony_ci      bundleName: "com.example.myapplication",
697e41f4b71Sopenharmony_ci      abilityName: "EntryAbility",
698e41f4b71Sopenharmony_ci      action: "action1",
699e41f4b71Sopenharmony_ci      entities: ["entity1"],
700e41f4b71Sopenharmony_ci      type: "MIMETYPE",
701e41f4b71Sopenharmony_ci      uri: "key = {true,true,false}",
702e41f4b71Sopenharmony_ci      parameters:
703e41f4b71Sopenharmony_ci        {
704e41f4b71Sopenharmony_ci          mykey0: 2222,
705e41f4b71Sopenharmony_ci          mykey1: [1, 2, 3],
706e41f4b71Sopenharmony_ci          mykey2: "[1, 2, 3]",
707e41f4b71Sopenharmony_ci          mykey3: "ssssssssssssssssssssssssss",
708e41f4b71Sopenharmony_ci          mykey4: [false, true, false],
709e41f4b71Sopenharmony_ci          mykey5: ["qqqqq", "wwwwww", "aaaaaaaaaaaaaaaaa"],
710e41f4b71Sopenharmony_ci          mykey6: true
711e41f4b71Sopenharmony_ci        }
712e41f4b71Sopenharmony_ci    }
713e41f4b71Sopenharmony_ci  ],
714e41f4b71Sopenharmony_ci  operationType: wantAgent.OperationType.START_ABILITIES,
715e41f4b71Sopenharmony_ci  requestCode: 0,
716e41f4b71Sopenharmony_ci  wantAgentFlags:[wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
717e41f4b71Sopenharmony_ci}
718e41f4b71Sopenharmony_ci
719e41f4b71Sopenharmony_ciwantAgent.getWantAgent(wantAgentInfo).then((agent) => {
720e41f4b71Sopenharmony_ci  currentAVSession.setLaunchAbility(agent, (err: BusinessError) => {
721e41f4b71Sopenharmony_ci    if (err) {
722e41f4b71Sopenharmony_ci      console.error(`SetLaunchAbility BusinessError: code: ${err.code}, message: ${err.message}`);
723e41f4b71Sopenharmony_ci    } else {
724e41f4b71Sopenharmony_ci      console.info('SetLaunchAbility successfully');
725e41f4b71Sopenharmony_ci    }
726e41f4b71Sopenharmony_ci  });
727e41f4b71Sopenharmony_ci});
728e41f4b71Sopenharmony_ci```
729e41f4b71Sopenharmony_ci
730e41f4b71Sopenharmony_ci### dispatchSessionEvent<sup>10+</sup>
731e41f4b71Sopenharmony_ci
732e41f4b71Sopenharmony_cidispatchSessionEvent(event: string, args: {[key: string]: Object}): Promise\<void>
733e41f4b71Sopenharmony_ci
734e41f4b71Sopenharmony_ci媒体提供方设置一个会话内自定义事件,包括事件名和键值对形式的事件内容, 结果通过Promise异步回调方式返回。
735e41f4b71Sopenharmony_ci
736e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
737e41f4b71Sopenharmony_ci
738e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
739e41f4b71Sopenharmony_ci
740e41f4b71Sopenharmony_ci**参数:**
741e41f4b71Sopenharmony_ci
742e41f4b71Sopenharmony_ci| 参数名  | 类型                                          | 必填 | 说明                                                        |
743e41f4b71Sopenharmony_ci| ------- | --------------------------------------------- | ---- | ----------------------------------------------------------- |
744e41f4b71Sopenharmony_ci| event | string | 是   | 需要设置的会话事件的名称 |
745e41f4b71Sopenharmony_ci| args | {[key: string]: Object} | 是   | 需要传递的会话事件内容。 |
746e41f4b71Sopenharmony_ci
747e41f4b71Sopenharmony_ci> **说明:**
748e41f4b71Sopenharmony_ci> 参数args支持的数据类型有:字符串、数字、布尔、对象、数组和文件描述符等,详细介绍请参见[@ohos.app.ability.Want(Want)](../apis-ability-kit/js-apis-app-ability-want.md)。
749e41f4b71Sopenharmony_ci
750e41f4b71Sopenharmony_ci**返回值:**
751e41f4b71Sopenharmony_ci
752e41f4b71Sopenharmony_ci| 类型           | 说明                          |
753e41f4b71Sopenharmony_ci| -------------- | ----------------------------- |
754e41f4b71Sopenharmony_ci| Promise\<void> | Promise对象。当事件设置成功,无返回结果,否则返回错误对象。 |
755e41f4b71Sopenharmony_ci
756e41f4b71Sopenharmony_ci**错误码:**
757e41f4b71Sopenharmony_ci
758e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
759e41f4b71Sopenharmony_ci
760e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
761e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
762e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 3.Parameter verification failed. |
763e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
764e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
765e41f4b71Sopenharmony_ci
766e41f4b71Sopenharmony_ci**示例:**
767e41f4b71Sopenharmony_ci
768e41f4b71Sopenharmony_ci```ts
769e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
770e41f4b71Sopenharmony_ci
771e41f4b71Sopenharmony_cilet currentAVSession: avSession.AVSession | undefined = undefined;
772e41f4b71Sopenharmony_cilet tag = "createNewSession";
773e41f4b71Sopenharmony_cilet context: Context = getContext(this);
774e41f4b71Sopenharmony_ci
775e41f4b71Sopenharmony_ciavSession.createAVSession(context, tag, "audio", (err: BusinessError, data: avSession.AVSession) => {
776e41f4b71Sopenharmony_ci  if (err) {
777e41f4b71Sopenharmony_ci    console.error(`CreateAVSession BusinessError: code: ${err.code}, message: ${err.message}`);
778e41f4b71Sopenharmony_ci  } else {
779e41f4b71Sopenharmony_ci    currentAVSession = data;
780e41f4b71Sopenharmony_ci  }
781e41f4b71Sopenharmony_ci});
782e41f4b71Sopenharmony_cilet eventName = "dynamic_lyric";
783e41f4b71Sopenharmony_ciif (currentAVSession !== undefined) {
784e41f4b71Sopenharmony_ci  (currentAVSession as avSession.AVSession).dispatchSessionEvent(eventName, {lyric : "This is lyric"}).then(() => {
785e41f4b71Sopenharmony_ci    console.info('dispatchSessionEvent successfully');
786e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
787e41f4b71Sopenharmony_ci    console.error(`dispatchSessionEvent BusinessError: code: ${err.code}, message: ${err.message}`);
788e41f4b71Sopenharmony_ci  })
789e41f4b71Sopenharmony_ci}
790e41f4b71Sopenharmony_ci```
791e41f4b71Sopenharmony_ci
792e41f4b71Sopenharmony_ci### dispatchSessionEvent<sup>10+</sup>
793e41f4b71Sopenharmony_ci
794e41f4b71Sopenharmony_cidispatchSessionEvent(event: string, args: {[key: string]: Object}, callback: AsyncCallback\<void>): void
795e41f4b71Sopenharmony_ci
796e41f4b71Sopenharmony_ci媒体提供方设置一个会话内自定义事件,包括事件名和键值对形式的事件内容, 结果通过callback异步回调方式返回。
797e41f4b71Sopenharmony_ci
798e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
799e41f4b71Sopenharmony_ci
800e41f4b71Sopenharmony_ci**参数:**
801e41f4b71Sopenharmony_ci
802e41f4b71Sopenharmony_ci| 参数名  | 类型                                          | 必填 | 说明                                                        |
803e41f4b71Sopenharmony_ci| ------- | --------------------------------------------- | ---- | ----------------------------------------------------------- |
804e41f4b71Sopenharmony_ci| event | string | 是   | 需要设置的会话事件的名称 |
805e41f4b71Sopenharmony_ci| args | {[key: string]: Object} | 是   | 需要传递的会话事件内容。 |
806e41f4b71Sopenharmony_ci| callback | AsyncCallback\<void>                          | 是   | 回调函数。当会话事件设置成功,err为undefined,否则返回错误对象。 |
807e41f4b71Sopenharmony_ci
808e41f4b71Sopenharmony_ci> **说明:**
809e41f4b71Sopenharmony_ci
810e41f4b71Sopenharmony_ci> 参数args支持的数据类型有:字符串、数字、布尔、对象、数组和文件描述符等,详细介绍请参见[@ohos.app.ability.Want(Want)](../apis-ability-kit/js-apis-app-ability-want.md)。
811e41f4b71Sopenharmony_ci
812e41f4b71Sopenharmony_ci**错误码:**
813e41f4b71Sopenharmony_ci
814e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
815e41f4b71Sopenharmony_ci
816e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
817e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
818e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 3.Parameter verification failed. |
819e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
820e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
821e41f4b71Sopenharmony_ci
822e41f4b71Sopenharmony_ci**示例:**
823e41f4b71Sopenharmony_ci
824e41f4b71Sopenharmony_ci```ts
825e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
826e41f4b71Sopenharmony_ci
827e41f4b71Sopenharmony_cilet currentAVSession: avSession.AVSession | undefined = undefined;
828e41f4b71Sopenharmony_cilet tag = "createNewSession";
829e41f4b71Sopenharmony_cilet context: Context = getContext(this);
830e41f4b71Sopenharmony_ci
831e41f4b71Sopenharmony_ciavSession.createAVSession(context, tag, "audio", (err: BusinessError, data: avSession.AVSession) => {
832e41f4b71Sopenharmony_ci  if (err) {
833e41f4b71Sopenharmony_ci    console.error(`CreateAVSession BusinessError: code: ${err.code}, message: ${err.message}`);
834e41f4b71Sopenharmony_ci  } else {
835e41f4b71Sopenharmony_ci    currentAVSession = data;
836e41f4b71Sopenharmony_ci  }
837e41f4b71Sopenharmony_ci});
838e41f4b71Sopenharmony_cilet eventName: string = "dynamic_lyric";
839e41f4b71Sopenharmony_ciif (currentAVSession !== undefined) {
840e41f4b71Sopenharmony_ci  (currentAVSession as avSession.AVSession).dispatchSessionEvent(eventName, {lyric : "This is lyric"}, (err: BusinessError) => {
841e41f4b71Sopenharmony_ci    if (err) {
842e41f4b71Sopenharmony_ci      console.error(`dispatchSessionEvent BusinessError: code: ${err.code}, message: ${err.message}`);
843e41f4b71Sopenharmony_ci    }
844e41f4b71Sopenharmony_ci  })
845e41f4b71Sopenharmony_ci}
846e41f4b71Sopenharmony_ci```
847e41f4b71Sopenharmony_ci
848e41f4b71Sopenharmony_ci### setAVQueueItems<sup>10+</sup>
849e41f4b71Sopenharmony_ci
850e41f4b71Sopenharmony_cisetAVQueueItems(items: Array\<AVQueueItem>): Promise\<void>
851e41f4b71Sopenharmony_ci
852e41f4b71Sopenharmony_ci设置媒体播放列表。结果通过Promise异步回调方式返回。
853e41f4b71Sopenharmony_ci
854e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
855e41f4b71Sopenharmony_ci
856e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
857e41f4b71Sopenharmony_ci
858e41f4b71Sopenharmony_ci**参数:**
859e41f4b71Sopenharmony_ci
860e41f4b71Sopenharmony_ci| 参数名  | 类型                                 | 必填 | 说明                               |
861e41f4b71Sopenharmony_ci| ------ | ------------------------------------ | ---- | ---------------------------------- |
862e41f4b71Sopenharmony_ci| items  | Array<[AVQueueItem](#avqueueitem10)\> | 是   | 播放列表单项的队列,用以表示播放列表。 |
863e41f4b71Sopenharmony_ci
864e41f4b71Sopenharmony_ci**返回值:**
865e41f4b71Sopenharmony_ci
866e41f4b71Sopenharmony_ci| 类型           | 说明                          |
867e41f4b71Sopenharmony_ci| -------------- | ----------------------------- |
868e41f4b71Sopenharmony_ci| Promise\<void> | Promise对象。当播放列表设置成功,无返回结果,否则返回错误对象。 |
869e41f4b71Sopenharmony_ci
870e41f4b71Sopenharmony_ci**错误码:**
871e41f4b71Sopenharmony_ci
872e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
873e41f4b71Sopenharmony_ci
874e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
875e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
876e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Parameter verification failed. |
877e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
878e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
879e41f4b71Sopenharmony_ci
880e41f4b71Sopenharmony_ci**示例:**
881e41f4b71Sopenharmony_ci
882e41f4b71Sopenharmony_ci```ts
883e41f4b71Sopenharmony_ciimport { image } from '@kit.ImageKit';
884e41f4b71Sopenharmony_ciimport { resourceManager } from '@kit.LocalizationKit';
885e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
886e41f4b71Sopenharmony_ci
887e41f4b71Sopenharmony_ciasync function setAVQueueItems() {
888e41f4b71Sopenharmony_ci  let value = await resourceManager.getSystemResourceManager().getRawFileContent('IMAGE_URI');
889e41f4b71Sopenharmony_ci  let imageSource = await image.createImageSource(value.buffer);
890e41f4b71Sopenharmony_ci  let imagePixel = await imageSource.createPixelMap({desiredSize:{width: 150, height: 150}});
891e41f4b71Sopenharmony_ci  let queueItemDescription_1: avSession.AVMediaDescription = {
892e41f4b71Sopenharmony_ci    assetId: '001',
893e41f4b71Sopenharmony_ci    title: 'music_name',
894e41f4b71Sopenharmony_ci    subtitle: 'music_sub_name',
895e41f4b71Sopenharmony_ci    description: 'music_description',
896e41f4b71Sopenharmony_ci    mediaImage : imagePixel,
897e41f4b71Sopenharmony_ci    extras: {extras:'any'}
898e41f4b71Sopenharmony_ci  };
899e41f4b71Sopenharmony_ci  let queueItem_1: avSession.AVQueueItem = {
900e41f4b71Sopenharmony_ci    itemId: 1,
901e41f4b71Sopenharmony_ci    description: queueItemDescription_1
902e41f4b71Sopenharmony_ci  };
903e41f4b71Sopenharmony_ci  let queueItemDescription_2: avSession.AVMediaDescription = {
904e41f4b71Sopenharmony_ci    assetId: '002',
905e41f4b71Sopenharmony_ci    title: 'music_name',
906e41f4b71Sopenharmony_ci    subtitle: 'music_sub_name',
907e41f4b71Sopenharmony_ci    description: 'music_description',
908e41f4b71Sopenharmony_ci    mediaImage: imagePixel,
909e41f4b71Sopenharmony_ci    extras: {extras:'any'}
910e41f4b71Sopenharmony_ci  };
911e41f4b71Sopenharmony_ci  let queueItem_2: avSession.AVQueueItem = {
912e41f4b71Sopenharmony_ci    itemId: 2,
913e41f4b71Sopenharmony_ci    description: queueItemDescription_2
914e41f4b71Sopenharmony_ci  };
915e41f4b71Sopenharmony_ci  let queueItemsArray: avSession.AVQueueItem[] = [queueItem_1, queueItem_2];
916e41f4b71Sopenharmony_ci  currentAVSession.setAVQueueItems(queueItemsArray).then(() => {
917e41f4b71Sopenharmony_ci    console.info('SetAVQueueItems successfully');
918e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
919e41f4b71Sopenharmony_ci    console.error(`SetAVQueueItems BusinessError: code: ${err.code}, message: ${err.message}`);
920e41f4b71Sopenharmony_ci  });
921e41f4b71Sopenharmony_ci}
922e41f4b71Sopenharmony_ci```
923e41f4b71Sopenharmony_ci
924e41f4b71Sopenharmony_ci### setAVQueueItems<sup>10+</sup>
925e41f4b71Sopenharmony_ci
926e41f4b71Sopenharmony_cisetAVQueueItems(items: Array\<AVQueueItem>, callback: AsyncCallback\<void>): void
927e41f4b71Sopenharmony_ci
928e41f4b71Sopenharmony_ci设置媒体播放列表。结果通过callback异步回调方式返回。
929e41f4b71Sopenharmony_ci
930e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
931e41f4b71Sopenharmony_ci
932e41f4b71Sopenharmony_ci**参数:**
933e41f4b71Sopenharmony_ci
934e41f4b71Sopenharmony_ci| 参数名   | 类型                                  | 必填 | 说明                                                         |
935e41f4b71Sopenharmony_ci| -------- | ------------------------------------ | ---- | ----------------------------------------------------------- |
936e41f4b71Sopenharmony_ci| items    | Array<[AVQueueItem](#avqueueitem10)\> | 是   | 播放列表单项的队列,用以表示播放列表。                          |
937e41f4b71Sopenharmony_ci| callback | AsyncCallback\<void>                 | 是   | 回调函数。当播放状态设置成功,err为undefined,否则返回错误对象。 |
938e41f4b71Sopenharmony_ci
939e41f4b71Sopenharmony_ci**错误码:**
940e41f4b71Sopenharmony_ci
941e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
942e41f4b71Sopenharmony_ci
943e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
944e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
945e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Parameter verification failed. |
946e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
947e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
948e41f4b71Sopenharmony_ci
949e41f4b71Sopenharmony_ci**示例:**
950e41f4b71Sopenharmony_ci
951e41f4b71Sopenharmony_ci```ts
952e41f4b71Sopenharmony_ciimport { image } from '@kit.ImageKit';
953e41f4b71Sopenharmony_ciimport { resourceManager } from '@kit.LocalizationKit';
954e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
955e41f4b71Sopenharmony_ci
956e41f4b71Sopenharmony_ciasync function setAVQueueItems() {
957e41f4b71Sopenharmony_ci  let value = await resourceManager.getSystemResourceManager().getRawFileContent('IMAGE_URI');
958e41f4b71Sopenharmony_ci  let imageSource = await image.createImageSource(value.buffer);
959e41f4b71Sopenharmony_ci  let imagePixel = await imageSource.createPixelMap({desiredSize:{width: 150, height: 150}});
960e41f4b71Sopenharmony_ci  let queueItemDescription_1: avSession.AVMediaDescription = {
961e41f4b71Sopenharmony_ci    assetId: '001',
962e41f4b71Sopenharmony_ci    title: 'music_name',
963e41f4b71Sopenharmony_ci    subtitle: 'music_sub_name',
964e41f4b71Sopenharmony_ci    description: 'music_description',
965e41f4b71Sopenharmony_ci    mediaImage : imagePixel,
966e41f4b71Sopenharmony_ci    extras: {extras:'any'}
967e41f4b71Sopenharmony_ci  };
968e41f4b71Sopenharmony_ci  let queueItem_1: avSession.AVQueueItem = {
969e41f4b71Sopenharmony_ci    itemId: 1,
970e41f4b71Sopenharmony_ci    description: queueItemDescription_1
971e41f4b71Sopenharmony_ci  };
972e41f4b71Sopenharmony_ci  let queueItemDescription_2: avSession.AVMediaDescription = {
973e41f4b71Sopenharmony_ci    assetId: '002',
974e41f4b71Sopenharmony_ci    title: 'music_name',
975e41f4b71Sopenharmony_ci    subtitle: 'music_sub_name',
976e41f4b71Sopenharmony_ci    description: 'music_description',
977e41f4b71Sopenharmony_ci    mediaImage: imagePixel,
978e41f4b71Sopenharmony_ci    extras: {extras:'any'}
979e41f4b71Sopenharmony_ci  };
980e41f4b71Sopenharmony_ci  let queueItem_2: avSession.AVQueueItem = {
981e41f4b71Sopenharmony_ci    itemId: 2,
982e41f4b71Sopenharmony_ci    description: queueItemDescription_2
983e41f4b71Sopenharmony_ci  };
984e41f4b71Sopenharmony_ci  let queueItemsArray: avSession.AVQueueItem[] = [queueItem_1, queueItem_2];
985e41f4b71Sopenharmony_ci  currentAVSession.setAVQueueItems(queueItemsArray, (err: BusinessError) => {
986e41f4b71Sopenharmony_ci    if (err) {
987e41f4b71Sopenharmony_ci      console.error(`SetAVQueueItems BusinessError: code: ${err.code}, message: ${err.message}`);
988e41f4b71Sopenharmony_ci    } else {
989e41f4b71Sopenharmony_ci      console.info('SetAVQueueItems successfully');
990e41f4b71Sopenharmony_ci    }
991e41f4b71Sopenharmony_ci  });
992e41f4b71Sopenharmony_ci}
993e41f4b71Sopenharmony_ci```
994e41f4b71Sopenharmony_ci
995e41f4b71Sopenharmony_ci### setAVQueueTitle<sup>10+</sup>
996e41f4b71Sopenharmony_ci
997e41f4b71Sopenharmony_cisetAVQueueTitle(title: string): Promise\<void>
998e41f4b71Sopenharmony_ci
999e41f4b71Sopenharmony_ci设置媒体播放列表名称。结果通过Promise异步回调方式返回。
1000e41f4b71Sopenharmony_ci
1001e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
1002e41f4b71Sopenharmony_ci
1003e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
1004e41f4b71Sopenharmony_ci
1005e41f4b71Sopenharmony_ci**参数:**
1006e41f4b71Sopenharmony_ci
1007e41f4b71Sopenharmony_ci| 参数名  | 类型   | 必填 | 说明           |
1008e41f4b71Sopenharmony_ci| ------ | ------ | ---- | -------------- |
1009e41f4b71Sopenharmony_ci| title  | string | 是   | 播放列表的名称。 |
1010e41f4b71Sopenharmony_ci
1011e41f4b71Sopenharmony_ci**返回值:**
1012e41f4b71Sopenharmony_ci
1013e41f4b71Sopenharmony_ci| 类型           | 说明                          |
1014e41f4b71Sopenharmony_ci| -------------- | ----------------------------- |
1015e41f4b71Sopenharmony_ci| Promise\<void> | Promise对象。当播放列表设置成功,无返回结果,否则返回错误对象。 |
1016e41f4b71Sopenharmony_ci
1017e41f4b71Sopenharmony_ci**错误码:**
1018e41f4b71Sopenharmony_ci
1019e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
1020e41f4b71Sopenharmony_ci
1021e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
1022e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
1023e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Parameter verification failed. |
1024e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
1025e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
1026e41f4b71Sopenharmony_ci
1027e41f4b71Sopenharmony_ci**示例:**
1028e41f4b71Sopenharmony_ci
1029e41f4b71Sopenharmony_ci```ts
1030e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1031e41f4b71Sopenharmony_ci
1032e41f4b71Sopenharmony_cilet queueTitle = 'QUEUE_TITLE';
1033e41f4b71Sopenharmony_cicurrentAVSession.setAVQueueTitle(queueTitle).then(() => {
1034e41f4b71Sopenharmony_ci  console.info('SetAVQueueTitle successfully');
1035e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
1036e41f4b71Sopenharmony_ci  console.error(`SetAVQueueTitle BusinessError: code: ${err.code}, message: ${err.message}`);
1037e41f4b71Sopenharmony_ci});
1038e41f4b71Sopenharmony_ci```
1039e41f4b71Sopenharmony_ci
1040e41f4b71Sopenharmony_ci### setAVQueueTitle<sup>10+</sup>
1041e41f4b71Sopenharmony_ci
1042e41f4b71Sopenharmony_cisetAVQueueTitle(title: string, callback: AsyncCallback\<void>): void
1043e41f4b71Sopenharmony_ci
1044e41f4b71Sopenharmony_ci设置媒体播放列表名称。结果通过callback异步回调方式返回。
1045e41f4b71Sopenharmony_ci
1046e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
1047e41f4b71Sopenharmony_ci
1048e41f4b71Sopenharmony_ci**参数:**
1049e41f4b71Sopenharmony_ci
1050e41f4b71Sopenharmony_ci| 参数名   | 类型                                  | 必填 | 说明                                                         |
1051e41f4b71Sopenharmony_ci| -------- | --------------------- | ---- | ----------------------------------------------------------- |
1052e41f4b71Sopenharmony_ci| title    | string                | 是   | 播放列表名称字段。                          |
1053e41f4b71Sopenharmony_ci| callback | AsyncCallback\<void>  | 是   | 回调函数。当播放状态设置成功,err为undefined,否则返回错误对象。 |
1054e41f4b71Sopenharmony_ci
1055e41f4b71Sopenharmony_ci**错误码:**
1056e41f4b71Sopenharmony_ci
1057e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
1058e41f4b71Sopenharmony_ci
1059e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
1060e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
1061e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Parameter verification failed. |
1062e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
1063e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
1064e41f4b71Sopenharmony_ci
1065e41f4b71Sopenharmony_ci**示例:**
1066e41f4b71Sopenharmony_ci
1067e41f4b71Sopenharmony_ci```ts
1068e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1069e41f4b71Sopenharmony_ci
1070e41f4b71Sopenharmony_cilet queueTitle = 'QUEUE_TITLE';
1071e41f4b71Sopenharmony_cicurrentAVSession.setAVQueueTitle(queueTitle, (err: BusinessError) => {
1072e41f4b71Sopenharmony_ci  if (err) {
1073e41f4b71Sopenharmony_ci    console.error(`SetAVQueueTitle BusinessError: code: ${err.code}, message: ${err.message}`);
1074e41f4b71Sopenharmony_ci  } else {
1075e41f4b71Sopenharmony_ci    console.info('SetAVQueueTitle successfully');
1076e41f4b71Sopenharmony_ci  }
1077e41f4b71Sopenharmony_ci});
1078e41f4b71Sopenharmony_ci```
1079e41f4b71Sopenharmony_ci
1080e41f4b71Sopenharmony_ci### setExtras<sup>10+</sup>
1081e41f4b71Sopenharmony_ci
1082e41f4b71Sopenharmony_cisetExtras(extras: {[key: string]: Object}): Promise\<void>
1083e41f4b71Sopenharmony_ci
1084e41f4b71Sopenharmony_ci媒体提供方设置键值对形式的自定义媒体数据包, 结果通过Promise异步回调方式返回。
1085e41f4b71Sopenharmony_ci
1086e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
1087e41f4b71Sopenharmony_ci
1088e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
1089e41f4b71Sopenharmony_ci
1090e41f4b71Sopenharmony_ci**参数:**
1091e41f4b71Sopenharmony_ci
1092e41f4b71Sopenharmony_ci| 参数名  | 类型                                          | 必填 | 说明                                                        |
1093e41f4b71Sopenharmony_ci| ------- | --------------------------------------------- | ---- | ----------------------------------------------------------- |
1094e41f4b71Sopenharmony_ci| extras | {[key: string]: Object} | 是   | 需要传递的自定义媒体数据包键值对 |
1095e41f4b71Sopenharmony_ci
1096e41f4b71Sopenharmony_ci> **说明:**
1097e41f4b71Sopenharmony_ci
1098e41f4b71Sopenharmony_ci> 参数extras支持的数据类型有:字符串、数字、布尔、对象、数组和文件描述符等,详细介绍请参见[@ohos.app.ability.Want(Want)](../apis-ability-kit/js-apis-app-ability-want.md)。
1099e41f4b71Sopenharmony_ci
1100e41f4b71Sopenharmony_ci**返回值:**
1101e41f4b71Sopenharmony_ci
1102e41f4b71Sopenharmony_ci| 类型           | 说明                          |
1103e41f4b71Sopenharmony_ci| -------------- | ----------------------------- |
1104e41f4b71Sopenharmony_ci| Promise\<void> | Promise对象。当自定义媒体数据包设置成功,无返回结果,否则返回错误对象。 |
1105e41f4b71Sopenharmony_ci
1106e41f4b71Sopenharmony_ci**错误码:**
1107e41f4b71Sopenharmony_ci
1108e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
1109e41f4b71Sopenharmony_ci
1110e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
1111e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
1112e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Parameter verification failed. |
1113e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
1114e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
1115e41f4b71Sopenharmony_ci
1116e41f4b71Sopenharmony_ci**示例:**
1117e41f4b71Sopenharmony_ci
1118e41f4b71Sopenharmony_ci```ts
1119e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1120e41f4b71Sopenharmony_ci
1121e41f4b71Sopenharmony_cilet currentAVSession: avSession.AVSession | undefined = undefined;
1122e41f4b71Sopenharmony_cilet tag = "createNewSession";
1123e41f4b71Sopenharmony_cilet context: Context = getContext(this);
1124e41f4b71Sopenharmony_ci
1125e41f4b71Sopenharmony_ciavSession.createAVSession(context, tag, "audio", (err: BusinessError, data: avSession.AVSession) => {
1126e41f4b71Sopenharmony_ci  if (err) {
1127e41f4b71Sopenharmony_ci    console.error(`CreateAVSession BusinessError: code: ${err.code}, message: ${err.message}`);
1128e41f4b71Sopenharmony_ci  } else {
1129e41f4b71Sopenharmony_ci    currentAVSession = data;
1130e41f4b71Sopenharmony_ci  }
1131e41f4b71Sopenharmony_ci});
1132e41f4b71Sopenharmony_ciif (currentAVSession !== undefined) {
1133e41f4b71Sopenharmony_ci  (currentAVSession as avSession.AVSession).setExtras({extras : "This is custom media packet"}).then(() => {
1134e41f4b71Sopenharmony_ci    console.info('setExtras successfully');
1135e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
1136e41f4b71Sopenharmony_ci    console.error(`setExtras BusinessError: code: ${err.code}, message: ${err.message}`);
1137e41f4b71Sopenharmony_ci  })
1138e41f4b71Sopenharmony_ci}
1139e41f4b71Sopenharmony_ci```
1140e41f4b71Sopenharmony_ci
1141e41f4b71Sopenharmony_ci### setExtras<sup>10+</sup>
1142e41f4b71Sopenharmony_ci
1143e41f4b71Sopenharmony_cisetExtras(extras: {[key: string]: Object}, callback: AsyncCallback\<void>): void
1144e41f4b71Sopenharmony_ci
1145e41f4b71Sopenharmony_ci媒体提供方设置键值对形式的自定义媒体数据包, 结果通过callback异步回调方式返回。
1146e41f4b71Sopenharmony_ci
1147e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
1148e41f4b71Sopenharmony_ci
1149e41f4b71Sopenharmony_ci**参数:**
1150e41f4b71Sopenharmony_ci
1151e41f4b71Sopenharmony_ci| 参数名  | 类型                                          | 必填 | 说明                                                        |
1152e41f4b71Sopenharmony_ci| ------- | --------------------------------------------- | ---- | ----------------------------------------------------------- |
1153e41f4b71Sopenharmony_ci| extras | {[key: string]: Object} | 是   | 需要传递的自定义媒体数据包键值对 |
1154e41f4b71Sopenharmony_ci| callback | AsyncCallback\<void>                          | 是   | 回调函数。当自定义媒体数据包设置成功,err为undefined,否则返回错误对象。 |
1155e41f4b71Sopenharmony_ci
1156e41f4b71Sopenharmony_ci> **说明:**
1157e41f4b71Sopenharmony_ci
1158e41f4b71Sopenharmony_ci> 参数extras支持的数据类型有:字符串、数字、布尔、对象、数组和文件描述符等,详细介绍请参见[@ohos.app.ability.Want(Want)](../apis-ability-kit/js-apis-app-ability-want.md)。
1159e41f4b71Sopenharmony_ci
1160e41f4b71Sopenharmony_ci**错误码:**
1161e41f4b71Sopenharmony_ci
1162e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
1163e41f4b71Sopenharmony_ci
1164e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
1165e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
1166e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Parameter verification failed. |
1167e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
1168e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
1169e41f4b71Sopenharmony_ci
1170e41f4b71Sopenharmony_ci**示例:**
1171e41f4b71Sopenharmony_ci
1172e41f4b71Sopenharmony_ci```ts
1173e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1174e41f4b71Sopenharmony_ci
1175e41f4b71Sopenharmony_cilet currentAVSession: avSession.AVSession | undefined = undefined;
1176e41f4b71Sopenharmony_cilet tag = "createNewSession";
1177e41f4b71Sopenharmony_cilet context: Context = getContext(this);
1178e41f4b71Sopenharmony_ci
1179e41f4b71Sopenharmony_ciavSession.createAVSession(context, tag, "audio", (err: BusinessError, data: avSession.AVSession) => {
1180e41f4b71Sopenharmony_ci  if (err) {
1181e41f4b71Sopenharmony_ci    console.error(`CreateAVSession BusinessError: code: ${err.code}, message: ${err.message}`);
1182e41f4b71Sopenharmony_ci  } else {
1183e41f4b71Sopenharmony_ci    currentAVSession = data;
1184e41f4b71Sopenharmony_ci  }
1185e41f4b71Sopenharmony_ci});
1186e41f4b71Sopenharmony_ciif (currentAVSession !== undefined) {
1187e41f4b71Sopenharmony_ci  (currentAVSession as avSession.AVSession).setExtras({extras : "This is custom media packet"}, (err: BusinessError) => {
1188e41f4b71Sopenharmony_ci    if (err) {
1189e41f4b71Sopenharmony_ci      console.error(`setExtras BusinessError: code: ${err.code}, message: ${err.message}`);
1190e41f4b71Sopenharmony_ci    }
1191e41f4b71Sopenharmony_ci  })
1192e41f4b71Sopenharmony_ci}
1193e41f4b71Sopenharmony_ci```
1194e41f4b71Sopenharmony_ci
1195e41f4b71Sopenharmony_ci### getController<sup>10+</sup>
1196e41f4b71Sopenharmony_ci
1197e41f4b71Sopenharmony_cigetController(): Promise\<AVSessionController>
1198e41f4b71Sopenharmony_ci
1199e41f4b71Sopenharmony_ci获取本会话对应的控制器。结果通过Promise异步回调方式返回。
1200e41f4b71Sopenharmony_ci
1201e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
1202e41f4b71Sopenharmony_ci
1203e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
1204e41f4b71Sopenharmony_ci
1205e41f4b71Sopenharmony_ci**返回值:**
1206e41f4b71Sopenharmony_ci
1207e41f4b71Sopenharmony_ci| 类型                                                 | 说明                          |
1208e41f4b71Sopenharmony_ci| ---------------------------------------------------- | ----------------------------- |
1209e41f4b71Sopenharmony_ci| Promise<[AVSessionController](#avsessioncontroller10)> | Promise对象。返回会话控制器。 |
1210e41f4b71Sopenharmony_ci
1211e41f4b71Sopenharmony_ci**错误码:**
1212e41f4b71Sopenharmony_ci
1213e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
1214e41f4b71Sopenharmony_ci
1215e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
1216e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
1217e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
1218e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
1219e41f4b71Sopenharmony_ci
1220e41f4b71Sopenharmony_ci**示例:**
1221e41f4b71Sopenharmony_ci
1222e41f4b71Sopenharmony_ci```ts
1223e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1224e41f4b71Sopenharmony_ci
1225e41f4b71Sopenharmony_cilet avsessionController: avSession.AVSessionController;
1226e41f4b71Sopenharmony_cicurrentAVSession.getController().then((avcontroller: avSession.AVSessionController) => {
1227e41f4b71Sopenharmony_ci  avsessionController = avcontroller;
1228e41f4b71Sopenharmony_ci  console.info(`GetController : SUCCESS : sessionid : ${avsessionController.sessionId}`);
1229e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
1230e41f4b71Sopenharmony_ci  console.error(`GetController BusinessError: code: ${err.code}, message: ${err.message}`);
1231e41f4b71Sopenharmony_ci});
1232e41f4b71Sopenharmony_ci```
1233e41f4b71Sopenharmony_ci
1234e41f4b71Sopenharmony_ci### getController<sup>10+</sup>
1235e41f4b71Sopenharmony_ci
1236e41f4b71Sopenharmony_cigetController(callback: AsyncCallback\<AVSessionController>): void
1237e41f4b71Sopenharmony_ci
1238e41f4b71Sopenharmony_ci获取本会话相应的控制器。结果通过callback异步回调方式返回。
1239e41f4b71Sopenharmony_ci
1240e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
1241e41f4b71Sopenharmony_ci
1242e41f4b71Sopenharmony_ci**参数:**
1243e41f4b71Sopenharmony_ci
1244e41f4b71Sopenharmony_ci| 参数名   | 类型                                                        | 必填 | 说明                       |
1245e41f4b71Sopenharmony_ci| -------- | ----------------------------------------------------------- | ---- | -------------------------- |
1246e41f4b71Sopenharmony_ci| callback | AsyncCallback<[AVSessionController](#avsessioncontroller10)\> | 是   | 回调函数。返回会话控制器。 |
1247e41f4b71Sopenharmony_ci
1248e41f4b71Sopenharmony_ci**错误码:**
1249e41f4b71Sopenharmony_ci
1250e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
1251e41f4b71Sopenharmony_ci
1252e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
1253e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
1254e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
1255e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
1256e41f4b71Sopenharmony_ci
1257e41f4b71Sopenharmony_ci**示例:**
1258e41f4b71Sopenharmony_ci
1259e41f4b71Sopenharmony_ci```ts
1260e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1261e41f4b71Sopenharmony_ci
1262e41f4b71Sopenharmony_cilet avsessionController: avSession.AVSessionController;
1263e41f4b71Sopenharmony_cicurrentAVSession.getController((err: BusinessError, avcontroller: avSession.AVSessionController) => {
1264e41f4b71Sopenharmony_ci  if (err) {
1265e41f4b71Sopenharmony_ci    console.error(`GetController BusinessError: code: ${err.code}, message: ${err.message}`);
1266e41f4b71Sopenharmony_ci  } else {
1267e41f4b71Sopenharmony_ci    avsessionController = avcontroller;
1268e41f4b71Sopenharmony_ci    console.info(`GetController : SUCCESS : sessionid : ${avsessionController.sessionId}`);
1269e41f4b71Sopenharmony_ci  }
1270e41f4b71Sopenharmony_ci});
1271e41f4b71Sopenharmony_ci```
1272e41f4b71Sopenharmony_ci
1273e41f4b71Sopenharmony_ci### getAVCastController<sup>10+</sup>
1274e41f4b71Sopenharmony_ci
1275e41f4b71Sopenharmony_cigetAVCastController(): Promise\<AVCastController>
1276e41f4b71Sopenharmony_ci
1277e41f4b71Sopenharmony_ci设备建立连接后,获取投播控制器。结果通过Promise异步回调方式返回。如果 avsession 未处于投播状态,则控制器将返回 null。
1278e41f4b71Sopenharmony_ci
1279e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
1280e41f4b71Sopenharmony_ci
1281e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.AVCast
1282e41f4b71Sopenharmony_ci
1283e41f4b71Sopenharmony_ci**返回值:**
1284e41f4b71Sopenharmony_ci
1285e41f4b71Sopenharmony_ci| 类型                                                        | 说明                                                         |
1286e41f4b71Sopenharmony_ci| --------- | ------------------------------------------------------------ |
1287e41f4b71Sopenharmony_ci| Promise<[AVCastController](#avcastcontroller10)\>  | Promise对象。返回投播控制器实例。 |
1288e41f4b71Sopenharmony_ci
1289e41f4b71Sopenharmony_ci**错误码:**
1290e41f4b71Sopenharmony_ci
1291e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
1292e41f4b71Sopenharmony_ci
1293e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
1294e41f4b71Sopenharmony_ci| -------- | --------------------------------------- |
1295e41f4b71Sopenharmony_ci| 6600102| The session does not exist.           |
1296e41f4b71Sopenharmony_ci| 6600109| The remote connection is not established. |
1297e41f4b71Sopenharmony_ci
1298e41f4b71Sopenharmony_ci**示例:**
1299e41f4b71Sopenharmony_ci
1300e41f4b71Sopenharmony_ci```ts
1301e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1302e41f4b71Sopenharmony_ci
1303e41f4b71Sopenharmony_cilet aVCastController: avSession.AVCastController;
1304e41f4b71Sopenharmony_cicurrentAVSession.getAVCastController().then((avcontroller: avSession.AVCastController) => {
1305e41f4b71Sopenharmony_ci  aVCastController = avcontroller;
1306e41f4b71Sopenharmony_ci  console.info('getAVCastController : SUCCESS');
1307e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
1308e41f4b71Sopenharmony_ci  console.error(`getAVCastController BusinessError: code: ${err.code}, message: ${err.message}`);
1309e41f4b71Sopenharmony_ci});
1310e41f4b71Sopenharmony_ci```
1311e41f4b71Sopenharmony_ci
1312e41f4b71Sopenharmony_ci### getAVCastController<sup>10+</sup>
1313e41f4b71Sopenharmony_ci
1314e41f4b71Sopenharmony_cigetAVCastController(callback: AsyncCallback\<AVCastController>): void
1315e41f4b71Sopenharmony_ci
1316e41f4b71Sopenharmony_ci设备建立连接后,获取投播控制器。结果通过callback异步回调方式返回。如果 avsession 未处于投播状态,则控制器将返回 null。
1317e41f4b71Sopenharmony_ci
1318e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.AVCast
1319e41f4b71Sopenharmony_ci
1320e41f4b71Sopenharmony_ci**参数:**
1321e41f4b71Sopenharmony_ci
1322e41f4b71Sopenharmony_ci| 参数名    | 类型                                                        | 必填 | 说明                                                         |
1323e41f4b71Sopenharmony_ci| --------- | ----------------------------------------------------------- | ---- | ------------------------------------------------------------ |
1324e41f4b71Sopenharmony_ci| callback  | AsyncCallback<[AVCastController](#avcastcontroller10)\> | 是   | 回调函数,返回投播控制器实例。 |
1325e41f4b71Sopenharmony_ci
1326e41f4b71Sopenharmony_ci**错误码:**
1327e41f4b71Sopenharmony_ci
1328e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
1329e41f4b71Sopenharmony_ci
1330e41f4b71Sopenharmony_ci| 错误码ID | 错误信息                                  |
1331e41f4b71Sopenharmony_ci| -------- |---------------------------------------|
1332e41f4b71Sopenharmony_ci| 6600102| The session does not exist.           |
1333e41f4b71Sopenharmony_ci| 6600109| The remote connection is not established. |
1334e41f4b71Sopenharmony_ci
1335e41f4b71Sopenharmony_ci**示例:**
1336e41f4b71Sopenharmony_ci
1337e41f4b71Sopenharmony_ci```ts
1338e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1339e41f4b71Sopenharmony_ci
1340e41f4b71Sopenharmony_cilet aVCastController: avSession.AVCastController;
1341e41f4b71Sopenharmony_cicurrentAVSession.getAVCastController((err: BusinessError, avcontroller: avSession.AVCastController) => {
1342e41f4b71Sopenharmony_ci  if (err) {
1343e41f4b71Sopenharmony_ci    console.error(`getAVCastController BusinessError: code: ${err.code}, message: ${err.message}`);
1344e41f4b71Sopenharmony_ci  } else {
1345e41f4b71Sopenharmony_ci    aVCastController = avcontroller;
1346e41f4b71Sopenharmony_ci    console.info('getAVCastController : SUCCESS');
1347e41f4b71Sopenharmony_ci  }
1348e41f4b71Sopenharmony_ci});
1349e41f4b71Sopenharmony_ci```
1350e41f4b71Sopenharmony_ci
1351e41f4b71Sopenharmony_ci### getOutputDevice<sup>10+</sup>
1352e41f4b71Sopenharmony_ci
1353e41f4b71Sopenharmony_cigetOutputDevice(): Promise\<OutputDeviceInfo>
1354e41f4b71Sopenharmony_ci
1355e41f4b71Sopenharmony_ci通过会话获取播放设备信息。结果通过Promise异步回调方式返回。
1356e41f4b71Sopenharmony_ci
1357e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
1358e41f4b71Sopenharmony_ci
1359e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
1360e41f4b71Sopenharmony_ci
1361e41f4b71Sopenharmony_ci**返回值:**
1362e41f4b71Sopenharmony_ci
1363e41f4b71Sopenharmony_ci| 类型                                           | 说明                              |
1364e41f4b71Sopenharmony_ci| ---------------------------------------------- | --------------------------------- |
1365e41f4b71Sopenharmony_ci| Promise<[OutputDeviceInfo](#outputdeviceinfo10)> | Promise对象。返回播放设备信息。 |
1366e41f4b71Sopenharmony_ci
1367e41f4b71Sopenharmony_ci**错误码:**
1368e41f4b71Sopenharmony_ci
1369e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
1370e41f4b71Sopenharmony_ci
1371e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
1372e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
1373e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
1374e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
1375e41f4b71Sopenharmony_ci
1376e41f4b71Sopenharmony_ci**示例:**
1377e41f4b71Sopenharmony_ci
1378e41f4b71Sopenharmony_ci```ts
1379e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1380e41f4b71Sopenharmony_ci
1381e41f4b71Sopenharmony_cicurrentAVSession.getOutputDevice().then((outputDeviceInfo: avSession.OutputDeviceInfo) => {
1382e41f4b71Sopenharmony_ci  console.info(`GetOutputDevice : SUCCESS : devices length : ${outputDeviceInfo.devices.length}`);
1383e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
1384e41f4b71Sopenharmony_ci  console.error(`GetOutputDevice BusinessError: code: ${err.code}, message: ${err.message}`);
1385e41f4b71Sopenharmony_ci})
1386e41f4b71Sopenharmony_ci```
1387e41f4b71Sopenharmony_ci
1388e41f4b71Sopenharmony_ci### getOutputDevice<sup>10+</sup>
1389e41f4b71Sopenharmony_ci
1390e41f4b71Sopenharmony_cigetOutputDevice(callback: AsyncCallback\<OutputDeviceInfo>): void
1391e41f4b71Sopenharmony_ci
1392e41f4b71Sopenharmony_ci通过会话获取播放设备相关信息。结果通过callback异步回调方式返回。
1393e41f4b71Sopenharmony_ci
1394e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
1395e41f4b71Sopenharmony_ci
1396e41f4b71Sopenharmony_ci**参数:**
1397e41f4b71Sopenharmony_ci
1398e41f4b71Sopenharmony_ci| 参数名   | 类型                                                  | 必填 | 说明                           |
1399e41f4b71Sopenharmony_ci| -------- | ----------------------------------------------------- | ---- | ------------------------------ |
1400e41f4b71Sopenharmony_ci| callback | AsyncCallback<[OutputDeviceInfo](#outputdeviceinfo10)\> | 是   | 回调函数,返回播放设备信息。 |
1401e41f4b71Sopenharmony_ci
1402e41f4b71Sopenharmony_ci**错误码:**
1403e41f4b71Sopenharmony_ci
1404e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
1405e41f4b71Sopenharmony_ci
1406e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
1407e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
1408e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
1409e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
1410e41f4b71Sopenharmony_ci
1411e41f4b71Sopenharmony_ci**示例:**
1412e41f4b71Sopenharmony_ci
1413e41f4b71Sopenharmony_ci```ts
1414e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1415e41f4b71Sopenharmony_ci
1416e41f4b71Sopenharmony_cicurrentAVSession.getOutputDevice((err: BusinessError, outputDeviceInfo: avSession.OutputDeviceInfo) => {
1417e41f4b71Sopenharmony_ci  if (err) {
1418e41f4b71Sopenharmony_ci    console.error(`GetOutputDevice BusinessError: code: ${err.code}, message: ${err.message}`);
1419e41f4b71Sopenharmony_ci  } else {
1420e41f4b71Sopenharmony_ci    console.info(`GetOutputDevice : SUCCESS : devices length : ${outputDeviceInfo.devices.length}`);
1421e41f4b71Sopenharmony_ci  }
1422e41f4b71Sopenharmony_ci});
1423e41f4b71Sopenharmony_ci```
1424e41f4b71Sopenharmony_ci
1425e41f4b71Sopenharmony_ci### activate<sup>10+</sup>
1426e41f4b71Sopenharmony_ci
1427e41f4b71Sopenharmony_ciactivate(): Promise\<void>
1428e41f4b71Sopenharmony_ci
1429e41f4b71Sopenharmony_ci激活会话,激活后可正常使用会话。结果通过Promise异步回调方式返回。
1430e41f4b71Sopenharmony_ci
1431e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
1432e41f4b71Sopenharmony_ci
1433e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
1434e41f4b71Sopenharmony_ci
1435e41f4b71Sopenharmony_ci**返回值:**
1436e41f4b71Sopenharmony_ci
1437e41f4b71Sopenharmony_ci| 类型           | 说明                          |
1438e41f4b71Sopenharmony_ci| -------------- | ----------------------------- |
1439e41f4b71Sopenharmony_ci| Promise\<void> | Promise对象。当会话激活成功,无返回结果,否则返回错误对象。 |
1440e41f4b71Sopenharmony_ci
1441e41f4b71Sopenharmony_ci**错误码:**
1442e41f4b71Sopenharmony_ci
1443e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
1444e41f4b71Sopenharmony_ci
1445e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
1446e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
1447e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
1448e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
1449e41f4b71Sopenharmony_ci
1450e41f4b71Sopenharmony_ci**示例:**
1451e41f4b71Sopenharmony_ci
1452e41f4b71Sopenharmony_ci```ts
1453e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1454e41f4b71Sopenharmony_ci
1455e41f4b71Sopenharmony_cicurrentAVSession.activate().then(() => {
1456e41f4b71Sopenharmony_ci  console.info('Activate : SUCCESS ');
1457e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
1458e41f4b71Sopenharmony_ci  console.error(`Activate BusinessError: code: ${err.code}, message: ${err.message}`);
1459e41f4b71Sopenharmony_ci});
1460e41f4b71Sopenharmony_ci```
1461e41f4b71Sopenharmony_ci
1462e41f4b71Sopenharmony_ci### activate<sup>10+</sup>
1463e41f4b71Sopenharmony_ci
1464e41f4b71Sopenharmony_ciactivate(callback: AsyncCallback\<void>): void
1465e41f4b71Sopenharmony_ci
1466e41f4b71Sopenharmony_ci激活会话,激活后可正常使用会话。结果通过callback异步回调方式返回。
1467e41f4b71Sopenharmony_ci
1468e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
1469e41f4b71Sopenharmony_ci
1470e41f4b71Sopenharmony_ci**参数:**
1471e41f4b71Sopenharmony_ci
1472e41f4b71Sopenharmony_ci| 参数名   | 类型                 | 必填 | 说明       |
1473e41f4b71Sopenharmony_ci| -------- | -------------------- | ---- | ---------- |
1474e41f4b71Sopenharmony_ci| callback | AsyncCallback\<void> | 是   | 回调函数。当会话激活成功,err为undefined,否则返回错误对象。 |
1475e41f4b71Sopenharmony_ci
1476e41f4b71Sopenharmony_ci**错误码:**
1477e41f4b71Sopenharmony_ci
1478e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
1479e41f4b71Sopenharmony_ci
1480e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
1481e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
1482e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
1483e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
1484e41f4b71Sopenharmony_ci
1485e41f4b71Sopenharmony_ci**示例:**
1486e41f4b71Sopenharmony_ci
1487e41f4b71Sopenharmony_ci```ts
1488e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1489e41f4b71Sopenharmony_ci
1490e41f4b71Sopenharmony_cicurrentAVSession.activate((err: BusinessError) => {
1491e41f4b71Sopenharmony_ci  if (err) {
1492e41f4b71Sopenharmony_ci    console.error(`Activate BusinessError: code: ${err.code}, message: ${err.message}`);
1493e41f4b71Sopenharmony_ci  } else {
1494e41f4b71Sopenharmony_ci    console.info('Activate : SUCCESS ');
1495e41f4b71Sopenharmony_ci  }
1496e41f4b71Sopenharmony_ci});
1497e41f4b71Sopenharmony_ci```
1498e41f4b71Sopenharmony_ci
1499e41f4b71Sopenharmony_ci### deactivate<sup>10+</sup>
1500e41f4b71Sopenharmony_ci
1501e41f4b71Sopenharmony_cideactivate(): Promise\<void>
1502e41f4b71Sopenharmony_ci
1503e41f4b71Sopenharmony_ci禁用当前会话的功能,可通过[activate](#activate10)恢复。结果通过Promise异步回调方式返回。
1504e41f4b71Sopenharmony_ci
1505e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
1506e41f4b71Sopenharmony_ci
1507e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
1508e41f4b71Sopenharmony_ci
1509e41f4b71Sopenharmony_ci**返回值:**
1510e41f4b71Sopenharmony_ci
1511e41f4b71Sopenharmony_ci| 类型           | 说明                          |
1512e41f4b71Sopenharmony_ci| -------------- | ----------------------------- |
1513e41f4b71Sopenharmony_ci| Promise\<void> | Promise对象。当禁用会话成功,无返回结果,否则返回错误对象。|
1514e41f4b71Sopenharmony_ci
1515e41f4b71Sopenharmony_ci**错误码:**
1516e41f4b71Sopenharmony_ci
1517e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
1518e41f4b71Sopenharmony_ci
1519e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
1520e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
1521e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
1522e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
1523e41f4b71Sopenharmony_ci
1524e41f4b71Sopenharmony_ci**示例:**
1525e41f4b71Sopenharmony_ci
1526e41f4b71Sopenharmony_ci```ts
1527e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1528e41f4b71Sopenharmony_ci
1529e41f4b71Sopenharmony_cicurrentAVSession.deactivate().then(() => {
1530e41f4b71Sopenharmony_ci  console.info('Deactivate : SUCCESS ');
1531e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
1532e41f4b71Sopenharmony_ci  console.error(`Deactivate BusinessError: code: ${err.code}, message: ${err.message}`);
1533e41f4b71Sopenharmony_ci});
1534e41f4b71Sopenharmony_ci```
1535e41f4b71Sopenharmony_ci
1536e41f4b71Sopenharmony_ci### deactivate<sup>10+</sup>
1537e41f4b71Sopenharmony_ci
1538e41f4b71Sopenharmony_cideactivate(callback: AsyncCallback\<void>): void
1539e41f4b71Sopenharmony_ci
1540e41f4b71Sopenharmony_ci禁用当前会话。结果通过callback异步回调方式返回。
1541e41f4b71Sopenharmony_ci
1542e41f4b71Sopenharmony_ci禁用当前会话的功能,可通过[activate](#activate10)恢复。
1543e41f4b71Sopenharmony_ci
1544e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
1545e41f4b71Sopenharmony_ci
1546e41f4b71Sopenharmony_ci**参数:**
1547e41f4b71Sopenharmony_ci
1548e41f4b71Sopenharmony_ci| 参数名   | 类型                 | 必填 | 说明       |
1549e41f4b71Sopenharmony_ci| -------- | -------------------- | ---- | ---------- |
1550e41f4b71Sopenharmony_ci| callback | AsyncCallback\<void> | 是   | 回调函数。当禁用会话成功,err为undefined,否则返回错误对象。|
1551e41f4b71Sopenharmony_ci
1552e41f4b71Sopenharmony_ci**错误码:**
1553e41f4b71Sopenharmony_ci
1554e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
1555e41f4b71Sopenharmony_ci
1556e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
1557e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
1558e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
1559e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
1560e41f4b71Sopenharmony_ci
1561e41f4b71Sopenharmony_ci**示例:**
1562e41f4b71Sopenharmony_ci
1563e41f4b71Sopenharmony_ci```ts
1564e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1565e41f4b71Sopenharmony_ci
1566e41f4b71Sopenharmony_cicurrentAVSession.deactivate((err: BusinessError) => {
1567e41f4b71Sopenharmony_ci  if (err) {
1568e41f4b71Sopenharmony_ci    console.error(`Deactivate BusinessError: code: ${err.code}, message: ${err.message}`);
1569e41f4b71Sopenharmony_ci  } else {
1570e41f4b71Sopenharmony_ci    console.info('Deactivate : SUCCESS ');
1571e41f4b71Sopenharmony_ci  }
1572e41f4b71Sopenharmony_ci});
1573e41f4b71Sopenharmony_ci```
1574e41f4b71Sopenharmony_ci
1575e41f4b71Sopenharmony_ci### destroy<sup>10+</sup>
1576e41f4b71Sopenharmony_ci
1577e41f4b71Sopenharmony_cidestroy(): Promise\<void>
1578e41f4b71Sopenharmony_ci
1579e41f4b71Sopenharmony_ci销毁当前会话,使当前会话完全失效。结果通过Promise异步回调方式返回。
1580e41f4b71Sopenharmony_ci
1581e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
1582e41f4b71Sopenharmony_ci
1583e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
1584e41f4b71Sopenharmony_ci
1585e41f4b71Sopenharmony_ci**返回值:**
1586e41f4b71Sopenharmony_ci
1587e41f4b71Sopenharmony_ci| 类型           | 说明                          |
1588e41f4b71Sopenharmony_ci| -------------- | ----------------------------- |
1589e41f4b71Sopenharmony_ci| Promise\<void> | Promise对象。当会话销毁成功,无返回结果,否则返回错误对象。 |
1590e41f4b71Sopenharmony_ci
1591e41f4b71Sopenharmony_ci**错误码:**
1592e41f4b71Sopenharmony_ci
1593e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
1594e41f4b71Sopenharmony_ci
1595e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
1596e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
1597e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
1598e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
1599e41f4b71Sopenharmony_ci
1600e41f4b71Sopenharmony_ci**示例:**
1601e41f4b71Sopenharmony_ci
1602e41f4b71Sopenharmony_ci```ts
1603e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1604e41f4b71Sopenharmony_ci
1605e41f4b71Sopenharmony_cicurrentAVSession.destroy().then(() => {
1606e41f4b71Sopenharmony_ci  console.info('Destroy : SUCCESS ');
1607e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
1608e41f4b71Sopenharmony_ci  console.error(`Destroy BusinessError: code: ${err.code}, message: ${err.message}`);
1609e41f4b71Sopenharmony_ci});
1610e41f4b71Sopenharmony_ci```
1611e41f4b71Sopenharmony_ci
1612e41f4b71Sopenharmony_ci### destroy<sup>10+</sup>
1613e41f4b71Sopenharmony_ci
1614e41f4b71Sopenharmony_cidestroy(callback: AsyncCallback\<void>): void
1615e41f4b71Sopenharmony_ci
1616e41f4b71Sopenharmony_ci销毁当前会话,使当前会话完全失效。结果通过callback异步回调方式返回。
1617e41f4b71Sopenharmony_ci
1618e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
1619e41f4b71Sopenharmony_ci
1620e41f4b71Sopenharmony_ci**参数:**
1621e41f4b71Sopenharmony_ci
1622e41f4b71Sopenharmony_ci| 参数名   | 类型                 | 必填 | 说明       |
1623e41f4b71Sopenharmony_ci| -------- | -------------------- | ---- | ---------- |
1624e41f4b71Sopenharmony_ci| callback | AsyncCallback\<void> | 是   | 回调函数。当会话销毁成功,err为undefined,否则返回错误对象。 |
1625e41f4b71Sopenharmony_ci
1626e41f4b71Sopenharmony_ci**错误码:**
1627e41f4b71Sopenharmony_ci
1628e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
1629e41f4b71Sopenharmony_ci
1630e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
1631e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
1632e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
1633e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
1634e41f4b71Sopenharmony_ci
1635e41f4b71Sopenharmony_ci**示例:**
1636e41f4b71Sopenharmony_ci
1637e41f4b71Sopenharmony_ci```ts
1638e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1639e41f4b71Sopenharmony_ci
1640e41f4b71Sopenharmony_cicurrentAVSession.destroy((err: BusinessError) => {
1641e41f4b71Sopenharmony_ci  if (err) {
1642e41f4b71Sopenharmony_ci    console.error(`Destroy BusinessError: code: ${err.code}, message: ${err.message}`);
1643e41f4b71Sopenharmony_ci  } else {
1644e41f4b71Sopenharmony_ci    console.info('Destroy : SUCCESS ');
1645e41f4b71Sopenharmony_ci  }
1646e41f4b71Sopenharmony_ci});
1647e41f4b71Sopenharmony_ci```
1648e41f4b71Sopenharmony_ci
1649e41f4b71Sopenharmony_ci### on('play')<sup>10+</sup>
1650e41f4b71Sopenharmony_ci
1651e41f4b71Sopenharmony_cion(type: 'play', callback: () => void): void
1652e41f4b71Sopenharmony_ci
1653e41f4b71Sopenharmony_ci设置播放命令监听事件。注册该监听,说明应用支持播放指令。
1654e41f4b71Sopenharmony_ci
1655e41f4b71Sopenharmony_ci每个播放命令仅支持注册一个回调,如果注册新的回调,将替换前一个回调。
1656e41f4b71Sopenharmony_ci
1657e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
1658e41f4b71Sopenharmony_ci
1659e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
1660e41f4b71Sopenharmony_ci
1661e41f4b71Sopenharmony_ci**参数:**
1662e41f4b71Sopenharmony_ci
1663e41f4b71Sopenharmony_ci| 参数名   | 类型                 | 必填 | 说明                                                         |
1664e41f4b71Sopenharmony_ci| -------- | -------------------- | ---- | ------------------------------------------------------------ |
1665e41f4b71Sopenharmony_ci| type     | string               | 是   | 事件回调类型,支持的事件为`'play'`当播放命令被发送到会话时,触发该事件回调。 |
1666e41f4b71Sopenharmony_ci| callback | () => void | 是   | 回调函数。当监听事件注册成功,err为undefined,否则为错误对象。                                        |
1667e41f4b71Sopenharmony_ci
1668e41f4b71Sopenharmony_ci**错误码:**
1669e41f4b71Sopenharmony_ci
1670e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
1671e41f4b71Sopenharmony_ci
1672e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
1673e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
1674e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
1675e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
1676e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
1677e41f4b71Sopenharmony_ci
1678e41f4b71Sopenharmony_ci**示例:**
1679e41f4b71Sopenharmony_ci
1680e41f4b71Sopenharmony_ci```ts
1681e41f4b71Sopenharmony_cicurrentAVSession.on('play', () => {
1682e41f4b71Sopenharmony_ci  console.info('on play entry');
1683e41f4b71Sopenharmony_ci});
1684e41f4b71Sopenharmony_ci```
1685e41f4b71Sopenharmony_ci
1686e41f4b71Sopenharmony_ci### on('pause')<sup>10+</sup>
1687e41f4b71Sopenharmony_ci
1688e41f4b71Sopenharmony_cion(type: 'pause', callback: () => void): void
1689e41f4b71Sopenharmony_ci
1690e41f4b71Sopenharmony_ci设置暂停命令监听事件。注册该监听,说明应用支持暂停指令。
1691e41f4b71Sopenharmony_ci
1692e41f4b71Sopenharmony_ci每个播放命令仅支持注册一个回调,如果注册新的回调,将替换前一个回调。
1693e41f4b71Sopenharmony_ci
1694e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
1695e41f4b71Sopenharmony_ci
1696e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
1697e41f4b71Sopenharmony_ci
1698e41f4b71Sopenharmony_ci**参数:**
1699e41f4b71Sopenharmony_ci
1700e41f4b71Sopenharmony_ci| 参数名   | 类型                 | 必填 | 说明                                                         |
1701e41f4b71Sopenharmony_ci| -------- | -------------------- | ---- | ------------------------------------------------------------ |
1702e41f4b71Sopenharmony_ci| type     | string               | 是   | 事件回调类型,支持的事件为`'pause'`,当暂停命令被发送到会话时,触发该事件回调。 |
1703e41f4b71Sopenharmony_ci| callback | () => void | 是   | 回调函数。当监听事件注册成功,err为undefined,否则为错误对象。     |
1704e41f4b71Sopenharmony_ci
1705e41f4b71Sopenharmony_ci**错误码:**
1706e41f4b71Sopenharmony_ci
1707e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
1708e41f4b71Sopenharmony_ci
1709e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
1710e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
1711e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
1712e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
1713e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
1714e41f4b71Sopenharmony_ci
1715e41f4b71Sopenharmony_ci**示例:**
1716e41f4b71Sopenharmony_ci
1717e41f4b71Sopenharmony_ci```ts
1718e41f4b71Sopenharmony_cicurrentAVSession.on('pause', () => {
1719e41f4b71Sopenharmony_ci  console.info('on pause entry');
1720e41f4b71Sopenharmony_ci});
1721e41f4b71Sopenharmony_ci```
1722e41f4b71Sopenharmony_ci
1723e41f4b71Sopenharmony_ci### on('stop')<sup>10+</sup>
1724e41f4b71Sopenharmony_ci
1725e41f4b71Sopenharmony_cion(type:'stop', callback: () => void): void
1726e41f4b71Sopenharmony_ci
1727e41f4b71Sopenharmony_ci设置停止命令监听事件。注册该监听,说明应用支持停止指令。
1728e41f4b71Sopenharmony_ci
1729e41f4b71Sopenharmony_ci每个播放命令仅支持注册一个回调,如果注册新的回调,将替换前一个回调。
1730e41f4b71Sopenharmony_ci
1731e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
1732e41f4b71Sopenharmony_ci
1733e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
1734e41f4b71Sopenharmony_ci
1735e41f4b71Sopenharmony_ci**参数:**
1736e41f4b71Sopenharmony_ci
1737e41f4b71Sopenharmony_ci| 参数名   | 类型                 | 必填 | 说明                                                         |
1738e41f4b71Sopenharmony_ci| -------- | -------------------- | ---- | ------------------------------------------------------------ |
1739e41f4b71Sopenharmony_ci| type     | string               | 是   | 事件回调类型,支持的事件是`'stop'`,当停止命令被发送到会话时,触发该事件回调。 |
1740e41f4b71Sopenharmony_ci| callback | () => void | 是   | 回调函数。当监听事件注册成功,err为undefined,否则为错误对象。          |
1741e41f4b71Sopenharmony_ci
1742e41f4b71Sopenharmony_ci**错误码:**
1743e41f4b71Sopenharmony_ci
1744e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
1745e41f4b71Sopenharmony_ci
1746e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
1747e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
1748e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
1749e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
1750e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
1751e41f4b71Sopenharmony_ci
1752e41f4b71Sopenharmony_ci**示例:**
1753e41f4b71Sopenharmony_ci
1754e41f4b71Sopenharmony_ci```ts
1755e41f4b71Sopenharmony_cicurrentAVSession.on('stop', () => {
1756e41f4b71Sopenharmony_ci  console.info('on stop entry');
1757e41f4b71Sopenharmony_ci});
1758e41f4b71Sopenharmony_ci```
1759e41f4b71Sopenharmony_ci
1760e41f4b71Sopenharmony_ci### on('playNext')<sup>10+</sup>
1761e41f4b71Sopenharmony_ci
1762e41f4b71Sopenharmony_cion(type:'playNext', callback: () => void): void
1763e41f4b71Sopenharmony_ci
1764e41f4b71Sopenharmony_ci设置播放下一首命令监听事件。注册该监听,说明应用支持下一首指令。
1765e41f4b71Sopenharmony_ci
1766e41f4b71Sopenharmony_ci每个播放命令仅支持注册一个回调,如果注册新的回调,将替换前一个回调。
1767e41f4b71Sopenharmony_ci
1768e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
1769e41f4b71Sopenharmony_ci
1770e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
1771e41f4b71Sopenharmony_ci
1772e41f4b71Sopenharmony_ci**参数:**
1773e41f4b71Sopenharmony_ci
1774e41f4b71Sopenharmony_ci| 参数名   | 类型                 | 必填 | 说明                                                         |
1775e41f4b71Sopenharmony_ci| -------- | -------------------- | ---- | ------------------------------------------------------------ |
1776e41f4b71Sopenharmony_ci| type     | string               | 是   | 事件回调类型,支持的事件是`'playNext'`,当播放下一首命令被发送到会话时,触发该事件回调。 |
1777e41f4b71Sopenharmony_ci| callback | () => void | 是   | 回调函数。当监听事件注册成功,err为undefined,否则为错误对象。     |
1778e41f4b71Sopenharmony_ci
1779e41f4b71Sopenharmony_ci**错误码:**
1780e41f4b71Sopenharmony_ci
1781e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
1782e41f4b71Sopenharmony_ci
1783e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
1784e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
1785e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
1786e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
1787e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
1788e41f4b71Sopenharmony_ci
1789e41f4b71Sopenharmony_ci**示例:**
1790e41f4b71Sopenharmony_ci
1791e41f4b71Sopenharmony_ci```ts
1792e41f4b71Sopenharmony_cicurrentAVSession.on('playNext', () => {
1793e41f4b71Sopenharmony_ci  console.info('on playNext entry');
1794e41f4b71Sopenharmony_ci});
1795e41f4b71Sopenharmony_ci```
1796e41f4b71Sopenharmony_ci
1797e41f4b71Sopenharmony_ci### on('playPrevious')<sup>10+</sup>
1798e41f4b71Sopenharmony_ci
1799e41f4b71Sopenharmony_cion(type:'playPrevious', callback: () => void): void
1800e41f4b71Sopenharmony_ci
1801e41f4b71Sopenharmony_ci设置播放上一首命令监听事件。注册该监听,说明应用支持上一首指令。
1802e41f4b71Sopenharmony_ci
1803e41f4b71Sopenharmony_ci每个播放命令仅支持注册一个回调,如果注册新的回调,将替换前一个回调。
1804e41f4b71Sopenharmony_ci
1805e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
1806e41f4b71Sopenharmony_ci
1807e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
1808e41f4b71Sopenharmony_ci
1809e41f4b71Sopenharmony_ci**参数:**
1810e41f4b71Sopenharmony_ci
1811e41f4b71Sopenharmony_ci| 参数名   | 类型                 | 必填 | 说明                                                         |
1812e41f4b71Sopenharmony_ci| -------- | -------------------- | ---- | ------------------------------------------------------------ |
1813e41f4b71Sopenharmony_ci| type     | string               | 是   | 事件回调类型,支持的事件是`'playPrevious'`当播放上一首命令被发送到会话时,触发该事件回调。 |
1814e41f4b71Sopenharmony_ci| callback | () => void | 是   | 回调函数。当监听事件注册成功,err为undefined,否则为错误对象。       |
1815e41f4b71Sopenharmony_ci
1816e41f4b71Sopenharmony_ci**错误码:**
1817e41f4b71Sopenharmony_ci
1818e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
1819e41f4b71Sopenharmony_ci
1820e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
1821e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
1822e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
1823e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
1824e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
1825e41f4b71Sopenharmony_ci
1826e41f4b71Sopenharmony_ci**示例:**
1827e41f4b71Sopenharmony_ci
1828e41f4b71Sopenharmony_ci```ts
1829e41f4b71Sopenharmony_cicurrentAVSession.on('playPrevious', () => {
1830e41f4b71Sopenharmony_ci  console.info('on playPrevious entry');
1831e41f4b71Sopenharmony_ci});
1832e41f4b71Sopenharmony_ci```
1833e41f4b71Sopenharmony_ci
1834e41f4b71Sopenharmony_ci### on('fastForward')<sup>10+</sup>
1835e41f4b71Sopenharmony_ci
1836e41f4b71Sopenharmony_cion(type: 'fastForward', callback: (time?: number) => void): void
1837e41f4b71Sopenharmony_ci
1838e41f4b71Sopenharmony_ci设置快进命令监听事件。注册该监听,说明应用支持快进指令。
1839e41f4b71Sopenharmony_ci
1840e41f4b71Sopenharmony_ci每个播放命令仅支持注册一个回调,如果注册新的回调,将替换前一个回调。
1841e41f4b71Sopenharmony_ci
1842e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
1843e41f4b71Sopenharmony_ci
1844e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
1845e41f4b71Sopenharmony_ci
1846e41f4b71Sopenharmony_ci**参数:**
1847e41f4b71Sopenharmony_ci
1848e41f4b71Sopenharmony_ci| 参数名   | 类型                 | 必填 | 说明                                                         |
1849e41f4b71Sopenharmony_ci| -------- | -------------------- | ---- | ------------------------------------------------------------ |
1850e41f4b71Sopenharmony_ci| type     | string               | 是   | 事件回调类型,支持的事件是 `'fastForward'`,当快进命令被发送到会话时,触发该事件回调。 |
1851e41f4b71Sopenharmony_ci| callback | (time?: number) => void | 是   | 回调函数。参数time是时间节点,单位为秒。    |
1852e41f4b71Sopenharmony_ci
1853e41f4b71Sopenharmony_ci**错误码:**
1854e41f4b71Sopenharmony_ci
1855e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
1856e41f4b71Sopenharmony_ci
1857e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
1858e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
1859e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
1860e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
1861e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
1862e41f4b71Sopenharmony_ci
1863e41f4b71Sopenharmony_ci**示例:**
1864e41f4b71Sopenharmony_ci
1865e41f4b71Sopenharmony_ci```ts
1866e41f4b71Sopenharmony_cicurrentAVSession.on('fastForward', (time?: number) => {
1867e41f4b71Sopenharmony_ci  console.info('on fastForward entry');
1868e41f4b71Sopenharmony_ci});
1869e41f4b71Sopenharmony_ci```
1870e41f4b71Sopenharmony_ci
1871e41f4b71Sopenharmony_ci### on('rewind')<sup>10+</sup>
1872e41f4b71Sopenharmony_ci
1873e41f4b71Sopenharmony_cion(type:'rewind', callback: (time?: number) => void): void
1874e41f4b71Sopenharmony_ci
1875e41f4b71Sopenharmony_ci设置快退命令监听事件。
1876e41f4b71Sopenharmony_ci
1877e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
1878e41f4b71Sopenharmony_ci
1879e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
1880e41f4b71Sopenharmony_ci
1881e41f4b71Sopenharmony_ci**参数:**
1882e41f4b71Sopenharmony_ci
1883e41f4b71Sopenharmony_ci| 参数名   | 类型                 | 必填 | 说明                                                         |
1884e41f4b71Sopenharmony_ci| -------- | -------------------- | ---- | ------------------------------------------------------------ |
1885e41f4b71Sopenharmony_ci| type     | string               | 是   | 事件回调类型,支持的事件是`'rewind'`,当快退命令被发送到会话时,触发该事件回调。 |
1886e41f4b71Sopenharmony_ci| callback | (time?: number) => void | 是   | 回调函数。参数time是时间节点,单位为秒。      |
1887e41f4b71Sopenharmony_ci
1888e41f4b71Sopenharmony_ci**错误码:**
1889e41f4b71Sopenharmony_ci
1890e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
1891e41f4b71Sopenharmony_ci
1892e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
1893e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
1894e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
1895e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
1896e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
1897e41f4b71Sopenharmony_ci
1898e41f4b71Sopenharmony_ci**示例:**
1899e41f4b71Sopenharmony_ci
1900e41f4b71Sopenharmony_ci```ts
1901e41f4b71Sopenharmony_cicurrentAVSession.on('rewind', (time?: number) => {
1902e41f4b71Sopenharmony_ci  console.info('on rewind entry');
1903e41f4b71Sopenharmony_ci});
1904e41f4b71Sopenharmony_ci```
1905e41f4b71Sopenharmony_ci
1906e41f4b71Sopenharmony_ci### on('playFromAssetId')<sup>11+</sup>
1907e41f4b71Sopenharmony_ci
1908e41f4b71Sopenharmony_cion(type:'playFromAssetId', callback: (assetId: number) => void): void
1909e41f4b71Sopenharmony_ci
1910e41f4b71Sopenharmony_ci设置媒体id播放监听事件。
1911e41f4b71Sopenharmony_ci
1912e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
1913e41f4b71Sopenharmony_ci
1914e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
1915e41f4b71Sopenharmony_ci
1916e41f4b71Sopenharmony_ci**参数:**
1917e41f4b71Sopenharmony_ci
1918e41f4b71Sopenharmony_ci| 参数名   | 类型                 | 必填 | 说明                                                         |
1919e41f4b71Sopenharmony_ci| -------- | -------------------- | ---- | ------------------------------------------------------------ |
1920e41f4b71Sopenharmony_ci| type     | string               | 是   | 事件回调类型,支持的事件是`'playFromAssetId'`,当媒体id播放时,触发该事件回调。 |
1921e41f4b71Sopenharmony_ci| callback | callback: (assetId: number) => void | 是   | 回调函数。参数assetId是媒体id。      |
1922e41f4b71Sopenharmony_ci
1923e41f4b71Sopenharmony_ci**错误码:**
1924e41f4b71Sopenharmony_ci
1925e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
1926e41f4b71Sopenharmony_ci
1927e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
1928e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
1929e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
1930e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
1931e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
1932e41f4b71Sopenharmony_ci
1933e41f4b71Sopenharmony_ci**示例:**
1934e41f4b71Sopenharmony_ci
1935e41f4b71Sopenharmony_ci```ts
1936e41f4b71Sopenharmony_cicurrentAVSession.on('playFromAssetId', (assetId: number) => {
1937e41f4b71Sopenharmony_ci  console.info('on playFromAssetId entry');
1938e41f4b71Sopenharmony_ci});
1939e41f4b71Sopenharmony_ci```
1940e41f4b71Sopenharmony_ci
1941e41f4b71Sopenharmony_ci### off('playFromAssetId')<sup>11+</sup>
1942e41f4b71Sopenharmony_ci
1943e41f4b71Sopenharmony_cioff(type: 'playFromAssetId', callback?: (assetId: number) => void): void
1944e41f4b71Sopenharmony_ci
1945e41f4b71Sopenharmony_ci取消媒体id播放事件监听,关闭后,不再进行该事件回调。
1946e41f4b71Sopenharmony_ci
1947e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
1948e41f4b71Sopenharmony_ci
1949e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
1950e41f4b71Sopenharmony_ci
1951e41f4b71Sopenharmony_ci**参数:**
1952e41f4b71Sopenharmony_ci
1953e41f4b71Sopenharmony_ci| 参数名    | 类型                  | 必填 | 说明                                                                                                                         |
1954e41f4b71Sopenharmony_ci| -------- | -------------------- | ---- | ---------------------------------------------------------------------------------------------------------------------------- |
1955e41f4b71Sopenharmony_ci| type     | string               | 是   | 关闭对应的监听事件,支持的事件是`'playFromAssetId'`。 |
1956e41f4b71Sopenharmony_ci| callback | callback: (assetId: number) => void | 否   | 回调函数。当监听事件取消成功,err为undefined,否则返回错误对象。<br>该参数为可选参数,若不填写该参数,则认为取消所有相关会话的事件监听。参数assetId是媒体id。                            |
1957e41f4b71Sopenharmony_ci
1958e41f4b71Sopenharmony_ci**错误码:**
1959e41f4b71Sopenharmony_ci
1960e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
1961e41f4b71Sopenharmony_ci
1962e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
1963e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
1964e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
1965e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
1966e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
1967e41f4b71Sopenharmony_ci
1968e41f4b71Sopenharmony_ci**示例:**
1969e41f4b71Sopenharmony_ci
1970e41f4b71Sopenharmony_ci```ts
1971e41f4b71Sopenharmony_cicurrentAVSession.off('playFromAssetId');
1972e41f4b71Sopenharmony_ci```
1973e41f4b71Sopenharmony_ci
1974e41f4b71Sopenharmony_ci### on('seek')<sup>10+</sup>
1975e41f4b71Sopenharmony_ci
1976e41f4b71Sopenharmony_cion(type: 'seek', callback: (time: number) => void): void
1977e41f4b71Sopenharmony_ci
1978e41f4b71Sopenharmony_ci设置跳转节点监听事件。
1979e41f4b71Sopenharmony_ci
1980e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
1981e41f4b71Sopenharmony_ci
1982e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
1983e41f4b71Sopenharmony_ci
1984e41f4b71Sopenharmony_ci**参数:**
1985e41f4b71Sopenharmony_ci
1986e41f4b71Sopenharmony_ci| 参数名   | 类型                   | 必填 | 说明                                                         |
1987e41f4b71Sopenharmony_ci| -------- | ---------------------- | ---- | ------------------------------------------------------------ |
1988e41f4b71Sopenharmony_ci| type     | string                 | 是   | 事件回调类型,支持事件`'seek'`:当跳转节点命令被发送到会话时,触发该事件。 |
1989e41f4b71Sopenharmony_ci| callback | (time: number) => void | 是   | 回调函数。参数time是时间节点,单位为毫秒。                   |
1990e41f4b71Sopenharmony_ci
1991e41f4b71Sopenharmony_ci**错误码:**
1992e41f4b71Sopenharmony_ci
1993e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
1994e41f4b71Sopenharmony_ci
1995e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
1996e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
1997e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
1998e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
1999e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
2000e41f4b71Sopenharmony_ci
2001e41f4b71Sopenharmony_ci**示例:**
2002e41f4b71Sopenharmony_ci
2003e41f4b71Sopenharmony_ci```ts
2004e41f4b71Sopenharmony_cicurrentAVSession.on('seek', (time: number) => {
2005e41f4b71Sopenharmony_ci  console.info(`on seek entry time : ${time}`);
2006e41f4b71Sopenharmony_ci});
2007e41f4b71Sopenharmony_ci```
2008e41f4b71Sopenharmony_ci
2009e41f4b71Sopenharmony_ci### on('setSpeed')<sup>10+</sup>
2010e41f4b71Sopenharmony_ci
2011e41f4b71Sopenharmony_cion(type: 'setSpeed', callback: (speed: number) => void): void
2012e41f4b71Sopenharmony_ci
2013e41f4b71Sopenharmony_ci设置播放速率的监听事件。
2014e41f4b71Sopenharmony_ci
2015e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
2016e41f4b71Sopenharmony_ci
2017e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
2018e41f4b71Sopenharmony_ci
2019e41f4b71Sopenharmony_ci**参数:**
2020e41f4b71Sopenharmony_ci
2021e41f4b71Sopenharmony_ci| 参数名   | 类型                    | 必填 | 说明                                                         |
2022e41f4b71Sopenharmony_ci| -------- | ----------------------- | ---- | ------------------------------------------------------------ |
2023e41f4b71Sopenharmony_ci| type     | string                  | 是   | 事件回调类型,支持事件`'setSpeed'`:当设置播放速率的命令被发送到会话时,触发该事件。 |
2024e41f4b71Sopenharmony_ci| callback | (speed: number) => void | 是   | 回调函数。参数speed是播放倍速。                              |
2025e41f4b71Sopenharmony_ci
2026e41f4b71Sopenharmony_ci**错误码:**
2027e41f4b71Sopenharmony_ci
2028e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
2029e41f4b71Sopenharmony_ci
2030e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
2031e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
2032e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
2033e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
2034e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
2035e41f4b71Sopenharmony_ci
2036e41f4b71Sopenharmony_ci**示例:**
2037e41f4b71Sopenharmony_ci
2038e41f4b71Sopenharmony_ci```ts
2039e41f4b71Sopenharmony_cicurrentAVSession.on('setSpeed', (speed: number) => {
2040e41f4b71Sopenharmony_ci  console.info(`on setSpeed speed : ${speed}`);
2041e41f4b71Sopenharmony_ci});
2042e41f4b71Sopenharmony_ci```
2043e41f4b71Sopenharmony_ci
2044e41f4b71Sopenharmony_ci### on('setLoopMode')<sup>10+</sup>
2045e41f4b71Sopenharmony_ci
2046e41f4b71Sopenharmony_cion(type: 'setLoopMode', callback: (mode: LoopMode) => void): void
2047e41f4b71Sopenharmony_ci
2048e41f4b71Sopenharmony_ci设置循环模式的监听事件。
2049e41f4b71Sopenharmony_ci
2050e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
2051e41f4b71Sopenharmony_ci
2052e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
2053e41f4b71Sopenharmony_ci
2054e41f4b71Sopenharmony_ci**参数:**
2055e41f4b71Sopenharmony_ci
2056e41f4b71Sopenharmony_ci| 参数名    | 类型                                   | 必填 | 说明  |
2057e41f4b71Sopenharmony_ci| -------- | ------------------------------------- | ---- | ---- |
2058e41f4b71Sopenharmony_ci| type     | string                                | 是   | 事件回调类型,支持事件`'setLoopMode'`:当设置循环模式的命令被发送到会话时,触发该事件。 |
2059e41f4b71Sopenharmony_ci| callback | (mode: [LoopMode](#loopmode10)) => void | 是   | 回调函数。参数mode是循环模式。                               |
2060e41f4b71Sopenharmony_ci
2061e41f4b71Sopenharmony_ci**错误码:**
2062e41f4b71Sopenharmony_ci
2063e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
2064e41f4b71Sopenharmony_ci
2065e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
2066e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
2067e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
2068e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
2069e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
2070e41f4b71Sopenharmony_ci
2071e41f4b71Sopenharmony_ci**示例:**
2072e41f4b71Sopenharmony_ci
2073e41f4b71Sopenharmony_ci```ts
2074e41f4b71Sopenharmony_cicurrentAVSession.on('setLoopMode', (mode: avSession.LoopMode) => {
2075e41f4b71Sopenharmony_ci  console.info(`on setLoopMode mode : ${mode}`);
2076e41f4b71Sopenharmony_ci});
2077e41f4b71Sopenharmony_ci```
2078e41f4b71Sopenharmony_ci
2079e41f4b71Sopenharmony_ci### on('toggleFavorite')<sup>10+</sup>
2080e41f4b71Sopenharmony_ci
2081e41f4b71Sopenharmony_cion(type: 'toggleFavorite', callback: (assetId: string) => void): void
2082e41f4b71Sopenharmony_ci
2083e41f4b71Sopenharmony_ci设置是否收藏的监听事件
2084e41f4b71Sopenharmony_ci
2085e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
2086e41f4b71Sopenharmony_ci
2087e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
2088e41f4b71Sopenharmony_ci
2089e41f4b71Sopenharmony_ci**参数:**
2090e41f4b71Sopenharmony_ci
2091e41f4b71Sopenharmony_ci| 参数名   | 类型                      | 必填 | 说明                                                         |
2092e41f4b71Sopenharmony_ci| -------- | ------------------------- | ---- | ------------------------------------------------------------ |
2093e41f4b71Sopenharmony_ci| type     | string                    | 是   | 事件回调类型,支持事件`'toggleFavorite'`:当是否收藏的命令被发送到会话时,触发该事件。 |
2094e41f4b71Sopenharmony_ci| callback | (assetId: string) => void | 是   | 回调函数。参数assetId是媒体ID。                              |
2095e41f4b71Sopenharmony_ci
2096e41f4b71Sopenharmony_ci**错误码:**
2097e41f4b71Sopenharmony_ci
2098e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
2099e41f4b71Sopenharmony_ci
2100e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
2101e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
2102e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
2103e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
2104e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
2105e41f4b71Sopenharmony_ci
2106e41f4b71Sopenharmony_ci**示例:**
2107e41f4b71Sopenharmony_ci
2108e41f4b71Sopenharmony_ci```ts
2109e41f4b71Sopenharmony_cicurrentAVSession.on('toggleFavorite', (assetId: string) => {
2110e41f4b71Sopenharmony_ci  console.info(`on toggleFavorite mode : ${assetId}`);
2111e41f4b71Sopenharmony_ci});
2112e41f4b71Sopenharmony_ci```
2113e41f4b71Sopenharmony_ci
2114e41f4b71Sopenharmony_ci### on('skipToQueueItem')<sup>10+</sup>
2115e41f4b71Sopenharmony_ci
2116e41f4b71Sopenharmony_cion(type: 'skipToQueueItem', callback: (itemId: number) => void): void
2117e41f4b71Sopenharmony_ci
2118e41f4b71Sopenharmony_ci设置播放列表其中某项被选中的监听事件,session端可以选择对这个单项歌曲进行播放。
2119e41f4b71Sopenharmony_ci
2120e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
2121e41f4b71Sopenharmony_ci
2122e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
2123e41f4b71Sopenharmony_ci
2124e41f4b71Sopenharmony_ci**参数:**
2125e41f4b71Sopenharmony_ci
2126e41f4b71Sopenharmony_ci| 参数名   | 类型                      | 必填 | 说明                                                                                      |
2127e41f4b71Sopenharmony_ci| -------- | ------------------------ | ---- | ---------------------------------------------------------------------------------------- |
2128e41f4b71Sopenharmony_ci| type     | string                   | 是   | 事件回调类型,支持事件`'skipToQueueItem'`:当播放列表选中单项的命令被发送到会话时,触发该事件。 |
2129e41f4b71Sopenharmony_ci| callback | (itemId: number) => void | 是   | 回调函数。参数itemId是选中的播放列表项的ID。                                                |
2130e41f4b71Sopenharmony_ci
2131e41f4b71Sopenharmony_ci**错误码:**
2132e41f4b71Sopenharmony_ci
2133e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
2134e41f4b71Sopenharmony_ci
2135e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
2136e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
2137e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
2138e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
2139e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
2140e41f4b71Sopenharmony_ci
2141e41f4b71Sopenharmony_ci**示例:**
2142e41f4b71Sopenharmony_ci
2143e41f4b71Sopenharmony_ci```ts
2144e41f4b71Sopenharmony_cicurrentAVSession.on('skipToQueueItem', (itemId: number) => {
2145e41f4b71Sopenharmony_ci  console.info(`on skipToQueueItem id : ${itemId}`);
2146e41f4b71Sopenharmony_ci});
2147e41f4b71Sopenharmony_ci```
2148e41f4b71Sopenharmony_ci
2149e41f4b71Sopenharmony_ci### on('handleKeyEvent')<sup>10+</sup>
2150e41f4b71Sopenharmony_ci
2151e41f4b71Sopenharmony_cion(type: 'handleKeyEvent', callback: (event: KeyEvent) => void): void
2152e41f4b71Sopenharmony_ci
2153e41f4b71Sopenharmony_ci设置蓝牙/有线等外设接入的按键输入事件的监听,监听多媒体按键事件中播放、暂停、上下一首、快进、快退的指令。
2154e41f4b71Sopenharmony_ci
2155e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
2156e41f4b71Sopenharmony_ci
2157e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
2158e41f4b71Sopenharmony_ci
2159e41f4b71Sopenharmony_ci**参数:**
2160e41f4b71Sopenharmony_ci
2161e41f4b71Sopenharmony_ci| 参数名   | 类型                                                         | 必填 | 说明                                                         |
2162e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
2163e41f4b71Sopenharmony_ci| type     | string                                                       | 是   | 事件回调类型,支持事件`'handleKeyEvent'`:当按键事件被发送到会话时,触发该事件。 |
2164e41f4b71Sopenharmony_ci| callback | (event: [KeyEvent](../apis-input-kit/js-apis-keyevent.md)) => void | 是   | 回调函数。参数event是按键事件。                              |
2165e41f4b71Sopenharmony_ci
2166e41f4b71Sopenharmony_ci**错误码:**
2167e41f4b71Sopenharmony_ci
2168e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
2169e41f4b71Sopenharmony_ci
2170e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
2171e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
2172e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
2173e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
2174e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
2175e41f4b71Sopenharmony_ci
2176e41f4b71Sopenharmony_ci**示例:**
2177e41f4b71Sopenharmony_ci
2178e41f4b71Sopenharmony_ci```ts
2179e41f4b71Sopenharmony_ciimport { KeyEvent } from '@kit.InputKit';
2180e41f4b71Sopenharmony_ci
2181e41f4b71Sopenharmony_cicurrentAVSession.on('handleKeyEvent', (event: KeyEvent) => {
2182e41f4b71Sopenharmony_ci  console.info(`on handleKeyEvent event : ${event}`);
2183e41f4b71Sopenharmony_ci});
2184e41f4b71Sopenharmony_ci
2185e41f4b71Sopenharmony_ci```
2186e41f4b71Sopenharmony_ci
2187e41f4b71Sopenharmony_ci### on('outputDeviceChange')<sup>10+</sup>
2188e41f4b71Sopenharmony_ci
2189e41f4b71Sopenharmony_cion(type: 'outputDeviceChange', callback: (state: ConnectionState, device: OutputDeviceInfo) => void): void
2190e41f4b71Sopenharmony_ci
2191e41f4b71Sopenharmony_ci设置播放设备变化的监听事件。应用接入[系统投播组件](ohos-multimedia-avcastpicker.md),当用户通过组件切换设备时,会收到设备切换的回调。
2192e41f4b71Sopenharmony_ci
2193e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
2194e41f4b71Sopenharmony_ci
2195e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
2196e41f4b71Sopenharmony_ci
2197e41f4b71Sopenharmony_ci**参数:**
2198e41f4b71Sopenharmony_ci
2199e41f4b71Sopenharmony_ci| 参数名   | 类型                                                    | 必填 | 说明                                                         |
2200e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ |
2201e41f4b71Sopenharmony_ci| type     | string                                                  | 是   | 事件回调类型,支持事件`'outputDeviceChange'`:当播放设备变化时,触发该事件。 |
2202e41f4b71Sopenharmony_ci| callback | (state: [ConnectionState](#connectionstate10), device: [OutputDeviceInfo](#outputdeviceinfo10)) => void | 是   | 回调函数,参数device是设备相关信息。<br>该参数为可选参数,若不填写该参数,则认为取消所有相关会话的事件监听。                         |
2203e41f4b71Sopenharmony_ci
2204e41f4b71Sopenharmony_ci**错误码:**
2205e41f4b71Sopenharmony_ci
2206e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
2207e41f4b71Sopenharmony_ci
2208e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
2209e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
2210e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
2211e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
2212e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
2213e41f4b71Sopenharmony_ci
2214e41f4b71Sopenharmony_ci**示例:**
2215e41f4b71Sopenharmony_ci
2216e41f4b71Sopenharmony_ci```ts
2217e41f4b71Sopenharmony_cicurrentAVSession.on('outputDeviceChange', (state: avSession.ConnectionState, device: avSession.OutputDeviceInfo) => {
2218e41f4b71Sopenharmony_ci  console.info(`on outputDeviceChange device : ${device}`);
2219e41f4b71Sopenharmony_ci});
2220e41f4b71Sopenharmony_ci```
2221e41f4b71Sopenharmony_ci
2222e41f4b71Sopenharmony_ci### on('commonCommand')<sup>10+</sup>
2223e41f4b71Sopenharmony_ci
2224e41f4b71Sopenharmony_cion(type: 'commonCommand', callback: (command: string, args: {[key: string]: Object}) => void): void
2225e41f4b71Sopenharmony_ci
2226e41f4b71Sopenharmony_ci设置自定义控制命令变化的监听器。
2227e41f4b71Sopenharmony_ci
2228e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
2229e41f4b71Sopenharmony_ci
2230e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
2231e41f4b71Sopenharmony_ci
2232e41f4b71Sopenharmony_ci**参数:**
2233e41f4b71Sopenharmony_ci
2234e41f4b71Sopenharmony_ci| 参数名   | 类型                                                         | 必填 | 说明                                                         |
2235e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
2236e41f4b71Sopenharmony_ci| type     | string                                                       | 是   | 事件回调类型,支持事件`'commonCommand'`:当自定义控制命令变化时,触发该事件。 |
2237e41f4b71Sopenharmony_ci| callback | (command: string, args: {[key:string]: Object}) => void         | 是   | 回调函数,command为变化的自定义控制命令名,args为自定义控制命令的参数,参数内容与[sendCommonCommand](#sendcommoncommand10)方法设置的参数内容完全一致。          |
2238e41f4b71Sopenharmony_ci
2239e41f4b71Sopenharmony_ci**错误码:**
2240e41f4b71Sopenharmony_ci
2241e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
2242e41f4b71Sopenharmony_ci
2243e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
2244e41f4b71Sopenharmony_ci| -------- | ------------------------------ |
2245e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
2246e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
2247e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
2248e41f4b71Sopenharmony_ci
2249e41f4b71Sopenharmony_ci**示例:**
2250e41f4b71Sopenharmony_ci
2251e41f4b71Sopenharmony_ci```ts
2252e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
2253e41f4b71Sopenharmony_ci
2254e41f4b71Sopenharmony_cilet currentAVSession: avSession.AVSession | undefined = undefined;
2255e41f4b71Sopenharmony_cilet tag = "createNewSession";
2256e41f4b71Sopenharmony_cilet context: Context = getContext(this);
2257e41f4b71Sopenharmony_ci
2258e41f4b71Sopenharmony_ciavSession.createAVSession(context, tag, "audio", (err: BusinessError, data: avSession.AVSession) => {
2259e41f4b71Sopenharmony_ci  if (err) {
2260e41f4b71Sopenharmony_ci    console.error(`CreateAVSession BusinessError: code: ${err.code}, message: ${err.message}`);
2261e41f4b71Sopenharmony_ci  } else {
2262e41f4b71Sopenharmony_ci    currentAVSession = data;
2263e41f4b71Sopenharmony_ci  }
2264e41f4b71Sopenharmony_ci});
2265e41f4b71Sopenharmony_ciif (currentAVSession !== undefined) {
2266e41f4b71Sopenharmony_ci  (currentAVSession as avSession.AVSession).on('commonCommand', (commonCommand, args) => {
2267e41f4b71Sopenharmony_ci    console.info(`OnCommonCommand, the command is ${commonCommand}, args: ${JSON.stringify(args)}`);
2268e41f4b71Sopenharmony_ci  });
2269e41f4b71Sopenharmony_ci}
2270e41f4b71Sopenharmony_ci```
2271e41f4b71Sopenharmony_ci
2272e41f4b71Sopenharmony_ci### off('play')<sup>10+</sup>
2273e41f4b71Sopenharmony_ci
2274e41f4b71Sopenharmony_cioff(type: 'play', callback?: () => void): void
2275e41f4b71Sopenharmony_ci
2276e41f4b71Sopenharmony_ci取消会话播放事件监听,关闭后,不再进行该事件回调。
2277e41f4b71Sopenharmony_ci
2278e41f4b71Sopenharmony_ci取消回调时,需要更新支持的命令列表。
2279e41f4b71Sopenharmony_ci
2280e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
2281e41f4b71Sopenharmony_ci
2282e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
2283e41f4b71Sopenharmony_ci
2284e41f4b71Sopenharmony_ci**参数:**
2285e41f4b71Sopenharmony_ci
2286e41f4b71Sopenharmony_ci| 参数名    | 类型                  | 必填 | 说明                                                                                                                         |
2287e41f4b71Sopenharmony_ci| -------- | -------------------- | ---- | ---------------------------------------------------------------------------------------------------------------------------- |
2288e41f4b71Sopenharmony_ci| type     | string               | 是   | 关闭对应的监听事件,支持的事件是`'play'`|
2289e41f4b71Sopenharmony_ci| callback | () => void | 否   | 回调函数。当监听事件取消成功,err为undefined,否则返回错误对象。<br>该参数为可选参数,若不填写该参数,则认为取消所有相关会话的事件监听。                            |
2290e41f4b71Sopenharmony_ci
2291e41f4b71Sopenharmony_ci**错误码:**
2292e41f4b71Sopenharmony_ci
2293e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
2294e41f4b71Sopenharmony_ci
2295e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
2296e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
2297e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
2298e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
2299e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
2300e41f4b71Sopenharmony_ci
2301e41f4b71Sopenharmony_ci**示例:**
2302e41f4b71Sopenharmony_ci
2303e41f4b71Sopenharmony_ci```ts
2304e41f4b71Sopenharmony_cicurrentAVSession.off('play');
2305e41f4b71Sopenharmony_ci```
2306e41f4b71Sopenharmony_ci
2307e41f4b71Sopenharmony_ci### off('pause')<sup>10+</sup>
2308e41f4b71Sopenharmony_ci
2309e41f4b71Sopenharmony_cioff(type: 'pause', callback?: () => void): void
2310e41f4b71Sopenharmony_ci
2311e41f4b71Sopenharmony_ci取消会话暂停事件监听,关闭后,不再进行该事件回调。
2312e41f4b71Sopenharmony_ci
2313e41f4b71Sopenharmony_ci取消回调时,需要更新支持的命令列表。
2314e41f4b71Sopenharmony_ci
2315e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
2316e41f4b71Sopenharmony_ci
2317e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
2318e41f4b71Sopenharmony_ci
2319e41f4b71Sopenharmony_ci**参数:**
2320e41f4b71Sopenharmony_ci
2321e41f4b71Sopenharmony_ci| 参数名    | 类型                  | 必填 | 说明                                                                                                                         |
2322e41f4b71Sopenharmony_ci| -------- | -------------------- | ---- | ---------------------------------------------------------------------------------------------------------------------------- |
2323e41f4b71Sopenharmony_ci| type     | string               | 是   | 关闭对应的监听事件,支持的事件是`'pause'`。 |
2324e41f4b71Sopenharmony_ci| callback | () => void | 否   | 回调函数。当监听事件取消成功,err为undefined,否则返回错误对象。<br>该参数为可选参数,若不填写该参数,则认为取消所有相关会话的事件监听。 |
2325e41f4b71Sopenharmony_ci
2326e41f4b71Sopenharmony_ci**错误码:**
2327e41f4b71Sopenharmony_ci
2328e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
2329e41f4b71Sopenharmony_ci
2330e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
2331e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
2332e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
2333e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
2334e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
2335e41f4b71Sopenharmony_ci
2336e41f4b71Sopenharmony_ci**示例:**
2337e41f4b71Sopenharmony_ci
2338e41f4b71Sopenharmony_ci```ts
2339e41f4b71Sopenharmony_cicurrentAVSession.off('pause');
2340e41f4b71Sopenharmony_ci```
2341e41f4b71Sopenharmony_ci
2342e41f4b71Sopenharmony_ci### off('stop')<sup>10+</sup>
2343e41f4b71Sopenharmony_ci
2344e41f4b71Sopenharmony_cioff(type: 'stop', callback?: () => void): void
2345e41f4b71Sopenharmony_ci
2346e41f4b71Sopenharmony_ci取消会话停止事件监听,关闭后,不再进行该事件回调。
2347e41f4b71Sopenharmony_ci
2348e41f4b71Sopenharmony_ci取消回调时,需要更新支持的命令列表。
2349e41f4b71Sopenharmony_ci
2350e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
2351e41f4b71Sopenharmony_ci
2352e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
2353e41f4b71Sopenharmony_ci
2354e41f4b71Sopenharmony_ci**参数:**
2355e41f4b71Sopenharmony_ci
2356e41f4b71Sopenharmony_ci| 参数名    | 类型                  | 必填 | 说明                                                                                                                         |
2357e41f4b71Sopenharmony_ci| -------- | -------------------- | ---- | ---------------------------------------------------------------------------------------------------------------------------- |
2358e41f4b71Sopenharmony_ci| type     | string               | 是   | 关闭对应的监听事件,支持的事件是`'stop'`。 |
2359e41f4b71Sopenharmony_ci| callback | () => void | 否   | 回调函数。当监听事件取消成功,err为undefined,否则返回错误对象。<br>该参数为可选参数,若不填写该参数,则认为取消所有相关会话的事件监听。                            |
2360e41f4b71Sopenharmony_ci
2361e41f4b71Sopenharmony_ci**错误码:**
2362e41f4b71Sopenharmony_ci
2363e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
2364e41f4b71Sopenharmony_ci
2365e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
2366e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
2367e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
2368e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
2369e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
2370e41f4b71Sopenharmony_ci
2371e41f4b71Sopenharmony_ci**示例:**
2372e41f4b71Sopenharmony_ci
2373e41f4b71Sopenharmony_ci```ts
2374e41f4b71Sopenharmony_cicurrentAVSession.off('stop');
2375e41f4b71Sopenharmony_ci```
2376e41f4b71Sopenharmony_ci
2377e41f4b71Sopenharmony_ci### off('playNext')<sup>10+</sup>
2378e41f4b71Sopenharmony_ci
2379e41f4b71Sopenharmony_cioff(type: 'playNext', callback?: () => void): void
2380e41f4b71Sopenharmony_ci
2381e41f4b71Sopenharmony_ci取消会话播放下一首事件监听,关闭后,不再进行该事件回调。
2382e41f4b71Sopenharmony_ci
2383e41f4b71Sopenharmony_ci取消回调时,需要更新支持的命令列表。
2384e41f4b71Sopenharmony_ci
2385e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
2386e41f4b71Sopenharmony_ci
2387e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
2388e41f4b71Sopenharmony_ci
2389e41f4b71Sopenharmony_ci**参数:**
2390e41f4b71Sopenharmony_ci
2391e41f4b71Sopenharmony_ci| 参数名    | 类型                  | 必填 | 说明                                                                                                                         |
2392e41f4b71Sopenharmony_ci| -------- | -------------------- | ---- | ---------------------------------------------------------------------------------------------------------------------------- |
2393e41f4b71Sopenharmony_ci| type     | string               | 是   | 关闭对应的监听事件,支持的事件是 `'playNext'`。 |
2394e41f4b71Sopenharmony_ci| callback | () => void | 否   | 回调函数。当监听事件取消成功,err为undefined,否则返回错误对象。<br>该参数为可选参数,若不填写该参数,则认为取消所有相关会话的事件监听。                            |
2395e41f4b71Sopenharmony_ci
2396e41f4b71Sopenharmony_ci**错误码:**
2397e41f4b71Sopenharmony_ci
2398e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
2399e41f4b71Sopenharmony_ci
2400e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
2401e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
2402e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
2403e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
2404e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
2405e41f4b71Sopenharmony_ci
2406e41f4b71Sopenharmony_ci**示例:**
2407e41f4b71Sopenharmony_ci
2408e41f4b71Sopenharmony_ci```ts
2409e41f4b71Sopenharmony_cicurrentAVSession.off('playNext');
2410e41f4b71Sopenharmony_ci```
2411e41f4b71Sopenharmony_ci
2412e41f4b71Sopenharmony_ci### off('playPrevious')<sup>10+</sup>
2413e41f4b71Sopenharmony_ci
2414e41f4b71Sopenharmony_cioff(type: 'playPrevious', callback?: () => void): void
2415e41f4b71Sopenharmony_ci
2416e41f4b71Sopenharmony_ci取消会话播放上一首事件监听,关闭后,不再进行该事件回调。
2417e41f4b71Sopenharmony_ci
2418e41f4b71Sopenharmony_ci取消回调时,需要更新支持的命令列表。
2419e41f4b71Sopenharmony_ci
2420e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
2421e41f4b71Sopenharmony_ci
2422e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
2423e41f4b71Sopenharmony_ci
2424e41f4b71Sopenharmony_ci**参数:**
2425e41f4b71Sopenharmony_ci
2426e41f4b71Sopenharmony_ci| 参数名    | 类型                  | 必填 | 说明                                                                                                                         |
2427e41f4b71Sopenharmony_ci| -------- | -------------------- | ---- | ---------------------------------------------------------------------------------------------------------------------------- |
2428e41f4b71Sopenharmony_ci| type     | string               | 是   | 关闭对应的监听事件,支持的事件是`'playPrevious'`。 |
2429e41f4b71Sopenharmony_ci| callback | () => void | 否   | 回调函数。当监听事件取消成功,err为undefined,否则返回错误对象。<br>该参数为可选参数,若不填写该参数,则认为取消所有相关会话的事件监听。                            |
2430e41f4b71Sopenharmony_ci
2431e41f4b71Sopenharmony_ci**错误码:**
2432e41f4b71Sopenharmony_ci
2433e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
2434e41f4b71Sopenharmony_ci
2435e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
2436e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
2437e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
2438e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
2439e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
2440e41f4b71Sopenharmony_ci
2441e41f4b71Sopenharmony_ci**示例:**
2442e41f4b71Sopenharmony_ci
2443e41f4b71Sopenharmony_ci```ts
2444e41f4b71Sopenharmony_cicurrentAVSession.off('playPrevious');
2445e41f4b71Sopenharmony_ci```
2446e41f4b71Sopenharmony_ci
2447e41f4b71Sopenharmony_ci### off('fastForward')<sup>10+</sup>
2448e41f4b71Sopenharmony_ci
2449e41f4b71Sopenharmony_cioff(type: 'fastForward', callback?: () => void): void
2450e41f4b71Sopenharmony_ci
2451e41f4b71Sopenharmony_ci取消会话快进事件监听,关闭后,不再进行该事件回调。
2452e41f4b71Sopenharmony_ci
2453e41f4b71Sopenharmony_ci取消回调时,需要更新支持的命令列表。
2454e41f4b71Sopenharmony_ci
2455e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
2456e41f4b71Sopenharmony_ci
2457e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
2458e41f4b71Sopenharmony_ci
2459e41f4b71Sopenharmony_ci**参数:**
2460e41f4b71Sopenharmony_ci
2461e41f4b71Sopenharmony_ci| 参数名    | 类型                  | 必填 | 说明                                                                                                                         |
2462e41f4b71Sopenharmony_ci| -------- | -------------------- | ---- | ---------------------------------------------------------------------------------------------------------------------------- |
2463e41f4b71Sopenharmony_ci| type     | string               | 是   | 关闭对应的监听事件,支持的事件是`'fastForward'`。 |
2464e41f4b71Sopenharmony_ci| callback | () => void | 否   | 回调函数。当监听事件取消成功,err为undefined,否则返回错误对象。<br>该参数为可选参数,若不填写该参数,则认为取消所有相关会话的事件监听。                            |
2465e41f4b71Sopenharmony_ci
2466e41f4b71Sopenharmony_ci**错误码:**
2467e41f4b71Sopenharmony_ci
2468e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
2469e41f4b71Sopenharmony_ci
2470e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
2471e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
2472e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
2473e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
2474e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
2475e41f4b71Sopenharmony_ci
2476e41f4b71Sopenharmony_ci**示例:**
2477e41f4b71Sopenharmony_ci
2478e41f4b71Sopenharmony_ci```ts
2479e41f4b71Sopenharmony_cicurrentAVSession.off('fastForward');
2480e41f4b71Sopenharmony_ci```
2481e41f4b71Sopenharmony_ci
2482e41f4b71Sopenharmony_ci### off('rewind')<sup>10+</sup>
2483e41f4b71Sopenharmony_ci
2484e41f4b71Sopenharmony_cioff(type: 'rewind', callback?: () => void): void
2485e41f4b71Sopenharmony_ci
2486e41f4b71Sopenharmony_ci取消会话快退事件监听,关闭后,不再进行该事件回调。
2487e41f4b71Sopenharmony_ci
2488e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
2489e41f4b71Sopenharmony_ci
2490e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
2491e41f4b71Sopenharmony_ci
2492e41f4b71Sopenharmony_ci**参数:**
2493e41f4b71Sopenharmony_ci
2494e41f4b71Sopenharmony_ci| 参数名    | 类型                  | 必填 | 说明                                                                                                                         |
2495e41f4b71Sopenharmony_ci| -------- | -------------------- | ---- | ---------------------------------------------------------------------------------------------------------------------------- |
2496e41f4b71Sopenharmony_ci| type     | string               | 是   | 关闭对应的监听事件,支持的事件是`'rewind'`。 |
2497e41f4b71Sopenharmony_ci| callback | () => void | 否   | 回调函数。当监听事件取消成功,err为undefined,否则返回错误对象。<br>该参数为可选参数,若不填写该参数,则认为取消所有相关会话的事件监听。                            |
2498e41f4b71Sopenharmony_ci
2499e41f4b71Sopenharmony_ci**错误码:**
2500e41f4b71Sopenharmony_ci
2501e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
2502e41f4b71Sopenharmony_ci
2503e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
2504e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
2505e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
2506e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
2507e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
2508e41f4b71Sopenharmony_ci
2509e41f4b71Sopenharmony_ci**示例:**
2510e41f4b71Sopenharmony_ci
2511e41f4b71Sopenharmony_ci```ts
2512e41f4b71Sopenharmony_cicurrentAVSession.off('rewind');
2513e41f4b71Sopenharmony_ci```
2514e41f4b71Sopenharmony_ci
2515e41f4b71Sopenharmony_ci### off('seek')<sup>10+</sup>
2516e41f4b71Sopenharmony_ci
2517e41f4b71Sopenharmony_cioff(type: 'seek', callback?: (time: number) => void): void
2518e41f4b71Sopenharmony_ci
2519e41f4b71Sopenharmony_ci取消监听跳转节点事件。
2520e41f4b71Sopenharmony_ci
2521e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
2522e41f4b71Sopenharmony_ci
2523e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
2524e41f4b71Sopenharmony_ci
2525e41f4b71Sopenharmony_ci**参数:**
2526e41f4b71Sopenharmony_ci
2527e41f4b71Sopenharmony_ci| 参数名   | 类型                   | 必填 | 说明                                          |
2528e41f4b71Sopenharmony_ci| -------- | ---------------------- | ---- | ----------------------------------------- |
2529e41f4b71Sopenharmony_ci| type     | string                 | 是   | 关闭对应的监听事件,支持关闭事件`'seek'`。       |
2530e41f4b71Sopenharmony_ci| callback | (time: number) => void | 否   | 回调函数,参数time是时间节点,单位为毫秒。<br>当监听事件取消成功,err为undefined,否则返回错误对象。<br>该参数为可选参数,若不填写该参数,则认为取消所有相关会话的事件监听。        |
2531e41f4b71Sopenharmony_ci
2532e41f4b71Sopenharmony_ci**错误码:**
2533e41f4b71Sopenharmony_ci
2534e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
2535e41f4b71Sopenharmony_ci
2536e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
2537e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
2538e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
2539e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
2540e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
2541e41f4b71Sopenharmony_ci
2542e41f4b71Sopenharmony_ci**示例:**
2543e41f4b71Sopenharmony_ci
2544e41f4b71Sopenharmony_ci```ts
2545e41f4b71Sopenharmony_cicurrentAVSession.off('seek');
2546e41f4b71Sopenharmony_ci```
2547e41f4b71Sopenharmony_ci
2548e41f4b71Sopenharmony_ci### off('setSpeed')<sup>10+</sup>
2549e41f4b71Sopenharmony_ci
2550e41f4b71Sopenharmony_cioff(type: 'setSpeed', callback?: (speed: number) => void): void
2551e41f4b71Sopenharmony_ci
2552e41f4b71Sopenharmony_ci取消监听播放速率变化事件。
2553e41f4b71Sopenharmony_ci
2554e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
2555e41f4b71Sopenharmony_ci
2556e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
2557e41f4b71Sopenharmony_ci
2558e41f4b71Sopenharmony_ci**参数:**
2559e41f4b71Sopenharmony_ci
2560e41f4b71Sopenharmony_ci| 参数名   | 类型                    | 必填 | 说明                                           |
2561e41f4b71Sopenharmony_ci| -------- | ----------------------- | ---- | -------------------------------------------|
2562e41f4b71Sopenharmony_ci| type     | string                  | 是   | 关闭对应的监听事件,支持关闭事件`'setSpeed'`。    |
2563e41f4b71Sopenharmony_ci| callback | (speed: number) => void | 否   | 回调函数,参数speed是播放倍速。<br>当监听事件取消成功,err为undefined,否则返回错误对象。<br>该参数为可选参数,若不填写该参数,则认为取消所有相关会话的事件监听。                 |
2564e41f4b71Sopenharmony_ci
2565e41f4b71Sopenharmony_ci**错误码:**
2566e41f4b71Sopenharmony_ci
2567e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
2568e41f4b71Sopenharmony_ci
2569e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
2570e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
2571e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
2572e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
2573e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
2574e41f4b71Sopenharmony_ci
2575e41f4b71Sopenharmony_ci**示例:**
2576e41f4b71Sopenharmony_ci
2577e41f4b71Sopenharmony_ci```ts
2578e41f4b71Sopenharmony_cicurrentAVSession.off('setSpeed');
2579e41f4b71Sopenharmony_ci```
2580e41f4b71Sopenharmony_ci
2581e41f4b71Sopenharmony_ci### off('setLoopMode')<sup>10+</sup>
2582e41f4b71Sopenharmony_ci
2583e41f4b71Sopenharmony_cioff(type: 'setLoopMode', callback?: (mode: LoopMode) => void): void
2584e41f4b71Sopenharmony_ci
2585e41f4b71Sopenharmony_ci取消监听循环模式变化事件。
2586e41f4b71Sopenharmony_ci
2587e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
2588e41f4b71Sopenharmony_ci
2589e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
2590e41f4b71Sopenharmony_ci
2591e41f4b71Sopenharmony_ci**参数:**
2592e41f4b71Sopenharmony_ci
2593e41f4b71Sopenharmony_ci| 参数名   | 类型                                  | 必填 | 说明     |
2594e41f4b71Sopenharmony_ci| -------- | ------------------------------------- | ---- | ----- |
2595e41f4b71Sopenharmony_ci| type     | string | 是   | 关闭对应的监听事件,支持关闭事件`'setLoopMode'`。|
2596e41f4b71Sopenharmony_ci| callback | (mode: [LoopMode](#loopmode10)) => void | 否   | 回调函数,参数mode是循环模式。<br>当监听事件取消成功,err为undefined,否则返回错误对象。<br>该参数为可选参数,若不填写该参数,则认为取消所有相关会话的事件监听。 |
2597e41f4b71Sopenharmony_ci
2598e41f4b71Sopenharmony_ci**错误码:**
2599e41f4b71Sopenharmony_ci
2600e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
2601e41f4b71Sopenharmony_ci
2602e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
2603e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
2604e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
2605e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
2606e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
2607e41f4b71Sopenharmony_ci
2608e41f4b71Sopenharmony_ci**示例:**
2609e41f4b71Sopenharmony_ci
2610e41f4b71Sopenharmony_ci```ts
2611e41f4b71Sopenharmony_cicurrentAVSession.off('setLoopMode');
2612e41f4b71Sopenharmony_ci```
2613e41f4b71Sopenharmony_ci
2614e41f4b71Sopenharmony_ci### off('toggleFavorite')<sup>10+</sup>
2615e41f4b71Sopenharmony_ci
2616e41f4b71Sopenharmony_cioff(type: 'toggleFavorite', callback?: (assetId: string) => void): void
2617e41f4b71Sopenharmony_ci
2618e41f4b71Sopenharmony_ci取消监听是否收藏的事件
2619e41f4b71Sopenharmony_ci
2620e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
2621e41f4b71Sopenharmony_ci
2622e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
2623e41f4b71Sopenharmony_ci
2624e41f4b71Sopenharmony_ci**参数:**
2625e41f4b71Sopenharmony_ci
2626e41f4b71Sopenharmony_ci| 参数名   | 类型                      | 必填 | 说明                                                         |
2627e41f4b71Sopenharmony_ci| -------- | ------------------------- | ---- | -------------------------------------------------------- |
2628e41f4b71Sopenharmony_ci| type     | string                    | 是   | 关闭对应的监听事件,支持关闭事件`'toggleFavorite'`。            |
2629e41f4b71Sopenharmony_ci| callback | (assetId: string) => void | 否   | 回调函数,参数assetId是媒体ID。<br>当监听事件取消成功,err为undefined,否则返回错误对象。<br>该参数为可选参数,若不填写该参数,则认为取消所有相关会话的事件监听。                               |
2630e41f4b71Sopenharmony_ci
2631e41f4b71Sopenharmony_ci**错误码:**
2632e41f4b71Sopenharmony_ci
2633e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
2634e41f4b71Sopenharmony_ci
2635e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
2636e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
2637e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
2638e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
2639e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
2640e41f4b71Sopenharmony_ci
2641e41f4b71Sopenharmony_ci**示例:**
2642e41f4b71Sopenharmony_ci
2643e41f4b71Sopenharmony_ci```ts
2644e41f4b71Sopenharmony_cicurrentAVSession.off('toggleFavorite');
2645e41f4b71Sopenharmony_ci```
2646e41f4b71Sopenharmony_ci
2647e41f4b71Sopenharmony_ci### off('skipToQueueItem')<sup>10+</sup>
2648e41f4b71Sopenharmony_ci
2649e41f4b71Sopenharmony_cioff(type: 'skipToQueueItem', callback?: (itemId: number) => void): void
2650e41f4b71Sopenharmony_ci
2651e41f4b71Sopenharmony_ci取消监听播放列表单项选中的事件
2652e41f4b71Sopenharmony_ci
2653e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
2654e41f4b71Sopenharmony_ci
2655e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
2656e41f4b71Sopenharmony_ci
2657e41f4b71Sopenharmony_ci**参数:**
2658e41f4b71Sopenharmony_ci
2659e41f4b71Sopenharmony_ci| 参数名   | 类型                      | 必填 | 说明                                                                                                                                                        |
2660e41f4b71Sopenharmony_ci| -------- | ------------------------ | ---- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
2661e41f4b71Sopenharmony_ci| type     | string                   | 是   | 关闭对应的监听事件,支持关闭事件`'skipToQueueItem'`。                                                                                                          |
2662e41f4b71Sopenharmony_ci| callback | (itemId: number) => void | 否   | 回调函数,参数itemId是播放列表单项ID。<br>当监听事件取消成功,err为undefined,否则返回错误对象。<br>该参数为可选参数,若不填写该参数,则认为取消所有相关会话的事件监听。 |
2663e41f4b71Sopenharmony_ci
2664e41f4b71Sopenharmony_ci**错误码:**
2665e41f4b71Sopenharmony_ci
2666e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
2667e41f4b71Sopenharmony_ci
2668e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
2669e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
2670e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
2671e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
2672e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
2673e41f4b71Sopenharmony_ci
2674e41f4b71Sopenharmony_ci**示例:**
2675e41f4b71Sopenharmony_ci
2676e41f4b71Sopenharmony_ci```ts
2677e41f4b71Sopenharmony_cicurrentAVSession.off('skipToQueueItem');
2678e41f4b71Sopenharmony_ci```
2679e41f4b71Sopenharmony_ci
2680e41f4b71Sopenharmony_ci### off('handleKeyEvent')<sup>10+</sup>
2681e41f4b71Sopenharmony_ci
2682e41f4b71Sopenharmony_cioff(type: 'handleKeyEvent', callback?: (event: KeyEvent) => void): void
2683e41f4b71Sopenharmony_ci
2684e41f4b71Sopenharmony_ci取消监听按键事件。
2685e41f4b71Sopenharmony_ci
2686e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
2687e41f4b71Sopenharmony_ci
2688e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
2689e41f4b71Sopenharmony_ci
2690e41f4b71Sopenharmony_ci**参数:**
2691e41f4b71Sopenharmony_ci
2692e41f4b71Sopenharmony_ci| 参数名   | 类型                                                         | 必填 | 说明                                                         |
2693e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
2694e41f4b71Sopenharmony_ci| type     | string                                                       | 是   | 关闭对应的监听事件,支持关闭事件`'handleKeyEvent'`。             |
2695e41f4b71Sopenharmony_ci| callback | (event: [KeyEvent](../apis-input-kit/js-apis-keyevent.md)) => void | 否   | 回调函数,参数event是按键事件。<br>当监听事件取消成功,err为undefined,否则返回错误对象。<br>该参数为可选参数,若不填写该参数,则认为取消所有相关会话的事件监听。                              |
2696e41f4b71Sopenharmony_ci
2697e41f4b71Sopenharmony_ci**错误码:**
2698e41f4b71Sopenharmony_ci
2699e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
2700e41f4b71Sopenharmony_ci
2701e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
2702e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
2703e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
2704e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
2705e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
2706e41f4b71Sopenharmony_ci
2707e41f4b71Sopenharmony_ci**示例:**
2708e41f4b71Sopenharmony_ci
2709e41f4b71Sopenharmony_ci```ts
2710e41f4b71Sopenharmony_cicurrentAVSession.off('handleKeyEvent');
2711e41f4b71Sopenharmony_ci```
2712e41f4b71Sopenharmony_ci
2713e41f4b71Sopenharmony_ci### off('outputDeviceChange')<sup>10+</sup>
2714e41f4b71Sopenharmony_ci
2715e41f4b71Sopenharmony_cioff(type: 'outputDeviceChange', callback?: (state: ConnectionState, device: OutputDeviceInfo) => void): void
2716e41f4b71Sopenharmony_ci
2717e41f4b71Sopenharmony_ci取消监听播放设备变化的事件。
2718e41f4b71Sopenharmony_ci
2719e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
2720e41f4b71Sopenharmony_ci
2721e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
2722e41f4b71Sopenharmony_ci
2723e41f4b71Sopenharmony_ci**参数:**
2724e41f4b71Sopenharmony_ci
2725e41f4b71Sopenharmony_ci| 参数名   | 类型                                                    | 必填 | 说明                                                      |
2726e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------ |
2727e41f4b71Sopenharmony_ci| type     | string                                                  | 是   | 关闭对应的监听事件,支持关闭事件`'outputDeviceChange'`。     |
2728e41f4b71Sopenharmony_ci| callback | (state: [ConnectionState](#connectionstate10), device: [OutputDeviceInfo](#outputdeviceinfo10)) => void | 否   | 回调函数,参数device是设备相关信息。<br>当监听事件取消成功,err为undefined,否则返回错误对象。<br>该参数为可选参数,若不填写该参数,则认为取消所有相关会话的事件监听。                        |
2729e41f4b71Sopenharmony_ci
2730e41f4b71Sopenharmony_ci**错误码:**
2731e41f4b71Sopenharmony_ci
2732e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
2733e41f4b71Sopenharmony_ci
2734e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
2735e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
2736e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
2737e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
2738e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
2739e41f4b71Sopenharmony_ci
2740e41f4b71Sopenharmony_ci**示例:**
2741e41f4b71Sopenharmony_ci
2742e41f4b71Sopenharmony_ci```ts
2743e41f4b71Sopenharmony_cicurrentAVSession.off('outputDeviceChange');
2744e41f4b71Sopenharmony_ci```
2745e41f4b71Sopenharmony_ci
2746e41f4b71Sopenharmony_ci
2747e41f4b71Sopenharmony_ci### off('commonCommand')<sup>10+</sup>
2748e41f4b71Sopenharmony_ci
2749e41f4b71Sopenharmony_cioff(type: 'commonCommand', callback?: (command: string, args: {[key:string]: Object}) => void): void
2750e41f4b71Sopenharmony_ci
2751e41f4b71Sopenharmony_ci取消监听自定义控制命令的变化。
2752e41f4b71Sopenharmony_ci
2753e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
2754e41f4b71Sopenharmony_ci
2755e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
2756e41f4b71Sopenharmony_ci
2757e41f4b71Sopenharmony_ci**参数:**
2758e41f4b71Sopenharmony_ci
2759e41f4b71Sopenharmony_ci| 参数名   | 类型                                                         | 必填 | 说明                                                     |
2760e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | ---- | ----------------------------------------------------- |
2761e41f4b71Sopenharmony_ci| type     | string                                                       | 是   | 取消对应的监听事件,支持事件`'commonCommand'`。    |
2762e41f4b71Sopenharmony_ci| callback | (command: string, args: {[key:string]: Object}) => void         | 否   | 回调函数,参数command是变化的自定义控制命令名,args为自定义控制命令的参数。<br>该参数为可选参数,若不填写该参数,则认为取消所有对command事件的监听。                      |
2763e41f4b71Sopenharmony_ci
2764e41f4b71Sopenharmony_ci**错误码:**
2765e41f4b71Sopenharmony_ci
2766e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
2767e41f4b71Sopenharmony_ci
2768e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
2769e41f4b71Sopenharmony_ci| -------- | ---------------- |
2770e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
2771e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
2772e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
2773e41f4b71Sopenharmony_ci
2774e41f4b71Sopenharmony_ci**示例:**
2775e41f4b71Sopenharmony_ci
2776e41f4b71Sopenharmony_ci```ts
2777e41f4b71Sopenharmony_cicurrentAVSession.off('commonCommand');
2778e41f4b71Sopenharmony_ci```
2779e41f4b71Sopenharmony_ci
2780e41f4b71Sopenharmony_ci### on('answer')<sup>11+</sup>
2781e41f4b71Sopenharmony_ci
2782e41f4b71Sopenharmony_cion(type: 'answer', callback: Callback\<void>): void;
2783e41f4b71Sopenharmony_ci
2784e41f4b71Sopenharmony_ci设置通话接听的监听事件。
2785e41f4b71Sopenharmony_ci
2786e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
2787e41f4b71Sopenharmony_ci
2788e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
2789e41f4b71Sopenharmony_ci
2790e41f4b71Sopenharmony_ci**参数:**
2791e41f4b71Sopenharmony_ci
2792e41f4b71Sopenharmony_ci| 参数名   | 类型                                                         | 必填 | 说明                                                         |
2793e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
2794e41f4b71Sopenharmony_ci| type     | string                                                       | 是   | 事件回调类型,支持事件`'answer'`:当通话接听时,触发该事件。 |
2795e41f4b71Sopenharmony_ci| callback | Callback\<void>                                               | 是   | 回调函数                      |
2796e41f4b71Sopenharmony_ci
2797e41f4b71Sopenharmony_ci**错误码:**
2798e41f4b71Sopenharmony_ci
2799e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
2800e41f4b71Sopenharmony_ci
2801e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
2802e41f4b71Sopenharmony_ci| -------- | ------------------------------ |
2803e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
2804e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
2805e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
2806e41f4b71Sopenharmony_ci
2807e41f4b71Sopenharmony_ci**示例:**
2808e41f4b71Sopenharmony_ci
2809e41f4b71Sopenharmony_ci```ts
2810e41f4b71Sopenharmony_cicurrentAVSession.on('answer', () => {
2811e41f4b71Sopenharmony_ci  console.info('on call answer');
2812e41f4b71Sopenharmony_ci});
2813e41f4b71Sopenharmony_ci```
2814e41f4b71Sopenharmony_ci
2815e41f4b71Sopenharmony_ci### off('answer')<sup>11+</sup>
2816e41f4b71Sopenharmony_ci
2817e41f4b71Sopenharmony_cioff(type: 'answer', callback?: Callback\<void>): void;
2818e41f4b71Sopenharmony_ci
2819e41f4b71Sopenharmony_ci取消通话接听事件的监听。
2820e41f4b71Sopenharmony_ci
2821e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
2822e41f4b71Sopenharmony_ci
2823e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
2824e41f4b71Sopenharmony_ci
2825e41f4b71Sopenharmony_ci**参数:**
2826e41f4b71Sopenharmony_ci
2827e41f4b71Sopenharmony_ci| 参数名    | 类型                  | 必填 | 说明                                                                                                                         |
2828e41f4b71Sopenharmony_ci| -------- | -------------------- | ---- | ---------------------------------------------------------------------------------------------------------------------------- |
2829e41f4b71Sopenharmony_ci| type     | string               | 是   | 关闭对应的监听事件,支持的事件是`'answer'`。 |
2830e41f4b71Sopenharmony_ci| callback | Callback\<void>     | 否   | 回调函数。当监听事件取消成功,err为undefined,否则返回错误对象。<br>该参数为可选参数,若不填写该参数,则认为取消所有相关会话的事件监听。    |
2831e41f4b71Sopenharmony_ci
2832e41f4b71Sopenharmony_ci**错误码:**
2833e41f4b71Sopenharmony_ci
2834e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
2835e41f4b71Sopenharmony_ci
2836e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
2837e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
2838e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
2839e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
2840e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
2841e41f4b71Sopenharmony_ci
2842e41f4b71Sopenharmony_ci**示例:**
2843e41f4b71Sopenharmony_ci
2844e41f4b71Sopenharmony_ci```ts
2845e41f4b71Sopenharmony_cicurrentAVSession.off('answer');
2846e41f4b71Sopenharmony_ci```
2847e41f4b71Sopenharmony_ci
2848e41f4b71Sopenharmony_ci### on('hangUp')<sup>11+</sup>
2849e41f4b71Sopenharmony_ci
2850e41f4b71Sopenharmony_cion(type: 'hangUp', callback: Callback\<void>): void;
2851e41f4b71Sopenharmony_ci
2852e41f4b71Sopenharmony_ci设置通话挂断的监听事件。
2853e41f4b71Sopenharmony_ci
2854e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
2855e41f4b71Sopenharmony_ci
2856e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
2857e41f4b71Sopenharmony_ci
2858e41f4b71Sopenharmony_ci**参数:**
2859e41f4b71Sopenharmony_ci
2860e41f4b71Sopenharmony_ci| 参数名   | 类型                                                         | 必填 | 说明                                                         |
2861e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
2862e41f4b71Sopenharmony_ci| type     | string                                                       | 是   | 事件回调类型,支持事件`'hangUp'`:当通话挂断时,触发该事件。 |
2863e41f4b71Sopenharmony_ci| callback | Callback\<void>                                               | 是   | 回调函数                                             |
2864e41f4b71Sopenharmony_ci
2865e41f4b71Sopenharmony_ci**错误码:**
2866e41f4b71Sopenharmony_ci
2867e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
2868e41f4b71Sopenharmony_ci
2869e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
2870e41f4b71Sopenharmony_ci| -------- | ------------------------------ |
2871e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
2872e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
2873e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
2874e41f4b71Sopenharmony_ci
2875e41f4b71Sopenharmony_ci**示例:**
2876e41f4b71Sopenharmony_ci
2877e41f4b71Sopenharmony_ci```ts
2878e41f4b71Sopenharmony_cicurrentAVSession.on('hangUp', () => {
2879e41f4b71Sopenharmony_ci  console.info('on call hangUp');
2880e41f4b71Sopenharmony_ci});
2881e41f4b71Sopenharmony_ci```
2882e41f4b71Sopenharmony_ci
2883e41f4b71Sopenharmony_ci### off('hangUp')<sup>11+</sup>
2884e41f4b71Sopenharmony_ci
2885e41f4b71Sopenharmony_cioff(type: 'hangUp', callback?: Callback\<void>): void;
2886e41f4b71Sopenharmony_ci
2887e41f4b71Sopenharmony_ci取消通话挂断事件的监听。
2888e41f4b71Sopenharmony_ci
2889e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
2890e41f4b71Sopenharmony_ci
2891e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
2892e41f4b71Sopenharmony_ci
2893e41f4b71Sopenharmony_ci**参数:**
2894e41f4b71Sopenharmony_ci
2895e41f4b71Sopenharmony_ci| 参数名    | 类型                  | 必填 | 说明                                                                                                                         |
2896e41f4b71Sopenharmony_ci| -------- | -------------------- | ---- | ---------------------------------------------------------------------------------------------------------------------------- |
2897e41f4b71Sopenharmony_ci| type     | string               | 是   | 关闭对应的监听事件,支持的事件是`'hangUp'`。 |
2898e41f4b71Sopenharmony_ci| callback | Callback\<void>      | 否   | 回调函数。当监听事件取消成功,err为undefined,否则返回错误对象。<br>该参数为可选参数,若不填写该参数,则认为取消所有相关会话的事件监听。                            |
2899e41f4b71Sopenharmony_ci
2900e41f4b71Sopenharmony_ci**错误码:**
2901e41f4b71Sopenharmony_ci
2902e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
2903e41f4b71Sopenharmony_ci
2904e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
2905e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
2906e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
2907e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
2908e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
2909e41f4b71Sopenharmony_ci
2910e41f4b71Sopenharmony_ci**示例:**
2911e41f4b71Sopenharmony_ci
2912e41f4b71Sopenharmony_ci```ts
2913e41f4b71Sopenharmony_cicurrentAVSession.off('hangUp');
2914e41f4b71Sopenharmony_ci```
2915e41f4b71Sopenharmony_ci
2916e41f4b71Sopenharmony_ci### on('toggleCallMute')<sup>11+</sup>
2917e41f4b71Sopenharmony_ci
2918e41f4b71Sopenharmony_cion(type: 'toggleCallMute', callback: Callback\<void>): void;
2919e41f4b71Sopenharmony_ci
2920e41f4b71Sopenharmony_ci设置通话静音的监听事件。
2921e41f4b71Sopenharmony_ci
2922e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
2923e41f4b71Sopenharmony_ci
2924e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
2925e41f4b71Sopenharmony_ci
2926e41f4b71Sopenharmony_ci**参数:**
2927e41f4b71Sopenharmony_ci
2928e41f4b71Sopenharmony_ci| 参数名   | 类型                                                         | 必填 | 说明                                                         |
2929e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
2930e41f4b71Sopenharmony_ci| type     | string                                                       | 是   | 事件回调类型,支持事件`'toggleCallMute'`:当通话静音或解除静音时,触发该事件。 |
2931e41f4b71Sopenharmony_ci| callback | Callback\<void>                                               | 是   | 回调函数                                             |
2932e41f4b71Sopenharmony_ci
2933e41f4b71Sopenharmony_ci**错误码:**
2934e41f4b71Sopenharmony_ci
2935e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
2936e41f4b71Sopenharmony_ci
2937e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
2938e41f4b71Sopenharmony_ci| -------- | ------------------------------ |
2939e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
2940e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
2941e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
2942e41f4b71Sopenharmony_ci
2943e41f4b71Sopenharmony_ci**示例:**
2944e41f4b71Sopenharmony_ci
2945e41f4b71Sopenharmony_ci```ts
2946e41f4b71Sopenharmony_cicurrentAVSession.on('toggleCallMute', () => {
2947e41f4b71Sopenharmony_ci  console.info('on call toggleCallMute');
2948e41f4b71Sopenharmony_ci});
2949e41f4b71Sopenharmony_ci```
2950e41f4b71Sopenharmony_ci
2951e41f4b71Sopenharmony_ci### off('toggleCallMute')<sup>11+</sup>
2952e41f4b71Sopenharmony_ci
2953e41f4b71Sopenharmony_cioff(type: 'toggleCallMute', callback?: Callback\<void>): void;
2954e41f4b71Sopenharmony_ci
2955e41f4b71Sopenharmony_ci取消通话静音事件的监听。
2956e41f4b71Sopenharmony_ci
2957e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
2958e41f4b71Sopenharmony_ci
2959e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
2960e41f4b71Sopenharmony_ci
2961e41f4b71Sopenharmony_ci**参数:**
2962e41f4b71Sopenharmony_ci
2963e41f4b71Sopenharmony_ci| 参数名    | 类型                  | 必填 | 说明                                                                                                                         |
2964e41f4b71Sopenharmony_ci| -------- | -------------------- | ---- | ---------------------------------------------------------------------------------------------------------------------------- |
2965e41f4b71Sopenharmony_ci| type     | string               | 是   | 关闭对应的监听事件,支持的事件是`'toggleCallMute'`。 |
2966e41f4b71Sopenharmony_ci| callback | Callback\<void>    | 否   | 回调函数。当监听事件取消成功,err为undefined,否则返回错误对象。<br>该参数为可选参数,若不填写该参数,则认为取消所有相关会话的事件监听。                            |
2967e41f4b71Sopenharmony_ci
2968e41f4b71Sopenharmony_ci**错误码:**
2969e41f4b71Sopenharmony_ci
2970e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
2971e41f4b71Sopenharmony_ci
2972e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
2973e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
2974e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
2975e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
2976e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
2977e41f4b71Sopenharmony_ci
2978e41f4b71Sopenharmony_ci**示例:**
2979e41f4b71Sopenharmony_ci
2980e41f4b71Sopenharmony_ci```ts
2981e41f4b71Sopenharmony_cicurrentAVSession.off('toggleCallMute');
2982e41f4b71Sopenharmony_ci```
2983e41f4b71Sopenharmony_ci
2984e41f4b71Sopenharmony_ci### on('castDisplayChange')<sup>12+</sup>
2985e41f4b71Sopenharmony_ci
2986e41f4b71Sopenharmony_cion(type: 'castDisplayChange', callback: Callback\<CastDisplayInfo>): void
2987e41f4b71Sopenharmony_ci
2988e41f4b71Sopenharmony_ci设置扩展屏投播显示设备变化的监听事件。
2989e41f4b71Sopenharmony_ci
2990e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
2991e41f4b71Sopenharmony_ci
2992e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.ExtendedDisplayCast
2993e41f4b71Sopenharmony_ci
2994e41f4b71Sopenharmony_ci**参数:**
2995e41f4b71Sopenharmony_ci
2996e41f4b71Sopenharmony_ci| 参数名    | 类型                  | 必填 | 说明                                                                                                                         |
2997e41f4b71Sopenharmony_ci| -------- | -------------------- | ---- | ---------------------------------------------------------------------------------------------------------------------------- |
2998e41f4b71Sopenharmony_ci| type     | string                                                       | 是   | 事件回调类型,支持事件`'castDisplayChange'`:当扩展屏投播显示设备变化时触发事件。 |
2999e41f4b71Sopenharmony_ci| callback | Callback<[CastDisplayInfo](#castdisplayinfo12)>   | 是   | 回调函数。参数是扩展屏投播显示设备信息。                            |
3000e41f4b71Sopenharmony_ci
3001e41f4b71Sopenharmony_ci**错误码:**
3002e41f4b71Sopenharmony_ci
3003e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
3004e41f4b71Sopenharmony_ci
3005e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
3006e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
3007e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
3008e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
3009e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
3010e41f4b71Sopenharmony_ci
3011e41f4b71Sopenharmony_ci**示例:**
3012e41f4b71Sopenharmony_ci
3013e41f4b71Sopenharmony_ci```ts
3014e41f4b71Sopenharmony_cilet castDisplay: avSession.CastDisplayInfo;
3015e41f4b71Sopenharmony_cicurrentAVSession.on('castDisplayChange', (display: avSession.CastDisplayInfo) => {
3016e41f4b71Sopenharmony_ci    if (display.state === avSession.CastDisplayState.STATE_ON) {
3017e41f4b71Sopenharmony_ci        castDisplay = display;
3018e41f4b71Sopenharmony_ci        console.info(`Succeeded in castDisplayChange display : ${display.id} ON`);
3019e41f4b71Sopenharmony_ci    } else if (display.state === avSession.CastDisplayState.STATE_OFF){
3020e41f4b71Sopenharmony_ci        console.info(`Succeeded in castDisplayChange display : ${display.id} OFF`);
3021e41f4b71Sopenharmony_ci    }
3022e41f4b71Sopenharmony_ci});
3023e41f4b71Sopenharmony_ci```
3024e41f4b71Sopenharmony_ci### off('castDisplayChange')<sup>12+</sup>
3025e41f4b71Sopenharmony_ci
3026e41f4b71Sopenharmony_ci off(type: 'castDisplayChange', callback?: Callback\<CastDisplayInfo>): void
3027e41f4b71Sopenharmony_ci
3028e41f4b71Sopenharmony_ci取消扩展屏投播显示设备变化事件监听,关闭后,不再进行该事件回调。
3029e41f4b71Sopenharmony_ci
3030e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
3031e41f4b71Sopenharmony_ci
3032e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.ExtendedDisplayCast
3033e41f4b71Sopenharmony_ci
3034e41f4b71Sopenharmony_ci**参数:**
3035e41f4b71Sopenharmony_ci
3036e41f4b71Sopenharmony_ci| 参数名    | 类型                  | 必填 | 说明                                                                                                                         |
3037e41f4b71Sopenharmony_ci| -------- | -------------------- | ---- | ---------------------------------------------------------------------------------------------------------------------------- |
3038e41f4b71Sopenharmony_ci| type     | string                                                       | 是   | 关闭对应的监听事件,支持的事件是`'castDisplayChange'`。 |
3039e41f4b71Sopenharmony_ci| callback | Callback<[CastDisplayInfo](#castdisplayinfo12)>   | 否   | 回调函数。当监听事件取消成功,err为undefined,否则返回错误对象。该参数为可选参数,若不填写该参数,则认为取消所有相关会话的事件监听。                            |
3040e41f4b71Sopenharmony_ci
3041e41f4b71Sopenharmony_ci**错误码:**
3042e41f4b71Sopenharmony_ci
3043e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
3044e41f4b71Sopenharmony_ci
3045e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
3046e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
3047e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
3048e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
3049e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
3050e41f4b71Sopenharmony_ci
3051e41f4b71Sopenharmony_ci**示例:**
3052e41f4b71Sopenharmony_ci
3053e41f4b71Sopenharmony_ci```ts
3054e41f4b71Sopenharmony_cicurrentAVSession.off('castDisplayChange');
3055e41f4b71Sopenharmony_ci```
3056e41f4b71Sopenharmony_ci
3057e41f4b71Sopenharmony_ci### stopCasting<sup>10+</sup>
3058e41f4b71Sopenharmony_ci
3059e41f4b71Sopenharmony_cistopCasting(callback: AsyncCallback\<void>): void
3060e41f4b71Sopenharmony_ci
3061e41f4b71Sopenharmony_ci结束投播。结果通过callback异步回调方式返回。
3062e41f4b71Sopenharmony_ci
3063e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.AVCast
3064e41f4b71Sopenharmony_ci
3065e41f4b71Sopenharmony_ci**参数:**
3066e41f4b71Sopenharmony_ci
3067e41f4b71Sopenharmony_ci| 参数名   | 类型                                  | 必填 | 说明                                  |
3068e41f4b71Sopenharmony_ci| -------- | ------------------------------------- | ---- | ------------------------------------- |
3069e41f4b71Sopenharmony_ci| callback | AsyncCallback\<void>                  | 是   | 回调函数。当命令发送成功,err为undefined,否则返回错误对象。 |
3070e41f4b71Sopenharmony_ci
3071e41f4b71Sopenharmony_ci**错误码:**
3072e41f4b71Sopenharmony_ci
3073e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
3074e41f4b71Sopenharmony_ci
3075e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
3076e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
3077e41f4b71Sopenharmony_ci| 6600109  | The remote connection is not established. |
3078e41f4b71Sopenharmony_ci
3079e41f4b71Sopenharmony_ci**示例:**
3080e41f4b71Sopenharmony_ci
3081e41f4b71Sopenharmony_ci```ts
3082e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
3083e41f4b71Sopenharmony_ci
3084e41f4b71Sopenharmony_cicurrentAVSession.stopCasting((err: BusinessError) => {
3085e41f4b71Sopenharmony_ci  if (err) {
3086e41f4b71Sopenharmony_ci    console.error(`stopCasting BusinessError: code: ${err.code}, message: ${err.message}`);
3087e41f4b71Sopenharmony_ci  } else {
3088e41f4b71Sopenharmony_ci    console.info('stopCasting successfully');
3089e41f4b71Sopenharmony_ci  }
3090e41f4b71Sopenharmony_ci});
3091e41f4b71Sopenharmony_ci```
3092e41f4b71Sopenharmony_ci
3093e41f4b71Sopenharmony_ci### stopCasting<sup>10+</sup>
3094e41f4b71Sopenharmony_ci
3095e41f4b71Sopenharmony_cistopCasting(): Promise\<void>
3096e41f4b71Sopenharmony_ci
3097e41f4b71Sopenharmony_ci结束投播。结果通过Promise异步回调方式返回。
3098e41f4b71Sopenharmony_ci
3099e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
3100e41f4b71Sopenharmony_ci
3101e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.AVCast
3102e41f4b71Sopenharmony_ci
3103e41f4b71Sopenharmony_ci**返回值:**
3104e41f4b71Sopenharmony_ci
3105e41f4b71Sopenharmony_ci| 类型           | 说明                          |
3106e41f4b71Sopenharmony_ci| -------------- | ----------------------------- |
3107e41f4b71Sopenharmony_ci| Promise\<void> | Promise对象。当成功结束投播,无返回结果,否则返回错误对象。 |
3108e41f4b71Sopenharmony_ci
3109e41f4b71Sopenharmony_ci**错误码:**
3110e41f4b71Sopenharmony_ci
3111e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
3112e41f4b71Sopenharmony_ci
3113e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
3114e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
3115e41f4b71Sopenharmony_ci| 6600109  | The remote connection is not established. |
3116e41f4b71Sopenharmony_ci
3117e41f4b71Sopenharmony_ci**示例:**
3118e41f4b71Sopenharmony_ci
3119e41f4b71Sopenharmony_ci```ts
3120e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
3121e41f4b71Sopenharmony_ci
3122e41f4b71Sopenharmony_cicurrentAVSession.stopCasting().then(() => {
3123e41f4b71Sopenharmony_ci  console.info('stopCasting successfully');
3124e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
3125e41f4b71Sopenharmony_ci  console.error(`stopCasting BusinessError: code: ${err.code}, message: ${err.message}`);
3126e41f4b71Sopenharmony_ci});
3127e41f4b71Sopenharmony_ci```
3128e41f4b71Sopenharmony_ci
3129e41f4b71Sopenharmony_ci### getOutputDeviceSync<sup>10+</sup>
3130e41f4b71Sopenharmony_ci
3131e41f4b71Sopenharmony_cigetOutputDeviceSync(): OutputDeviceInfo
3132e41f4b71Sopenharmony_ci
3133e41f4b71Sopenharmony_ci使用同步方法获取当前输出设备信息。
3134e41f4b71Sopenharmony_ci
3135e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
3136e41f4b71Sopenharmony_ci
3137e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
3138e41f4b71Sopenharmony_ci
3139e41f4b71Sopenharmony_ci**返回值:**
3140e41f4b71Sopenharmony_ci
3141e41f4b71Sopenharmony_ci| 类型                                            | 说明                              |
3142e41f4b71Sopenharmony_ci| ----------------------------------------------- | --------------------------------- |
3143e41f4b71Sopenharmony_ci| [OutputDeviceInfo](#outputdeviceinfo10) | 当前输出设备信息。 |
3144e41f4b71Sopenharmony_ci
3145e41f4b71Sopenharmony_ci**错误码:**
3146e41f4b71Sopenharmony_ci
3147e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
3148e41f4b71Sopenharmony_ci
3149e41f4b71Sopenharmony_ci| 错误码ID   | 错误信息 |
3150e41f4b71Sopenharmony_ci|---------| --------------------------------------- |
3151e41f4b71Sopenharmony_ci| 6600101 | Session service exception. |
3152e41f4b71Sopenharmony_ci| 6600102 | The session does not exist. |
3153e41f4b71Sopenharmony_ci
3154e41f4b71Sopenharmony_ci**示例:**
3155e41f4b71Sopenharmony_ci
3156e41f4b71Sopenharmony_ci```ts
3157e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
3158e41f4b71Sopenharmony_ci
3159e41f4b71Sopenharmony_citry {
3160e41f4b71Sopenharmony_ci  let currentOutputDevice: avSession.OutputDeviceInfo = currentAVSession.getOutputDeviceSync();
3161e41f4b71Sopenharmony_ci} catch (err) {
3162e41f4b71Sopenharmony_ci  let error = err as BusinessError;
3163e41f4b71Sopenharmony_ci  console.error(`getOutputDeviceSync error, error code: ${error.code}, error message: ${error.message}`);
3164e41f4b71Sopenharmony_ci}
3165e41f4b71Sopenharmony_ci```
3166e41f4b71Sopenharmony_ci### getAllCastDisplays<sup>12+</sup>
3167e41f4b71Sopenharmony_ci
3168e41f4b71Sopenharmony_cigetAllCastDisplays(): Promise<Array\<CastDisplayInfo>>
3169e41f4b71Sopenharmony_ci
3170e41f4b71Sopenharmony_ci获取当前系统中所有支持扩展屏投播的显示设备。通过Promise异步回调方式返回。
3171e41f4b71Sopenharmony_ci
3172e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
3173e41f4b71Sopenharmony_ci
3174e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.ExtendedDisplayCast
3175e41f4b71Sopenharmony_ci
3176e41f4b71Sopenharmony_ci**返回值:**
3177e41f4b71Sopenharmony_ci
3178e41f4b71Sopenharmony_ci| 类型                                            | 说明                              |
3179e41f4b71Sopenharmony_ci| ----------------------------------------------- | --------------------------------- |
3180e41f4b71Sopenharmony_ci| Promise<Array<[CastDisplayInfo](#castdisplayinfo12)>>| Promise对象,返回当前系统中所有支持扩展屏投播的显示设备。 |
3181e41f4b71Sopenharmony_ci
3182e41f4b71Sopenharmony_ci**错误码:**
3183e41f4b71Sopenharmony_ci
3184e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
3185e41f4b71Sopenharmony_ci
3186e41f4b71Sopenharmony_ci| 错误码ID   | 错误信息 |
3187e41f4b71Sopenharmony_ci|---------| --------------------------------------- |
3188e41f4b71Sopenharmony_ci| 6600101 | Session service exception. |
3189e41f4b71Sopenharmony_ci| 6600102 | The session does not exist. |
3190e41f4b71Sopenharmony_ci
3191e41f4b71Sopenharmony_ci**示例:**
3192e41f4b71Sopenharmony_ci
3193e41f4b71Sopenharmony_ci```ts
3194e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
3195e41f4b71Sopenharmony_ci
3196e41f4b71Sopenharmony_cilet castDisplay: avSession.CastDisplayInfo;
3197e41f4b71Sopenharmony_cicurrentAVSession.getAllCastDisplays().then((data: Array< avSession.CastDisplayInfo >) => {
3198e41f4b71Sopenharmony_ci    if (data.length >= 1) {
3199e41f4b71Sopenharmony_ci       castDisplay = data[0];
3200e41f4b71Sopenharmony_ci     }
3201e41f4b71Sopenharmony_ci   }).catch((err: BusinessError) => {
3202e41f4b71Sopenharmony_ci     console.error(`Failed to getAllCastDisplay. Code: ${err.code}, message: ${err.message}`);
3203e41f4b71Sopenharmony_ci   });
3204e41f4b71Sopenharmony_ci```
3205e41f4b71Sopenharmony_ci
3206e41f4b71Sopenharmony_ci## AVCastControlCommandType<sup>10+</sup>
3207e41f4b71Sopenharmony_ci
3208e41f4b71Sopenharmony_citype AVCastControlCommandType = 'play' | 'pause' | 'stop' | 'playNext' | 'playPrevious' | 'fastForward' | 'rewind' |
3209e41f4b71Sopenharmony_ci  'seek' | 'setVolume' | 'setSpeed' | 'setLoopMode' | 'toggleFavorite' | 'toggleMute'
3210e41f4b71Sopenharmony_ci
3211e41f4b71Sopenharmony_ci投播控制器可传递的命令。
3212e41f4b71Sopenharmony_ci
3213e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
3214e41f4b71Sopenharmony_ci
3215e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.AVCast
3216e41f4b71Sopenharmony_ci
3217e41f4b71Sopenharmony_ci| 类型             | 说明         |
3218e41f4b71Sopenharmony_ci| ---------------- | ------------ |
3219e41f4b71Sopenharmony_ci| 'play'           | 播放         |
3220e41f4b71Sopenharmony_ci| 'pause'          | 暂停         |
3221e41f4b71Sopenharmony_ci| 'stop'           | 停止         |
3222e41f4b71Sopenharmony_ci| 'playNext'       | 下一首       |
3223e41f4b71Sopenharmony_ci| 'playPrevious'   | 上一首       |
3224e41f4b71Sopenharmony_ci| 'fastForward'    | 快进         |
3225e41f4b71Sopenharmony_ci| 'rewind'         | 快退         |
3226e41f4b71Sopenharmony_ci| 'seek'           | 跳转某一节点 |
3227e41f4b71Sopenharmony_ci| 'setVolume'      | 设置音量     |
3228e41f4b71Sopenharmony_ci| 'setSpeed'       | 设置播放倍速 |
3229e41f4b71Sopenharmony_ci| 'setLoopMode'    | 设置循环模式 |
3230e41f4b71Sopenharmony_ci| 'toggleFavorite' | 是否收藏     |
3231e41f4b71Sopenharmony_ci| 'toggleMute'     | 设置静音状态 |
3232e41f4b71Sopenharmony_ci
3233e41f4b71Sopenharmony_ci## AVCastControlCommand<sup>10+</sup>
3234e41f4b71Sopenharmony_ci
3235e41f4b71Sopenharmony_ci投播控制器接受的命令的对象描述。
3236e41f4b71Sopenharmony_ci
3237e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
3238e41f4b71Sopenharmony_ci
3239e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.AVCast
3240e41f4b71Sopenharmony_ci
3241e41f4b71Sopenharmony_ci| 名称      | 类型                                              | 必填 | 说明           |
3242e41f4b71Sopenharmony_ci| --------- | ------------------------------------------------- | ---- | -------------- |
3243e41f4b71Sopenharmony_ci| command   | [AVCastControlCommandType](#avcastcontrolcommandtype10)     | 是   | 命令           |
3244e41f4b71Sopenharmony_ci| parameter | [media.PlaybackSpeed](../apis-media-kit/js-apis-media.md#playbackspeed8) &#124; number &#124; string &#124; [LoopMode](#loopmode10) | 否   | 命令对应的参数 |
3245e41f4b71Sopenharmony_ci
3246e41f4b71Sopenharmony_ci## AVCastController<sup>10+</sup>
3247e41f4b71Sopenharmony_ci
3248e41f4b71Sopenharmony_ci在投播建立后,调用[avSession.getAVCastController](#getavcastcontroller10)后,返回会话控制器实例。控制器可查看会话ID,并可完成对会话发送命令及事件,获取会话元数据,播放状态信息等操作。
3249e41f4b71Sopenharmony_ci
3250e41f4b71Sopenharmony_ci### getAVPlaybackState<sup>10+</sup>
3251e41f4b71Sopenharmony_ci
3252e41f4b71Sopenharmony_cigetAVPlaybackState(callback: AsyncCallback\<AVPlaybackState>): void
3253e41f4b71Sopenharmony_ci
3254e41f4b71Sopenharmony_ci获取当前的远端播放状态。结果通过callback异步回调方式返回。
3255e41f4b71Sopenharmony_ci
3256e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.AVCast
3257e41f4b71Sopenharmony_ci
3258e41f4b71Sopenharmony_ci**参数:**
3259e41f4b71Sopenharmony_ci
3260e41f4b71Sopenharmony_ci| 参数名    | 类型                                                        | 必填 | 说明                                                         |
3261e41f4b71Sopenharmony_ci| --------- | ----------------------------------------------------------- | ---- | ------------------------------------------------------------ |
3262e41f4b71Sopenharmony_ci| callback  | AsyncCallback<[AVPlaybackState](#avplaybackstate10)\> | 是   | 回调函数,返回远端播放状态。 |
3263e41f4b71Sopenharmony_ci
3264e41f4b71Sopenharmony_ci**错误码:**
3265e41f4b71Sopenharmony_ci
3266e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
3267e41f4b71Sopenharmony_ci
3268e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
3269e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
3270e41f4b71Sopenharmony_ci| 6600101  | Session service exception |
3271e41f4b71Sopenharmony_ci
3272e41f4b71Sopenharmony_ci**示例:**
3273e41f4b71Sopenharmony_ci
3274e41f4b71Sopenharmony_ci```ts
3275e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
3276e41f4b71Sopenharmony_ci
3277e41f4b71Sopenharmony_ciaVCastController.getAVPlaybackState((err: BusinessError, state: avSession.AVPlaybackState) => {
3278e41f4b71Sopenharmony_ci  if (err) {
3279e41f4b71Sopenharmony_ci    console.error(`getAVPlaybackState BusinessError: code: ${err.code}, message: ${err.message}`);
3280e41f4b71Sopenharmony_ci  } else {
3281e41f4b71Sopenharmony_ci    console.info('getAVPlaybackState : SUCCESS');
3282e41f4b71Sopenharmony_ci  }
3283e41f4b71Sopenharmony_ci});
3284e41f4b71Sopenharmony_ci```
3285e41f4b71Sopenharmony_ci
3286e41f4b71Sopenharmony_ci### getAVPlaybackState<sup>10+</sup>
3287e41f4b71Sopenharmony_ci
3288e41f4b71Sopenharmony_cigetAVPlaybackState(): Promise\<AVPlaybackState>
3289e41f4b71Sopenharmony_ci
3290e41f4b71Sopenharmony_ci获取当前的远端播放状态。结果通过Promise异步回调方式返回。
3291e41f4b71Sopenharmony_ci
3292e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
3293e41f4b71Sopenharmony_ci
3294e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.AVCast
3295e41f4b71Sopenharmony_ci
3296e41f4b71Sopenharmony_ci**返回值:**
3297e41f4b71Sopenharmony_ci
3298e41f4b71Sopenharmony_ci| 类型                                                        | 说明                                                         |
3299e41f4b71Sopenharmony_ci| --------- | ------------------------------------------------------------ |
3300e41f4b71Sopenharmony_ci| Promise<[AVPlaybackState](#avplaybackstate10)\>  | Promise对象。返回远端播放状态。 |
3301e41f4b71Sopenharmony_ci
3302e41f4b71Sopenharmony_ci**错误码:**
3303e41f4b71Sopenharmony_ci
3304e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
3305e41f4b71Sopenharmony_ci
3306e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
3307e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
3308e41f4b71Sopenharmony_ci| 6600101  | Session service exception |
3309e41f4b71Sopenharmony_ci
3310e41f4b71Sopenharmony_ci**示例:**
3311e41f4b71Sopenharmony_ci
3312e41f4b71Sopenharmony_ci```ts
3313e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
3314e41f4b71Sopenharmony_ci
3315e41f4b71Sopenharmony_ciaVCastController.getAVPlaybackState().then((state: avSession.AVPlaybackState) => {
3316e41f4b71Sopenharmony_ci  console.info('getAVPlaybackState : SUCCESS');
3317e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
3318e41f4b71Sopenharmony_ci  console.error(`getAVPlaybackState BusinessError: code: ${err.code}, message: ${err.message}`);
3319e41f4b71Sopenharmony_ci});
3320e41f4b71Sopenharmony_ci```
3321e41f4b71Sopenharmony_ci
3322e41f4b71Sopenharmony_ci### sendControlCommand<sup>10+</sup>
3323e41f4b71Sopenharmony_ci
3324e41f4b71Sopenharmony_cisendControlCommand(command: AVCastControlCommand): Promise\<void>
3325e41f4b71Sopenharmony_ci
3326e41f4b71Sopenharmony_ci通过控制器发送命令到其对应的会话。结果通过Promise异步回调方式返回。
3327e41f4b71Sopenharmony_ci
3328e41f4b71Sopenharmony_ci
3329e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
3330e41f4b71Sopenharmony_ci
3331e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.AVCast
3332e41f4b71Sopenharmony_ci
3333e41f4b71Sopenharmony_ci**参数:**
3334e41f4b71Sopenharmony_ci
3335e41f4b71Sopenharmony_ci| 参数名    | 类型                                  | 必填 | 说明                           |
3336e41f4b71Sopenharmony_ci| ------- | ------------------------------------- | ---- | ------------------------------ |
3337e41f4b71Sopenharmony_ci| command | [AVCastControlCommand](#avcastcontrolcommand10) | 是   | 会话的相关命令和命令相关参数。 |
3338e41f4b71Sopenharmony_ci
3339e41f4b71Sopenharmony_ci**返回值:**
3340e41f4b71Sopenharmony_ci
3341e41f4b71Sopenharmony_ci| 类型           | 说明                          |
3342e41f4b71Sopenharmony_ci| -------------- | ----------------------------- |
3343e41f4b71Sopenharmony_ci| Promise\<void> | Promise对象。当命令发送成功,无返回结果,否则返回错误对象。 |
3344e41f4b71Sopenharmony_ci
3345e41f4b71Sopenharmony_ci**错误码:**
3346e41f4b71Sopenharmony_ci
3347e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
3348e41f4b71Sopenharmony_ci
3349e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
3350e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
3351e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Parameter verification failed. |
3352e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
3353e41f4b71Sopenharmony_ci| 6600105  | Invalid session command. |
3354e41f4b71Sopenharmony_ci| 6600109  | The remote connection is not established. |
3355e41f4b71Sopenharmony_ci
3356e41f4b71Sopenharmony_ci**示例:**
3357e41f4b71Sopenharmony_ci
3358e41f4b71Sopenharmony_ci```ts
3359e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
3360e41f4b71Sopenharmony_ci
3361e41f4b71Sopenharmony_cilet avCommand: avSession.AVCastControlCommand = {command:'play'};
3362e41f4b71Sopenharmony_ciaVCastController.sendControlCommand(avCommand).then(() => {
3363e41f4b71Sopenharmony_ci  console.info('SendControlCommand successfully');
3364e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
3365e41f4b71Sopenharmony_ci  console.error(`SendControlCommand BusinessError: code: ${err.code}, message: ${err.message}`);
3366e41f4b71Sopenharmony_ci});
3367e41f4b71Sopenharmony_ci```
3368e41f4b71Sopenharmony_ci
3369e41f4b71Sopenharmony_ci### sendControlCommand<sup>10+</sup>
3370e41f4b71Sopenharmony_ci
3371e41f4b71Sopenharmony_cisendControlCommand(command: AVCastControlCommand, callback: AsyncCallback\<void>): void
3372e41f4b71Sopenharmony_ci
3373e41f4b71Sopenharmony_ci通过会话控制器发送命令到其对应的会话。结果通过callback异步回调方式返回。
3374e41f4b71Sopenharmony_ci
3375e41f4b71Sopenharmony_ci
3376e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.AVCast
3377e41f4b71Sopenharmony_ci
3378e41f4b71Sopenharmony_ci**参数:**
3379e41f4b71Sopenharmony_ci
3380e41f4b71Sopenharmony_ci| 参数名   | 类型                                  | 必填 | 说明                           |
3381e41f4b71Sopenharmony_ci| -------- | ------------------------------------- | ---- | ------------------------------ |
3382e41f4b71Sopenharmony_ci| command  | [AVCastControlCommand](#avcastcontrolcommand10) | 是   | 会话的相关命令和命令相关参数。 |
3383e41f4b71Sopenharmony_ci| callback | AsyncCallback\<void>                  | 是   | 回调函数。当命令发送成功,err为undefined,否则返回错误对象。                     |
3384e41f4b71Sopenharmony_ci
3385e41f4b71Sopenharmony_ci**错误码:**
3386e41f4b71Sopenharmony_ci
3387e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
3388e41f4b71Sopenharmony_ci
3389e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
3390e41f4b71Sopenharmony_ci| -------- | ------------------------------- |
3391e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Parameter verification failed. |
3392e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
3393e41f4b71Sopenharmony_ci| 6600105  | Invalid session command. |
3394e41f4b71Sopenharmony_ci| 6600109  | The remote connection is not established. |
3395e41f4b71Sopenharmony_ci
3396e41f4b71Sopenharmony_ci**示例:**
3397e41f4b71Sopenharmony_ci
3398e41f4b71Sopenharmony_ci```ts
3399e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
3400e41f4b71Sopenharmony_ci
3401e41f4b71Sopenharmony_cilet avCommand: avSession.AVCastControlCommand = {command:'play'};
3402e41f4b71Sopenharmony_ciaVCastController.sendControlCommand(avCommand, (err: BusinessError) => {
3403e41f4b71Sopenharmony_ci  if (err) {
3404e41f4b71Sopenharmony_ci    console.error(`SendControlCommand BusinessError: code: ${err.code}, message: ${err.message}`);
3405e41f4b71Sopenharmony_ci  } else {
3406e41f4b71Sopenharmony_ci    console.info('SendControlCommand successfully');
3407e41f4b71Sopenharmony_ci  }
3408e41f4b71Sopenharmony_ci});
3409e41f4b71Sopenharmony_ci```
3410e41f4b71Sopenharmony_ci
3411e41f4b71Sopenharmony_ci### prepare<sup>10+</sup>
3412e41f4b71Sopenharmony_ci
3413e41f4b71Sopenharmony_ciprepare(item: AVQueueItem, callback: AsyncCallback\<void>): void
3414e41f4b71Sopenharmony_ci
3415e41f4b71Sopenharmony_ci准备播放媒体资源,即进行播放资源的加载和缓冲。结果通过callback异步回调方式返回。
3416e41f4b71Sopenharmony_ci
3417e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.AVCast
3418e41f4b71Sopenharmony_ci
3419e41f4b71Sopenharmony_ci**参数:**
3420e41f4b71Sopenharmony_ci
3421e41f4b71Sopenharmony_ci| 参数名    | 类型                                  | 必填 | 说明                           |
3422e41f4b71Sopenharmony_ci| ------- | ------------------------------------- | ---- | ------------------------------ |
3423e41f4b71Sopenharmony_ci| item | [AVQueueItem](#avqueueitem10) | 是   | 播放列表中单项的相关属性。 |
3424e41f4b71Sopenharmony_ci| callback | AsyncCallback\<void>                  | 是   | 回调函数。当命令发送成功,err为undefined,否则返回错误对象。 |   
3425e41f4b71Sopenharmony_ci
3426e41f4b71Sopenharmony_ci**错误码:**
3427e41f4b71Sopenharmony_ci
3428e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
3429e41f4b71Sopenharmony_ci
3430e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
3431e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
3432e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Parameter verification failed. |
3433e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
3434e41f4b71Sopenharmony_ci| 6600109  | The remote connection is not established. |
3435e41f4b71Sopenharmony_ci
3436e41f4b71Sopenharmony_ci**示例:**
3437e41f4b71Sopenharmony_ci
3438e41f4b71Sopenharmony_ci```ts
3439e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
3440e41f4b71Sopenharmony_ci
3441e41f4b71Sopenharmony_ci// 设置播放参数,开始播放
3442e41f4b71Sopenharmony_cilet playItem: avSession.AVQueueItem = {
3443e41f4b71Sopenharmony_ci  itemId: 0,
3444e41f4b71Sopenharmony_ci  description: {
3445e41f4b71Sopenharmony_ci    assetId: '12345',
3446e41f4b71Sopenharmony_ci    mediaType: 'AUDIO',
3447e41f4b71Sopenharmony_ci    mediaUri: 'http://resource1_address',
3448e41f4b71Sopenharmony_ci    mediaSize: 12345,
3449e41f4b71Sopenharmony_ci    startPosition: 0,
3450e41f4b71Sopenharmony_ci    duration: 0,
3451e41f4b71Sopenharmony_ci    artist: 'mysong',
3452e41f4b71Sopenharmony_ci    albumTitle: 'song1_title',
3453e41f4b71Sopenharmony_ci    albumCoverUri: "http://resource1_album_address",
3454e41f4b71Sopenharmony_ci    lyricUri: "http://resource1_lyric_address",
3455e41f4b71Sopenharmony_ci    appName: 'MyMusic'
3456e41f4b71Sopenharmony_ci  }
3457e41f4b71Sopenharmony_ci};
3458e41f4b71Sopenharmony_ci// 准备播放,这个不会触发真正的播放,会进行加载和缓冲
3459e41f4b71Sopenharmony_ciaVCastController.prepare(playItem, (err: BusinessError) => {
3460e41f4b71Sopenharmony_ci  if (err) {
3461e41f4b71Sopenharmony_ci    console.error(`prepare BusinessError: code: ${err.code}, message: ${err.message}`);
3462e41f4b71Sopenharmony_ci  } else {
3463e41f4b71Sopenharmony_ci    console.info('prepare successfully');
3464e41f4b71Sopenharmony_ci  }
3465e41f4b71Sopenharmony_ci});
3466e41f4b71Sopenharmony_ci```
3467e41f4b71Sopenharmony_ci
3468e41f4b71Sopenharmony_ci
3469e41f4b71Sopenharmony_ci### prepare<sup>10+</sup>
3470e41f4b71Sopenharmony_ci
3471e41f4b71Sopenharmony_ciprepare(item: AVQueueItem): Promise\<void>
3472e41f4b71Sopenharmony_ci
3473e41f4b71Sopenharmony_ci准备播放媒体资源,即进行播放资源的加载和缓冲。结果通过Promise异步回调方式返回。
3474e41f4b71Sopenharmony_ci
3475e41f4b71Sopenharmony_ci
3476e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
3477e41f4b71Sopenharmony_ci
3478e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.AVCast
3479e41f4b71Sopenharmony_ci
3480e41f4b71Sopenharmony_ci**参数:**
3481e41f4b71Sopenharmony_ci
3482e41f4b71Sopenharmony_ci| 参数名    | 类型                                  | 必填 | 说明                           |
3483e41f4b71Sopenharmony_ci| ------- | ------------------------------------- | ---- | ------------------------------ |
3484e41f4b71Sopenharmony_ci| item | [AVQueueItem](#avqueueitem10) | 是   | 播放列表中单项的相关属性。 |
3485e41f4b71Sopenharmony_ci
3486e41f4b71Sopenharmony_ci**返回值:**
3487e41f4b71Sopenharmony_ci
3488e41f4b71Sopenharmony_ci| 类型           | 说明                          |
3489e41f4b71Sopenharmony_ci| -------------- | ----------------------------- |
3490e41f4b71Sopenharmony_ci| Promise\<void> | Promise对象。当命令发送成功,无返回结果,否则返回错误对象。 |
3491e41f4b71Sopenharmony_ci
3492e41f4b71Sopenharmony_ci**错误码:**
3493e41f4b71Sopenharmony_ci
3494e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
3495e41f4b71Sopenharmony_ci
3496e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
3497e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
3498e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Parameter verification failed. |
3499e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
3500e41f4b71Sopenharmony_ci| 6600109  | The remote connection is not established. |
3501e41f4b71Sopenharmony_ci
3502e41f4b71Sopenharmony_ci
3503e41f4b71Sopenharmony_ci**示例:**
3504e41f4b71Sopenharmony_ci
3505e41f4b71Sopenharmony_ci```ts
3506e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
3507e41f4b71Sopenharmony_ci
3508e41f4b71Sopenharmony_ci// 设置播放参数,开始播放
3509e41f4b71Sopenharmony_cilet playItem: avSession.AVQueueItem = {
3510e41f4b71Sopenharmony_ci  itemId: 0,
3511e41f4b71Sopenharmony_ci  description: {
3512e41f4b71Sopenharmony_ci    assetId: '12345',
3513e41f4b71Sopenharmony_ci    mediaType: 'AUDIO',
3514e41f4b71Sopenharmony_ci    mediaUri: 'http://resource1_address',
3515e41f4b71Sopenharmony_ci    mediaSize: 12345,
3516e41f4b71Sopenharmony_ci    startPosition: 0,
3517e41f4b71Sopenharmony_ci    duration: 0,
3518e41f4b71Sopenharmony_ci    artist: 'mysong',
3519e41f4b71Sopenharmony_ci    albumTitle: 'song1_title',
3520e41f4b71Sopenharmony_ci    albumCoverUri: "http://resource1_album_address",
3521e41f4b71Sopenharmony_ci    lyricUri: "http://resource1_lyric_address",
3522e41f4b71Sopenharmony_ci    appName: 'MyMusic'
3523e41f4b71Sopenharmony_ci  }
3524e41f4b71Sopenharmony_ci};
3525e41f4b71Sopenharmony_ci// 准备播放,这个不会触发真正的播放,会进行加载和缓冲
3526e41f4b71Sopenharmony_ciaVCastController.prepare(playItem).then(() => {
3527e41f4b71Sopenharmony_ci  console.info('prepare successfully');
3528e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
3529e41f4b71Sopenharmony_ci  console.error(`prepare BusinessError: code: ${err.code}, message: ${err.message}`);
3530e41f4b71Sopenharmony_ci});
3531e41f4b71Sopenharmony_ci```
3532e41f4b71Sopenharmony_ci
3533e41f4b71Sopenharmony_ci### start<sup>10+</sup>
3534e41f4b71Sopenharmony_ci
3535e41f4b71Sopenharmony_cistart(item: AVQueueItem, callback: AsyncCallback\<void>): void
3536e41f4b71Sopenharmony_ci
3537e41f4b71Sopenharmony_ci启动播放某个媒体资源。结果通过callback异步回调方式返回。
3538e41f4b71Sopenharmony_ci
3539e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.AVCast
3540e41f4b71Sopenharmony_ci
3541e41f4b71Sopenharmony_ci**参数:**
3542e41f4b71Sopenharmony_ci
3543e41f4b71Sopenharmony_ci| 参数名    | 类型                                  | 必填 | 说明                           |
3544e41f4b71Sopenharmony_ci| ------- | ------------------------------------- | ---- | ------------------------------ |
3545e41f4b71Sopenharmony_ci| item | [AVQueueItem](#avqueueitem10) | 是   | 播放列表中单项的相关属性。 |
3546e41f4b71Sopenharmony_ci| callback | AsyncCallback\<void>                  | 是   | 回调函数。当命令发送成功,err为undefined,否则返回错误对象。 |   
3547e41f4b71Sopenharmony_ci
3548e41f4b71Sopenharmony_ci**错误码:**
3549e41f4b71Sopenharmony_ci
3550e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
3551e41f4b71Sopenharmony_ci
3552e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
3553e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
3554e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Parameter verification failed. |
3555e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
3556e41f4b71Sopenharmony_ci| 6600109  | The remote connection is not established. |
3557e41f4b71Sopenharmony_ci
3558e41f4b71Sopenharmony_ci**示例:**
3559e41f4b71Sopenharmony_ci
3560e41f4b71Sopenharmony_ci```ts
3561e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
3562e41f4b71Sopenharmony_ci
3563e41f4b71Sopenharmony_ci// 设置播放参数,开始播放
3564e41f4b71Sopenharmony_cilet playItem: avSession.AVQueueItem = {
3565e41f4b71Sopenharmony_ci  itemId: 0,
3566e41f4b71Sopenharmony_ci  description: {
3567e41f4b71Sopenharmony_ci    assetId: '12345',
3568e41f4b71Sopenharmony_ci    mediaType: 'AUDIO',
3569e41f4b71Sopenharmony_ci    mediaUri: 'http://resource1_address',
3570e41f4b71Sopenharmony_ci    mediaSize: 12345,
3571e41f4b71Sopenharmony_ci    startPosition: 0,
3572e41f4b71Sopenharmony_ci    duration: 0,
3573e41f4b71Sopenharmony_ci    artist: 'mysong',
3574e41f4b71Sopenharmony_ci    albumTitle: 'song1_title',
3575e41f4b71Sopenharmony_ci    albumCoverUri: "http://resource1_album_address",
3576e41f4b71Sopenharmony_ci    lyricUri: "http://resource1_lyric_address",
3577e41f4b71Sopenharmony_ci    appName: 'MyMusic'
3578e41f4b71Sopenharmony_ci  }
3579e41f4b71Sopenharmony_ci};
3580e41f4b71Sopenharmony_ci
3581e41f4b71Sopenharmony_ci// 启动播放
3582e41f4b71Sopenharmony_ciaVCastController.start(playItem, (err: BusinessError) => {
3583e41f4b71Sopenharmony_ci  if (err) {
3584e41f4b71Sopenharmony_ci    console.error(`start BusinessError: code: ${err.code}, message: ${err.message}`);
3585e41f4b71Sopenharmony_ci  } else {
3586e41f4b71Sopenharmony_ci    console.info('start successfully');
3587e41f4b71Sopenharmony_ci  }
3588e41f4b71Sopenharmony_ci});
3589e41f4b71Sopenharmony_ci```
3590e41f4b71Sopenharmony_ci
3591e41f4b71Sopenharmony_ci### start<sup>10+</sup>
3592e41f4b71Sopenharmony_ci
3593e41f4b71Sopenharmony_cistart(item: AVQueueItem): Promise\<void>
3594e41f4b71Sopenharmony_ci
3595e41f4b71Sopenharmony_ci启动播放某个媒体资源。结果通过Promise异步回调方式返回。
3596e41f4b71Sopenharmony_ci
3597e41f4b71Sopenharmony_ci
3598e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
3599e41f4b71Sopenharmony_ci
3600e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.AVCast
3601e41f4b71Sopenharmony_ci
3602e41f4b71Sopenharmony_ci**参数:**
3603e41f4b71Sopenharmony_ci
3604e41f4b71Sopenharmony_ci| 参数名    | 类型                                  | 必填 | 说明                           |
3605e41f4b71Sopenharmony_ci| ------- | ------------------------------------- | ---- | ------------------------------ |
3606e41f4b71Sopenharmony_ci| item | [AVQueueItem](#avqueueitem10) | 是   | 播放列表中单项的相关属性。 |
3607e41f4b71Sopenharmony_ci
3608e41f4b71Sopenharmony_ci**返回值:**
3609e41f4b71Sopenharmony_ci
3610e41f4b71Sopenharmony_ci| 类型           | 说明                          |
3611e41f4b71Sopenharmony_ci| -------------- | ----------------------------- |
3612e41f4b71Sopenharmony_ci| Promise\<void> | Promise对象。当命令发送成功,无返回结果,否则返回错误对象。 |
3613e41f4b71Sopenharmony_ci
3614e41f4b71Sopenharmony_ci**错误码:**
3615e41f4b71Sopenharmony_ci
3616e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
3617e41f4b71Sopenharmony_ci
3618e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
3619e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
3620e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Parameter verification failed. |
3621e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
3622e41f4b71Sopenharmony_ci| 6600109  | The remote connection is not established. |
3623e41f4b71Sopenharmony_ci
3624e41f4b71Sopenharmony_ci
3625e41f4b71Sopenharmony_ci**示例:**
3626e41f4b71Sopenharmony_ci
3627e41f4b71Sopenharmony_ci```ts
3628e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
3629e41f4b71Sopenharmony_ci
3630e41f4b71Sopenharmony_ci// 设置播放参数,开始播放
3631e41f4b71Sopenharmony_cilet playItem: avSession.AVQueueItem = {
3632e41f4b71Sopenharmony_ci  itemId: 0,
3633e41f4b71Sopenharmony_ci  description: {
3634e41f4b71Sopenharmony_ci    assetId: '12345',
3635e41f4b71Sopenharmony_ci    mediaType: 'AUDIO',
3636e41f4b71Sopenharmony_ci    mediaUri: 'http://resource1_address',
3637e41f4b71Sopenharmony_ci    mediaSize: 12345,
3638e41f4b71Sopenharmony_ci    startPosition: 0,
3639e41f4b71Sopenharmony_ci    duration: 0,
3640e41f4b71Sopenharmony_ci    artist: 'mysong',
3641e41f4b71Sopenharmony_ci    albumTitle: 'song1_title',
3642e41f4b71Sopenharmony_ci    albumCoverUri: "http://resource1_album_address",
3643e41f4b71Sopenharmony_ci    lyricUri: "http://resource1_lyric_address",
3644e41f4b71Sopenharmony_ci    appName: 'MyMusic'
3645e41f4b71Sopenharmony_ci  }
3646e41f4b71Sopenharmony_ci};
3647e41f4b71Sopenharmony_ci// 启动播放
3648e41f4b71Sopenharmony_ciaVCastController.start(playItem).then(() => {
3649e41f4b71Sopenharmony_ci  console.info('start successfully');
3650e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
3651e41f4b71Sopenharmony_ci  console.error(`start BusinessError: code: ${err.code}, message: ${err.message}`);
3652e41f4b71Sopenharmony_ci});
3653e41f4b71Sopenharmony_ci```
3654e41f4b71Sopenharmony_ci
3655e41f4b71Sopenharmony_ci### getCurrentItem<sup>10+</sup>
3656e41f4b71Sopenharmony_ci
3657e41f4b71Sopenharmony_cigetCurrentItem(callback: AsyncCallback\<AVQueueItem>): void
3658e41f4b71Sopenharmony_ci
3659e41f4b71Sopenharmony_ci获取当前投播的资源信息。结果通过callback异步回调方式返回。
3660e41f4b71Sopenharmony_ci
3661e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.AVCast
3662e41f4b71Sopenharmony_ci
3663e41f4b71Sopenharmony_ci**参数:**
3664e41f4b71Sopenharmony_ci
3665e41f4b71Sopenharmony_ci| 参数名   | 类型                                  | 必填 | 说明                                  |
3666e41f4b71Sopenharmony_ci| -------- | ------------------------------------- | ---- | ------------------------------------- |
3667e41f4b71Sopenharmony_ci| callback | AsyncCallback\<[AVQueueItem](#avqueueitem10)>                  | 是   | 回调函数。当命令发送成功,err为undefined,否则返回错误对象。 |
3668e41f4b71Sopenharmony_ci
3669e41f4b71Sopenharmony_ci**错误码:**
3670e41f4b71Sopenharmony_ci
3671e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
3672e41f4b71Sopenharmony_ci
3673e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
3674e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
3675e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
3676e41f4b71Sopenharmony_ci
3677e41f4b71Sopenharmony_ci**示例:**
3678e41f4b71Sopenharmony_ci
3679e41f4b71Sopenharmony_ci```ts
3680e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
3681e41f4b71Sopenharmony_ci
3682e41f4b71Sopenharmony_ciaVCastController.getCurrentItem((err: BusinessError, value: avSession.AVQueueItem) => {
3683e41f4b71Sopenharmony_ci  if (err) {
3684e41f4b71Sopenharmony_ci    console.error(`getCurrentItem BusinessError: code: ${err.code}, message: ${err.message}`);
3685e41f4b71Sopenharmony_ci  } else {
3686e41f4b71Sopenharmony_ci    console.info('getCurrentItem successfully');
3687e41f4b71Sopenharmony_ci  }
3688e41f4b71Sopenharmony_ci});
3689e41f4b71Sopenharmony_ci```
3690e41f4b71Sopenharmony_ci
3691e41f4b71Sopenharmony_ci### getCurrentItem<sup>10+</sup>
3692e41f4b71Sopenharmony_ci
3693e41f4b71Sopenharmony_cigetCurrentItem(): Promise\<AVQueueItem>
3694e41f4b71Sopenharmony_ci
3695e41f4b71Sopenharmony_ci获取当前投播的资源信息。结果通过Promise异步回调方式返回。
3696e41f4b71Sopenharmony_ci
3697e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
3698e41f4b71Sopenharmony_ci
3699e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.AVCast
3700e41f4b71Sopenharmony_ci
3701e41f4b71Sopenharmony_ci**返回值:**
3702e41f4b71Sopenharmony_ci
3703e41f4b71Sopenharmony_ci| 类型           | 说明                          |
3704e41f4b71Sopenharmony_ci| -------------- | ----------------------------- |
3705e41f4b71Sopenharmony_ci| Promise\<[AVQueueItem](#avqueueitem10)> | Promise对象,返回当前的播放资源,否则返回错误对象。 |
3706e41f4b71Sopenharmony_ci
3707e41f4b71Sopenharmony_ci**错误码:**
3708e41f4b71Sopenharmony_ci
3709e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
3710e41f4b71Sopenharmony_ci
3711e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
3712e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
3713e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
3714e41f4b71Sopenharmony_ci
3715e41f4b71Sopenharmony_ci**示例:**
3716e41f4b71Sopenharmony_ci
3717e41f4b71Sopenharmony_ci```ts
3718e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
3719e41f4b71Sopenharmony_ci
3720e41f4b71Sopenharmony_ciaVCastController.getCurrentItem().then((value: avSession.AVQueueItem) => {
3721e41f4b71Sopenharmony_ci  console.info('getCurrentItem successfully');
3722e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
3723e41f4b71Sopenharmony_ci  console.error(`getCurrentItem BusinessError: code: ${err.code}, message: ${err.message}`);
3724e41f4b71Sopenharmony_ci});
3725e41f4b71Sopenharmony_ci```
3726e41f4b71Sopenharmony_ci
3727e41f4b71Sopenharmony_ci### getValidCommands<sup>11+</sup>
3728e41f4b71Sopenharmony_ci
3729e41f4b71Sopenharmony_cigetValidCommands(callback: AsyncCallback<Array\<AVCastControlCommandType>>): void
3730e41f4b71Sopenharmony_ci
3731e41f4b71Sopenharmony_ci获取当前支持的命令。结果通过callback异步回调方式返回。
3732e41f4b71Sopenharmony_ci
3733e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.AVCast
3734e41f4b71Sopenharmony_ci
3735e41f4b71Sopenharmony_ci**参数:**
3736e41f4b71Sopenharmony_ci
3737e41f4b71Sopenharmony_ci| 参数名 | 类型 | 必填 | 说明 |
3738e41f4b71Sopenharmony_ci| -------- | ------------------------------------- | ---- | ------------------------------------- |
3739e41f4b71Sopenharmony_ci| callback | Array<[AVCastControlCommandType](#avcastcontrolcommandtype10)> | 是 | 回调函数。返回当前支持的命令。 |
3740e41f4b71Sopenharmony_ci
3741e41f4b71Sopenharmony_ci**错误码:**
3742e41f4b71Sopenharmony_ci
3743e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
3744e41f4b71Sopenharmony_ci
3745e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
3746e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
3747e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
3748e41f4b71Sopenharmony_ci
3749e41f4b71Sopenharmony_ci**示例:**
3750e41f4b71Sopenharmony_ci
3751e41f4b71Sopenharmony_ci```ts
3752e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
3753e41f4b71Sopenharmony_ci
3754e41f4b71Sopenharmony_ciaVCastController.getValidCommands((err: BusinessError, state: avSession.AVCastControlCommandType) => {
3755e41f4b71Sopenharmony_ci  if (err) {
3756e41f4b71Sopenharmony_ci    console.error(`getValidCommands BusinessError: code: ${err.code}, message: ${err.message}`);
3757e41f4b71Sopenharmony_ci  } else {
3758e41f4b71Sopenharmony_ci    console.info('getValidCommands successfully');
3759e41f4b71Sopenharmony_ci  }
3760e41f4b71Sopenharmony_ci});
3761e41f4b71Sopenharmony_ci```
3762e41f4b71Sopenharmony_ci
3763e41f4b71Sopenharmony_ci### getValidCommands<sup>11+</sup>
3764e41f4b71Sopenharmony_ci
3765e41f4b71Sopenharmony_cigetValidCommands(): Promise<Array\<AVCastControlCommandType>>
3766e41f4b71Sopenharmony_ci
3767e41f4b71Sopenharmony_ci获取当前支持的命令。结果通过Promise异步回调方式返回。
3768e41f4b71Sopenharmony_ci
3769e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.AVCast
3770e41f4b71Sopenharmony_ci
3771e41f4b71Sopenharmony_ci**返回值:**
3772e41f4b71Sopenharmony_ci
3773e41f4b71Sopenharmony_ci| 类型 | 说明 |
3774e41f4b71Sopenharmony_ci| -------------- | ----------------------------- |
3775e41f4b71Sopenharmony_ci| Promise<Array\<[AVCastControlCommandType](#avcastcontrolcommandtype10)>> | Promise对象,返回当前支持的命令。 |
3776e41f4b71Sopenharmony_ci
3777e41f4b71Sopenharmony_ci**错误码:**
3778e41f4b71Sopenharmony_ci
3779e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
3780e41f4b71Sopenharmony_ci
3781e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
3782e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
3783e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
3784e41f4b71Sopenharmony_ci
3785e41f4b71Sopenharmony_ci**示例:**
3786e41f4b71Sopenharmony_ci
3787e41f4b71Sopenharmony_ci```ts
3788e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
3789e41f4b71Sopenharmony_ci
3790e41f4b71Sopenharmony_ciaVCastController.getValidCommands().then((state: avSession.AVCastControlCommandType) => {
3791e41f4b71Sopenharmony_ci  console.info('getValidCommands successfully');
3792e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
3793e41f4b71Sopenharmony_ci  console.error(`getValidCommands BusinessError: code: ${err.code}, message: ${err.message}`);
3794e41f4b71Sopenharmony_ci});
3795e41f4b71Sopenharmony_ci```
3796e41f4b71Sopenharmony_ci
3797e41f4b71Sopenharmony_ci### processMediaKeyResponse<sup>12+</sup>
3798e41f4b71Sopenharmony_ci
3799e41f4b71Sopenharmony_ciprocessMediaKeyResponse(assetId: string, response: Uint8Array): Promise\<void>
3800e41f4b71Sopenharmony_ci
3801e41f4b71Sopenharmony_ci在线DRM资源投播时,处理许可证响应。结果通过Promise异步回调方式返回。
3802e41f4b71Sopenharmony_ci
3803e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
3804e41f4b71Sopenharmony_ci
3805e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.AVCast
3806e41f4b71Sopenharmony_ci
3807e41f4b71Sopenharmony_ci**参数:**
3808e41f4b71Sopenharmony_ci
3809e41f4b71Sopenharmony_ci| 参数名   | 类型                                  | 必填 | 说明                                  |
3810e41f4b71Sopenharmony_ci| -------- | ------------------------------------- | ---- | ------------------------------------- |
3811e41f4b71Sopenharmony_ci| assetId | string                  | 是   | 媒体ID。 |
3812e41f4b71Sopenharmony_ci| response | Uint8Array             | 是   | 许可证响应。 |
3813e41f4b71Sopenharmony_ci
3814e41f4b71Sopenharmony_ci**返回值:**
3815e41f4b71Sopenharmony_ci
3816e41f4b71Sopenharmony_ci| 类型           | 说明                          |
3817e41f4b71Sopenharmony_ci| -------------- | ----------------------------- |
3818e41f4b71Sopenharmony_ci| Promise\<void> | Promise对象,当处理许可证响应成功,无返回结果,否则返回错误对象。 |
3819e41f4b71Sopenharmony_ci
3820e41f4b71Sopenharmony_ci**错误码:**
3821e41f4b71Sopenharmony_ci
3822e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
3823e41f4b71Sopenharmony_ci
3824e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
3825e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
3826e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Parameter verification failed. |
3827e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
3828e41f4b71Sopenharmony_ci
3829e41f4b71Sopenharmony_ci**示例:**
3830e41f4b71Sopenharmony_ci
3831e41f4b71Sopenharmony_ci```ts
3832e41f4b71Sopenharmony_cilet keyRequestCallback: avSession.KeyRequestCallback = async(assetId: string, requestData: Uint8Array) => {
3833e41f4b71Sopenharmony_ci  // 根据assetId获取对应的DRM url
3834e41f4b71Sopenharmony_ci  let drmUrl = 'http://license.xxx.xxx.com:8080/drmproxy/getLicense';
3835e41f4b71Sopenharmony_ci  // 从服务器获取许可证,需要开发者根据实际情况进行赋值
3836e41f4b71Sopenharmony_ci  let licenseResponseData: Uint8Array = new Uint8Array();
3837e41f4b71Sopenharmony_ci  console.info(`Succeeded in get license by ${drmUrl}.`);
3838e41f4b71Sopenharmony_ci  aVCastController.processMediaKeyResponse(assetId, licenseResponseData);
3839e41f4b71Sopenharmony_ci}
3840e41f4b71Sopenharmony_ci```
3841e41f4b71Sopenharmony_ci
3842e41f4b71Sopenharmony_ci### release<sup>11+</sup>
3843e41f4b71Sopenharmony_ci
3844e41f4b71Sopenharmony_cirelease(callback: AsyncCallback\<void>): void
3845e41f4b71Sopenharmony_ci
3846e41f4b71Sopenharmony_ci销毁当前controller,结果通过callback异步回调方式返回。
3847e41f4b71Sopenharmony_ci
3848e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.AVCast
3849e41f4b71Sopenharmony_ci
3850e41f4b71Sopenharmony_ci**参数:**
3851e41f4b71Sopenharmony_ci
3852e41f4b71Sopenharmony_ci| 参数名   | 类型                       | 必填 | 说明                                                         |
3853e41f4b71Sopenharmony_ci| -------- | -------------------------- | ---- | ------------------------------------------------------------ |
3854e41f4b71Sopenharmony_ci| callback | AsyncCallback\<void>       | 是   | 回调函数。当命令执行成功,err为undefined,否则返回错误对象。 |
3855e41f4b71Sopenharmony_ci
3856e41f4b71Sopenharmony_ci**错误码:**
3857e41f4b71Sopenharmony_ci
3858e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
3859e41f4b71Sopenharmony_ci
3860e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
3861e41f4b71Sopenharmony_ci| -------- | -------------------------- |
3862e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
3863e41f4b71Sopenharmony_ci
3864e41f4b71Sopenharmony_ci**示例:**
3865e41f4b71Sopenharmony_ci
3866e41f4b71Sopenharmony_ci```ts
3867e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
3868e41f4b71Sopenharmony_ci
3869e41f4b71Sopenharmony_ciaVCastController.release((err: BusinessError) => {
3870e41f4b71Sopenharmony_ci  if (err) {
3871e41f4b71Sopenharmony_ci    console.error(`release BusinessError: code: ${err.code}, message: ${err.message}`);
3872e41f4b71Sopenharmony_ci  } else {
3873e41f4b71Sopenharmony_ci    console.info('release successfully');
3874e41f4b71Sopenharmony_ci  }
3875e41f4b71Sopenharmony_ci});
3876e41f4b71Sopenharmony_ci```
3877e41f4b71Sopenharmony_ci
3878e41f4b71Sopenharmony_ci### release<sup>11+</sup>
3879e41f4b71Sopenharmony_ci
3880e41f4b71Sopenharmony_cirelease(): Promise\<void>
3881e41f4b71Sopenharmony_ci
3882e41f4b71Sopenharmony_ci销毁当前controller。结果通过Promise异步回调方式返回。
3883e41f4b71Sopenharmony_ci
3884e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
3885e41f4b71Sopenharmony_ci
3886e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.AVCast
3887e41f4b71Sopenharmony_ci
3888e41f4b71Sopenharmony_ci**返回值:**
3889e41f4b71Sopenharmony_ci
3890e41f4b71Sopenharmony_ci| 类型           | 说明                          |
3891e41f4b71Sopenharmony_ci| -------------- | ----------------------------- |
3892e41f4b71Sopenharmony_ci| Promise\<void> | Promise对象,controller销毁成功,无结果返回,否则返回错误对象。 |
3893e41f4b71Sopenharmony_ci
3894e41f4b71Sopenharmony_ci**错误码:**
3895e41f4b71Sopenharmony_ci
3896e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
3897e41f4b71Sopenharmony_ci
3898e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
3899e41f4b71Sopenharmony_ci| -------- | ------------------------------ |
3900e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
3901e41f4b71Sopenharmony_ci
3902e41f4b71Sopenharmony_ci**示例:**
3903e41f4b71Sopenharmony_ci
3904e41f4b71Sopenharmony_ci```ts
3905e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
3906e41f4b71Sopenharmony_ci
3907e41f4b71Sopenharmony_ciaVCastController.release().then(() => {
3908e41f4b71Sopenharmony_ci  console.info('release successfully');
3909e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
3910e41f4b71Sopenharmony_ci  console.error(`release BusinessError: code: ${err.code}, message: ${err.message}`);
3911e41f4b71Sopenharmony_ci});
3912e41f4b71Sopenharmony_ci
3913e41f4b71Sopenharmony_ci```
3914e41f4b71Sopenharmony_ci
3915e41f4b71Sopenharmony_ci### on('playbackStateChange')<sup>10+</sup>
3916e41f4b71Sopenharmony_ci
3917e41f4b71Sopenharmony_cion(type: 'playbackStateChange', filter: Array\<keyof AVPlaybackState> | 'all', callback: (state: AVPlaybackState) => void): void
3918e41f4b71Sopenharmony_ci
3919e41f4b71Sopenharmony_ci设置播放状态变化的监听事件。
3920e41f4b71Sopenharmony_ci
3921e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
3922e41f4b71Sopenharmony_ci
3923e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.AVCast
3924e41f4b71Sopenharmony_ci
3925e41f4b71Sopenharmony_ci**参数:**
3926e41f4b71Sopenharmony_ci
3927e41f4b71Sopenharmony_ci| 参数名   | 类型                                                         | 必填 | 说明                                                         |
3928e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
3929e41f4b71Sopenharmony_ci| type     | string                                                       | 是   | 事件回调类型,支持事件`'playbackStateChange'`:当播放状态变化时,触发该事件。 |
3930e41f4b71Sopenharmony_ci| filter   | Array\<keyof&nbsp;[AVPlaybackState](#avplaybackstate10)\>&nbsp;&#124;&nbsp;'all' | 是   | 'all' 表示关注播放状态所有字段变化;Array<keyof&nbsp;[AVPlaybackState](#avplaybackstate10)\> 表示关注Array中的字段变化。 |
3931e41f4b71Sopenharmony_ci| callback | (state: [AVPlaybackState](#avplaybackstate10)) => void         | 是   | 回调函数,参数state是变化后的播放状态。                      |
3932e41f4b71Sopenharmony_ci
3933e41f4b71Sopenharmony_ci**错误码:**
3934e41f4b71Sopenharmony_ci
3935e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
3936e41f4b71Sopenharmony_ci
3937e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
3938e41f4b71Sopenharmony_ci| -------- | ------------------------------ |
3939e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
3940e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
3941e41f4b71Sopenharmony_ci
3942e41f4b71Sopenharmony_ci**示例:**
3943e41f4b71Sopenharmony_ci
3944e41f4b71Sopenharmony_ci```ts
3945e41f4b71Sopenharmony_ciaVCastController.on('playbackStateChange', 'all', (playbackState: avSession.AVPlaybackState) => {
3946e41f4b71Sopenharmony_ci  console.info(`on playbackStateChange state : ${playbackState.state}`);
3947e41f4b71Sopenharmony_ci});
3948e41f4b71Sopenharmony_ci
3949e41f4b71Sopenharmony_cilet playbackFilter: Array<keyof avSession.AVPlaybackState> = ['state', 'speed', 'loopMode'];
3950e41f4b71Sopenharmony_ciaVCastController.on('playbackStateChange', playbackFilter, (playbackState: avSession.AVPlaybackState) => {
3951e41f4b71Sopenharmony_ci  console.info(`on playbackStateChange state : ${playbackState.state}`);
3952e41f4b71Sopenharmony_ci});
3953e41f4b71Sopenharmony_ci```
3954e41f4b71Sopenharmony_ci
3955e41f4b71Sopenharmony_ci### off('playbackStateChange')<sup>10+</sup>
3956e41f4b71Sopenharmony_ci
3957e41f4b71Sopenharmony_cioff(type: 'playbackStateChange', callback?: (state: AVPlaybackState) => void): void
3958e41f4b71Sopenharmony_ci
3959e41f4b71Sopenharmony_ci媒体控制器取消监听播放状态变化的事件。
3960e41f4b71Sopenharmony_ci
3961e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
3962e41f4b71Sopenharmony_ci
3963e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.AVCast
3964e41f4b71Sopenharmony_ci
3965e41f4b71Sopenharmony_ci**参数:**
3966e41f4b71Sopenharmony_ci
3967e41f4b71Sopenharmony_ci| 参数名   | 类型                                                         | 必填 | 说明                                                     |
3968e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | ---- | ----------------------------------------------------- |
3969e41f4b71Sopenharmony_ci| type     | string                                                       | 是   | 取消对应的监听事件,支持事件`'playbackStateChange'`。    |
3970e41f4b71Sopenharmony_ci| callback | (state: [AVPlaybackState](#avplaybackstate10)) => void         | 否   | 回调函数,参数state是变化后的播放状态。<br>该参数为可选参数,若不填写该参数,则认为取消所有相关会话的事件监听。                      |
3971e41f4b71Sopenharmony_ci
3972e41f4b71Sopenharmony_ci**错误码:**
3973e41f4b71Sopenharmony_ci
3974e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
3975e41f4b71Sopenharmony_ci
3976e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
3977e41f4b71Sopenharmony_ci| -------- | ---------------- |
3978e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
3979e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
3980e41f4b71Sopenharmony_ci
3981e41f4b71Sopenharmony_ci**示例:**
3982e41f4b71Sopenharmony_ci
3983e41f4b71Sopenharmony_ci```ts
3984e41f4b71Sopenharmony_ciaVCastController.off('playbackStateChange');
3985e41f4b71Sopenharmony_ci```
3986e41f4b71Sopenharmony_ci
3987e41f4b71Sopenharmony_ci### on('mediaItemChange')<sup>10+</sup>
3988e41f4b71Sopenharmony_ci
3989e41f4b71Sopenharmony_cion(type: 'mediaItemChange', callback: Callback\<AVQueueItem>): void
3990e41f4b71Sopenharmony_ci
3991e41f4b71Sopenharmony_ci设置投播当前播放媒体内容的监听事件。
3992e41f4b71Sopenharmony_ci
3993e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
3994e41f4b71Sopenharmony_ci
3995e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.AVCast
3996e41f4b71Sopenharmony_ci
3997e41f4b71Sopenharmony_ci**参数:**
3998e41f4b71Sopenharmony_ci
3999e41f4b71Sopenharmony_ci| 参数名   | 类型                                                         | 必填 | 说明                                                         |
4000e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
4001e41f4b71Sopenharmony_ci| type     | string                                                       | 是   | 事件回调类型,支持事件`'mediaItemChange'`:当播放的媒体内容变化时,触发该事件。 |
4002e41f4b71Sopenharmony_ci| callback | (callback: [AVQueueItem](#avqueueitem10)) => void         | 是   | 回调函数,参数AVQueueItem是当前正在播放的媒体内容。                      |
4003e41f4b71Sopenharmony_ci
4004e41f4b71Sopenharmony_ci**错误码:**
4005e41f4b71Sopenharmony_ci
4006e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
4007e41f4b71Sopenharmony_ci
4008e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
4009e41f4b71Sopenharmony_ci| -------- | ------------------------------ |
4010e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
4011e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
4012e41f4b71Sopenharmony_ci
4013e41f4b71Sopenharmony_ci**示例:**
4014e41f4b71Sopenharmony_ci
4015e41f4b71Sopenharmony_ci```ts
4016e41f4b71Sopenharmony_ciaVCastController.on('mediaItemChange', (item: avSession.AVQueueItem) => {
4017e41f4b71Sopenharmony_ci  console.info(`on mediaItemChange state : ${item.itemId}`);
4018e41f4b71Sopenharmony_ci});
4019e41f4b71Sopenharmony_ci```
4020e41f4b71Sopenharmony_ci
4021e41f4b71Sopenharmony_ci### off('mediaItemChange')<sup>10+</sup>
4022e41f4b71Sopenharmony_ci
4023e41f4b71Sopenharmony_cioff(type: 'mediaItemChange'): void
4024e41f4b71Sopenharmony_ci
4025e41f4b71Sopenharmony_ci取消设置投播当前播放媒体内容的监听事件。
4026e41f4b71Sopenharmony_ci
4027e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
4028e41f4b71Sopenharmony_ci
4029e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.AVCast
4030e41f4b71Sopenharmony_ci
4031e41f4b71Sopenharmony_ci**参数:**
4032e41f4b71Sopenharmony_ci
4033e41f4b71Sopenharmony_ci| 参数名   | 类型                                                         | 必填 | 说明                                                     |
4034e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | ---- | ----------------------------------------------------- |
4035e41f4b71Sopenharmony_ci| type     | string                                                       | 是   | 取消对应的监听事件,支持事件`'mediaItemChange'`。    |
4036e41f4b71Sopenharmony_ci
4037e41f4b71Sopenharmony_ci**错误码:**
4038e41f4b71Sopenharmony_ci
4039e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
4040e41f4b71Sopenharmony_ci
4041e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
4042e41f4b71Sopenharmony_ci| -------- | ---------------- |
4043e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
4044e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
4045e41f4b71Sopenharmony_ci
4046e41f4b71Sopenharmony_ci**示例:**
4047e41f4b71Sopenharmony_ci
4048e41f4b71Sopenharmony_ci```ts
4049e41f4b71Sopenharmony_ciaVCastController.off('mediaItemChange');
4050e41f4b71Sopenharmony_ci```
4051e41f4b71Sopenharmony_ci
4052e41f4b71Sopenharmony_ci### on('playNext')<sup>10+</sup>
4053e41f4b71Sopenharmony_ci
4054e41f4b71Sopenharmony_cion(type: 'playNext', callback: Callback\<void>): void
4055e41f4b71Sopenharmony_ci
4056e41f4b71Sopenharmony_ci设置播放下一首资源的监听事件。
4057e41f4b71Sopenharmony_ci
4058e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
4059e41f4b71Sopenharmony_ci
4060e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.AVCast
4061e41f4b71Sopenharmony_ci
4062e41f4b71Sopenharmony_ci**参数:**
4063e41f4b71Sopenharmony_ci
4064e41f4b71Sopenharmony_ci| 参数名   | 类型                                                         | 必填 | 说明                                                         |
4065e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
4066e41f4b71Sopenharmony_ci| type     | string                                                       | 是   | 事件回调类型,支持事件`'playNext'`:当播放下一首状态变化时,触发该事件。 |
4067e41f4b71Sopenharmony_ci| callback | Callback\<void\>         | 是   | 回调函数                      |
4068e41f4b71Sopenharmony_ci
4069e41f4b71Sopenharmony_ci**错误码:**
4070e41f4b71Sopenharmony_ci
4071e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
4072e41f4b71Sopenharmony_ci
4073e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
4074e41f4b71Sopenharmony_ci| -------- | ------------------------------ |
4075e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
4076e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
4077e41f4b71Sopenharmony_ci
4078e41f4b71Sopenharmony_ci**示例:**
4079e41f4b71Sopenharmony_ci
4080e41f4b71Sopenharmony_ci```ts
4081e41f4b71Sopenharmony_ciaVCastController.on('playNext', () => {
4082e41f4b71Sopenharmony_ci  console.info('on playNext');
4083e41f4b71Sopenharmony_ci});
4084e41f4b71Sopenharmony_ci```
4085e41f4b71Sopenharmony_ci
4086e41f4b71Sopenharmony_ci### off('playNext')<sup>10+</sup>
4087e41f4b71Sopenharmony_ci
4088e41f4b71Sopenharmony_cioff(type: 'playNext'): void
4089e41f4b71Sopenharmony_ci
4090e41f4b71Sopenharmony_ci取消设置播放下一首资源的监听事件。
4091e41f4b71Sopenharmony_ci
4092e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
4093e41f4b71Sopenharmony_ci
4094e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.AVCast
4095e41f4b71Sopenharmony_ci
4096e41f4b71Sopenharmony_ci**参数:**
4097e41f4b71Sopenharmony_ci
4098e41f4b71Sopenharmony_ci| 参数名   | 类型                                                         | 必填 | 说明                                                     |
4099e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | ---- | ----------------------------------------------------- |
4100e41f4b71Sopenharmony_ci| type     | string                                                       | 是   | 取消对应的监听事件,支持事件`'playNext'`。    |
4101e41f4b71Sopenharmony_ci
4102e41f4b71Sopenharmony_ci**错误码:**
4103e41f4b71Sopenharmony_ci
4104e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
4105e41f4b71Sopenharmony_ci
4106e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
4107e41f4b71Sopenharmony_ci| -------- | ---------------- |
4108e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
4109e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
4110e41f4b71Sopenharmony_ci
4111e41f4b71Sopenharmony_ci**示例:**
4112e41f4b71Sopenharmony_ci
4113e41f4b71Sopenharmony_ci```ts
4114e41f4b71Sopenharmony_ciaVCastController.off('playNext');
4115e41f4b71Sopenharmony_ci```
4116e41f4b71Sopenharmony_ci
4117e41f4b71Sopenharmony_ci### on('playPrevious')<sup>10+</sup>
4118e41f4b71Sopenharmony_ci
4119e41f4b71Sopenharmony_cion(type: 'playPrevious', callback: Callback\<void>): void
4120e41f4b71Sopenharmony_ci
4121e41f4b71Sopenharmony_ci设置播放上一首资源的监听事件。
4122e41f4b71Sopenharmony_ci
4123e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
4124e41f4b71Sopenharmony_ci
4125e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.AVCast
4126e41f4b71Sopenharmony_ci
4127e41f4b71Sopenharmony_ci**参数:**
4128e41f4b71Sopenharmony_ci
4129e41f4b71Sopenharmony_ci| 参数名   | 类型                                                         | 必填 | 说明                                                         |
4130e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
4131e41f4b71Sopenharmony_ci| type     | string                                                       | 是   | 事件回调类型,支持事件`'playPrevious'`:当播放上一首状态变化时,触发该事件。 |
4132e41f4b71Sopenharmony_ci| callback | Callback\<void\>         | 是   | 回调函数                      |
4133e41f4b71Sopenharmony_ci
4134e41f4b71Sopenharmony_ci**错误码:**
4135e41f4b71Sopenharmony_ci
4136e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
4137e41f4b71Sopenharmony_ci
4138e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
4139e41f4b71Sopenharmony_ci| -------- | ------------------------------ |
4140e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
4141e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
4142e41f4b71Sopenharmony_ci
4143e41f4b71Sopenharmony_ci**示例:**
4144e41f4b71Sopenharmony_ci
4145e41f4b71Sopenharmony_ci```ts
4146e41f4b71Sopenharmony_ciaVCastController.on('playPrevious', () => {
4147e41f4b71Sopenharmony_ci  console.info('on playPrevious');
4148e41f4b71Sopenharmony_ci});
4149e41f4b71Sopenharmony_ci```
4150e41f4b71Sopenharmony_ci
4151e41f4b71Sopenharmony_ci### off('playPrevious')<sup>10+</sup>
4152e41f4b71Sopenharmony_ci
4153e41f4b71Sopenharmony_cioff(type: 'playPrevious'): void
4154e41f4b71Sopenharmony_ci
4155e41f4b71Sopenharmony_ci取消设置播放上一首资源的监听事件。
4156e41f4b71Sopenharmony_ci
4157e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
4158e41f4b71Sopenharmony_ci
4159e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.AVCast
4160e41f4b71Sopenharmony_ci
4161e41f4b71Sopenharmony_ci**参数:**
4162e41f4b71Sopenharmony_ci
4163e41f4b71Sopenharmony_ci| 参数名   | 类型                                                         | 必填 | 说明                                                     |
4164e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | ---- | ----------------------------------------------------- |
4165e41f4b71Sopenharmony_ci| type     | string                                                       | 是   | 取消对应的监听事件,支持事件`'playPrevious'`。    |
4166e41f4b71Sopenharmony_ci
4167e41f4b71Sopenharmony_ci**错误码:**
4168e41f4b71Sopenharmony_ci
4169e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
4170e41f4b71Sopenharmony_ci
4171e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
4172e41f4b71Sopenharmony_ci| -------- | ---------------- |
4173e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
4174e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
4175e41f4b71Sopenharmony_ci
4176e41f4b71Sopenharmony_ci**示例:**
4177e41f4b71Sopenharmony_ci
4178e41f4b71Sopenharmony_ci```ts
4179e41f4b71Sopenharmony_ciaVCastController.off('playPrevious');
4180e41f4b71Sopenharmony_ci```
4181e41f4b71Sopenharmony_ci
4182e41f4b71Sopenharmony_ci### on('requestPlay')<sup>11+</sup>
4183e41f4b71Sopenharmony_ci
4184e41f4b71Sopenharmony_cion(type: 'requestPlay', callback: Callback\<AVQueueItem>): void
4185e41f4b71Sopenharmony_ci
4186e41f4b71Sopenharmony_ci设置请求播放的监听事件。
4187e41f4b71Sopenharmony_ci
4188e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.AVCast
4189e41f4b71Sopenharmony_ci
4190e41f4b71Sopenharmony_ci**参数:**
4191e41f4b71Sopenharmony_ci
4192e41f4b71Sopenharmony_ci| 参数名   | 类型                                                         | 必填 | 说明                                                         |
4193e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
4194e41f4b71Sopenharmony_ci| type     | string                                                       | 是   | 事件回调类型,支持事件`'requestPlay'`:当请求播放状态变化时,触发该事件。 |
4195e41f4b71Sopenharmony_ci| callback | (state: [AVQueueItem](#avqueueitem10)) => void               | 是   | 回调函数,参数AVQueueItem是当前正在播放的媒体内容。当监听事件注册成功,err为undefined,否则返回错误对象。  | 
4196e41f4b71Sopenharmony_ci
4197e41f4b71Sopenharmony_ci**错误码:**
4198e41f4b71Sopenharmony_ci
4199e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
4200e41f4b71Sopenharmony_ci
4201e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
4202e41f4b71Sopenharmony_ci| -------- | ------------------------------ |
4203e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
4204e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
4205e41f4b71Sopenharmony_ci
4206e41f4b71Sopenharmony_ci**示例:**
4207e41f4b71Sopenharmony_ci
4208e41f4b71Sopenharmony_ci```ts
4209e41f4b71Sopenharmony_ciaVCastController.on('requestPlay', (item: avSession.AVQueueItem) => {
4210e41f4b71Sopenharmony_ci  console.info(`on requestPlay state : ${item.itemId}`);
4211e41f4b71Sopenharmony_ci});
4212e41f4b71Sopenharmony_ci```
4213e41f4b71Sopenharmony_ci
4214e41f4b71Sopenharmony_ci### off('requestPlay')<sup>11+</sup>
4215e41f4b71Sopenharmony_ci
4216e41f4b71Sopenharmony_cioff(type: 'requestPlay', callback?: Callback\<AVQueueItem>): void
4217e41f4b71Sopenharmony_ci
4218e41f4b71Sopenharmony_ci取消设置请求播放的监听事件。
4219e41f4b71Sopenharmony_ci
4220e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.AVCast
4221e41f4b71Sopenharmony_ci
4222e41f4b71Sopenharmony_ci**参数:**
4223e41f4b71Sopenharmony_ci
4224e41f4b71Sopenharmony_ci| 参数名   | 类型                                                         | 必填 | 说明                                                     |
4225e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------| ---- | ----------------------------------------------------- |
4226e41f4b71Sopenharmony_ci| type     | string                                                      | 是   | 取消对应的监听事件,支持事件`'requestPlay'`。    |
4227e41f4b71Sopenharmony_ci| callback | (state: [AVQueueItem](#avqueueitem10)) => void              | 否   | 回调函数,参数AVQueueItem是当前正在播放的媒体内容。当监听事件取消成功,err为undefined,否则返回错误对象。该参数为可选参数,若不填写该参数,则认为取消所有相关会话的事件监听。|
4228e41f4b71Sopenharmony_ci
4229e41f4b71Sopenharmony_ci**错误码:**
4230e41f4b71Sopenharmony_ci
4231e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
4232e41f4b71Sopenharmony_ci
4233e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
4234e41f4b71Sopenharmony_ci| -------- | ---------------- |
4235e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
4236e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
4237e41f4b71Sopenharmony_ci
4238e41f4b71Sopenharmony_ci**示例:**
4239e41f4b71Sopenharmony_ci
4240e41f4b71Sopenharmony_ci```ts
4241e41f4b71Sopenharmony_ciaVCastController.off('requestPlay');
4242e41f4b71Sopenharmony_ci```
4243e41f4b71Sopenharmony_ci
4244e41f4b71Sopenharmony_ci### on('endOfStream')<sup>11+</sup>
4245e41f4b71Sopenharmony_ci
4246e41f4b71Sopenharmony_cion(type: 'endOfStream', callback: Callback\<void>): void
4247e41f4b71Sopenharmony_ci
4248e41f4b71Sopenharmony_ci设置播放结束的监听事件。
4249e41f4b71Sopenharmony_ci
4250e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.AVCast
4251e41f4b71Sopenharmony_ci
4252e41f4b71Sopenharmony_ci**参数:**
4253e41f4b71Sopenharmony_ci
4254e41f4b71Sopenharmony_ci| 参数名   | 类型                                                         | 必填 | 说明                                                         |
4255e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------| ---- | ------------------------------------------------------------ |
4256e41f4b71Sopenharmony_ci| type     | string                                                      | 是   | 事件回调类型,支持事件`'endOfStream'`:当资源播放结束时,触发该事件。 |
4257e41f4b71Sopenharmony_ci| callback | Callback\<void\>                                            | 是   | 回调函数。当监听事件注册成功,err为undefined,否则返回错误对象。      |
4258e41f4b71Sopenharmony_ci
4259e41f4b71Sopenharmony_ci**错误码:**
4260e41f4b71Sopenharmony_ci
4261e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
4262e41f4b71Sopenharmony_ci
4263e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
4264e41f4b71Sopenharmony_ci| -------- | ------------------------------ |
4265e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
4266e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
4267e41f4b71Sopenharmony_ci
4268e41f4b71Sopenharmony_ci**示例:**
4269e41f4b71Sopenharmony_ci
4270e41f4b71Sopenharmony_ci```ts
4271e41f4b71Sopenharmony_ciaVCastController.on('endOfStream', () => {
4272e41f4b71Sopenharmony_ci  console.info('on endOfStream');
4273e41f4b71Sopenharmony_ci});
4274e41f4b71Sopenharmony_ci```
4275e41f4b71Sopenharmony_ci
4276e41f4b71Sopenharmony_ci### off('endOfStream')<sup>11+</sup>
4277e41f4b71Sopenharmony_ci
4278e41f4b71Sopenharmony_cioff(type: 'endOfStream', callback?: Callback\<void>): void
4279e41f4b71Sopenharmony_ci
4280e41f4b71Sopenharmony_ci取消设置播放结束的监听事件。
4281e41f4b71Sopenharmony_ci
4282e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.AVCast
4283e41f4b71Sopenharmony_ci
4284e41f4b71Sopenharmony_ci**参数:**
4285e41f4b71Sopenharmony_ci
4286e41f4b71Sopenharmony_ci| 参数名   | 类型                                                         | 必填 | 说明                                                     |
4287e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------| ---- | ----------------------------------------------------- |
4288e41f4b71Sopenharmony_ci| type     | string                                                      | 是   | 取消对应的监听事件,支持事件`'endOfStream'`。    |
4289e41f4b71Sopenharmony_ci| callback | Callback\<void\>                                            | 否   | 回调函数。当监听事件取消成功,err为undefined,否则返回错误对象。该参数为可选参数,若不填写该参数,则认为取消所有相关会话的事件监听。   |
4290e41f4b71Sopenharmony_ci
4291e41f4b71Sopenharmony_ci**错误码:**
4292e41f4b71Sopenharmony_ci
4293e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
4294e41f4b71Sopenharmony_ci
4295e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
4296e41f4b71Sopenharmony_ci| -------- | ---------------- |
4297e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
4298e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
4299e41f4b71Sopenharmony_ci
4300e41f4b71Sopenharmony_ci**示例:**
4301e41f4b71Sopenharmony_ci
4302e41f4b71Sopenharmony_ci```ts
4303e41f4b71Sopenharmony_ciaVCastController.off('endOfStream');
4304e41f4b71Sopenharmony_ci```
4305e41f4b71Sopenharmony_ci
4306e41f4b71Sopenharmony_ci### on('seekDone')<sup>10+</sup>
4307e41f4b71Sopenharmony_ci
4308e41f4b71Sopenharmony_cion(type: 'seekDone', callback: Callback\<number>): void
4309e41f4b71Sopenharmony_ci
4310e41f4b71Sopenharmony_ci设置seek结束的监听事件。
4311e41f4b71Sopenharmony_ci
4312e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
4313e41f4b71Sopenharmony_ci
4314e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.AVCast
4315e41f4b71Sopenharmony_ci
4316e41f4b71Sopenharmony_ci**参数:**
4317e41f4b71Sopenharmony_ci
4318e41f4b71Sopenharmony_ci| 参数名   | 类型                                                         | 必填 | 说明                                                         |
4319e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
4320e41f4b71Sopenharmony_ci| type     | string                                                       | 是   | 事件回调类型,支持事件`'seekDone'`:当seek结束时,触发该事件。 |
4321e41f4b71Sopenharmony_ci| callback | Callback\<number\>         | 是   | 回调函数,返回seek后播放的位置                      |
4322e41f4b71Sopenharmony_ci
4323e41f4b71Sopenharmony_ci**错误码:**
4324e41f4b71Sopenharmony_ci
4325e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
4326e41f4b71Sopenharmony_ci
4327e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
4328e41f4b71Sopenharmony_ci| -------- | ------------------------------ |
4329e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
4330e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
4331e41f4b71Sopenharmony_ci
4332e41f4b71Sopenharmony_ci**示例:**
4333e41f4b71Sopenharmony_ci
4334e41f4b71Sopenharmony_ci```ts
4335e41f4b71Sopenharmony_ciaVCastController.on('seekDone', (pos: number) => {
4336e41f4b71Sopenharmony_ci  console.info(`on seekDone pos:${pos} `);
4337e41f4b71Sopenharmony_ci});
4338e41f4b71Sopenharmony_ci```
4339e41f4b71Sopenharmony_ci
4340e41f4b71Sopenharmony_ci### off('seekDone')<sup>10+</sup>
4341e41f4b71Sopenharmony_ci
4342e41f4b71Sopenharmony_cioff(type: 'seekDone'): void
4343e41f4b71Sopenharmony_ci
4344e41f4b71Sopenharmony_ci取消设置seek结束的监听事件。
4345e41f4b71Sopenharmony_ci
4346e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
4347e41f4b71Sopenharmony_ci
4348e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.AVCast
4349e41f4b71Sopenharmony_ci
4350e41f4b71Sopenharmony_ci**参数:**
4351e41f4b71Sopenharmony_ci
4352e41f4b71Sopenharmony_ci| 参数名   | 类型                                                         | 必填 | 说明                                                     |
4353e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | ---- | ----------------------------------------------------- |
4354e41f4b71Sopenharmony_ci| type     | string                                                       | 是   | 取消对应的监听事件,支持事件`'seekDone'`。    |
4355e41f4b71Sopenharmony_ci
4356e41f4b71Sopenharmony_ci**错误码:**
4357e41f4b71Sopenharmony_ci
4358e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
4359e41f4b71Sopenharmony_ci
4360e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
4361e41f4b71Sopenharmony_ci| -------- | ---------------- |
4362e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
4363e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
4364e41f4b71Sopenharmony_ci
4365e41f4b71Sopenharmony_ci**示例:**
4366e41f4b71Sopenharmony_ci
4367e41f4b71Sopenharmony_ci```ts
4368e41f4b71Sopenharmony_ciaVCastController.off('seekDone');
4369e41f4b71Sopenharmony_ci```
4370e41f4b71Sopenharmony_ci
4371e41f4b71Sopenharmony_ci### on('validCommandChange')<sup>11+</sup>
4372e41f4b71Sopenharmony_ci
4373e41f4b71Sopenharmony_cion(type: 'validCommandChange', callback: Callback\<Array\<AVCastControlCommandType>>)
4374e41f4b71Sopenharmony_ci
4375e41f4b71Sopenharmony_ci会话支持的有效命令变化监听事件。
4376e41f4b71Sopenharmony_ci
4377e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.AVCast
4378e41f4b71Sopenharmony_ci
4379e41f4b71Sopenharmony_ci**参数:**
4380e41f4b71Sopenharmony_ci
4381e41f4b71Sopenharmony_ci| 参数名   | 类型                                                         | 必填 | 说明                                                         |
4382e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
4383e41f4b71Sopenharmony_ci| type     | string                                                       | 是   | 事件回调类型,支持事件`'validCommandChange'`:当检测到会话的合法命令发生改变时,触发该事件。 |
4384e41f4b71Sopenharmony_ci| callback | Callback<Array<[AVCastControlCommandType](#avcastcontrolcommandtype10)\>\>   | 是   | 回调函数。参数commands是有效命令的集合。                     |
4385e41f4b71Sopenharmony_ci
4386e41f4b71Sopenharmony_ci**错误码:**
4387e41f4b71Sopenharmony_ci
4388e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
4389e41f4b71Sopenharmony_ci
4390e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
4391e41f4b71Sopenharmony_ci| -------- | ------------------------------ |
4392e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
4393e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
4394e41f4b71Sopenharmony_ci| 6600103  | The session controller does not exist. |
4395e41f4b71Sopenharmony_ci
4396e41f4b71Sopenharmony_ci**示例:**
4397e41f4b71Sopenharmony_ci
4398e41f4b71Sopenharmony_ci```ts
4399e41f4b71Sopenharmony_ciaVCastController.on('validCommandChange', (validCommands: avSession.AVCastControlCommandType[]) => {
4400e41f4b71Sopenharmony_ci  console.info(`validCommandChange : SUCCESS : size : ${validCommands.length}`);
4401e41f4b71Sopenharmony_ci  console.info(`validCommandChange : SUCCESS : validCommands : ${validCommands.values()}`);
4402e41f4b71Sopenharmony_ci});
4403e41f4b71Sopenharmony_ci```
4404e41f4b71Sopenharmony_ci
4405e41f4b71Sopenharmony_ci### off('validCommandChange')<sup>11+</sup>
4406e41f4b71Sopenharmony_ci
4407e41f4b71Sopenharmony_cioff(type: 'validCommandChange', callback?: Callback\<Array\<AVCastControlCommandType>>)
4408e41f4b71Sopenharmony_ci
4409e41f4b71Sopenharmony_ci媒体控制器取消监听会话有效命令变化的事件。
4410e41f4b71Sopenharmony_ci
4411e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.AVCast
4412e41f4b71Sopenharmony_ci
4413e41f4b71Sopenharmony_ci**参数:**
4414e41f4b71Sopenharmony_ci
4415e41f4b71Sopenharmony_ci| 参数名   | 类型                                                         | 必填 | 说明                                                        |
4416e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | ---- | -------------------------------------------------------- |
4417e41f4b71Sopenharmony_ci| type     | string                                                       | 是   | 取消对应的监听事件,支持事件`'validCommandChange'`。         |
4418e41f4b71Sopenharmony_ci| callback | Callback<Array<[AVCastControlCommandType](#avcastcontrolcommandtype10)\>\> | 否   | 回调函数。参数commands是有效命令的集合。<br>该参数为可选参数,若不填写该参数,则认为取消所有相关会话的事件监听。          |
4419e41f4b71Sopenharmony_ci
4420e41f4b71Sopenharmony_ci**错误码:**
4421e41f4b71Sopenharmony_ci
4422e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
4423e41f4b71Sopenharmony_ci
4424e41f4b71Sopenharmony_ci| 错误码ID | 错误信息           |
4425e41f4b71Sopenharmony_ci| -------- | ---------------- |
4426e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
4427e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
4428e41f4b71Sopenharmony_ci| 6600103  | The session controller does not exist. |
4429e41f4b71Sopenharmony_ci
4430e41f4b71Sopenharmony_ci**示例:**
4431e41f4b71Sopenharmony_ci
4432e41f4b71Sopenharmony_ci```ts
4433e41f4b71Sopenharmony_ciaVCastController.off('validCommandChange');
4434e41f4b71Sopenharmony_ci```
4435e41f4b71Sopenharmony_ci
4436e41f4b71Sopenharmony_ci### on('error')<sup>10+</sup>
4437e41f4b71Sopenharmony_ci
4438e41f4b71Sopenharmony_cion(type: 'error', callback: ErrorCallback): void
4439e41f4b71Sopenharmony_ci
4440e41f4b71Sopenharmony_ci监听远端播放器的错误事件,该事件仅用于错误提示,不需要用户停止播控动作。
4441e41f4b71Sopenharmony_ci
4442e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
4443e41f4b71Sopenharmony_ci
4444e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.AVCast
4445e41f4b71Sopenharmony_ci
4446e41f4b71Sopenharmony_ci**参数:**
4447e41f4b71Sopenharmony_ci
4448e41f4b71Sopenharmony_ci| 参数名   | 类型     | 必填 | 说明                                                         |
4449e41f4b71Sopenharmony_ci| -------- | -------- | ---- | ------------------------------------------------------------ |
4450e41f4b71Sopenharmony_ci| type     | string   | 是   | 错误事件回调类型,支持的事件:'error',用户操作和系统都会触发此事件。 |
4451e41f4b71Sopenharmony_ci| callback | ErrorCallback | 是   | 错误事件回调方法:远端播放过程中发生的错误,会提供错误码ID和错误信息。 |
4452e41f4b71Sopenharmony_ci
4453e41f4b71Sopenharmony_ci**错误码:**
4454e41f4b71Sopenharmony_ci
4455e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体服务错误码](../apis-media-kit/errorcode-media.md)以及[媒体会话管理错误码](errorcode-avsession.md)。
4456e41f4b71Sopenharmony_ci
4457e41f4b71Sopenharmony_ci| 错误码ID | 错误信息              |
4458e41f4b71Sopenharmony_ci| -------- | --------------------- |
4459e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
4460e41f4b71Sopenharmony_ci| 5400101  | No memory.            |
4461e41f4b71Sopenharmony_ci| 5400102  | Operation not allowed.   |
4462e41f4b71Sopenharmony_ci| 5400103  | I/O error.             |
4463e41f4b71Sopenharmony_ci| 5400104  | Time out.      |
4464e41f4b71Sopenharmony_ci| 5400105  | Service died.         |
4465e41f4b71Sopenharmony_ci| 5400106  | Unsupport format.     |
4466e41f4b71Sopenharmony_ci| 6600101  | Session service exception.     |
4467e41f4b71Sopenharmony_ci
4468e41f4b71Sopenharmony_ci**示例:**
4469e41f4b71Sopenharmony_ci
4470e41f4b71Sopenharmony_ci```ts
4471e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
4472e41f4b71Sopenharmony_ci
4473e41f4b71Sopenharmony_ciaVCastController.on('error', (error: BusinessError) => {
4474e41f4b71Sopenharmony_ci  console.info(`error happened, error code: ${error.code}, error message : ${error.message}.`)
4475e41f4b71Sopenharmony_ci})
4476e41f4b71Sopenharmony_ci```
4477e41f4b71Sopenharmony_ci
4478e41f4b71Sopenharmony_ci### off('error')<sup>10+</sup>
4479e41f4b71Sopenharmony_ci
4480e41f4b71Sopenharmony_cioff(type: 'error'): void
4481e41f4b71Sopenharmony_ci
4482e41f4b71Sopenharmony_ci取消监听播放的错误事件。
4483e41f4b71Sopenharmony_ci
4484e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
4485e41f4b71Sopenharmony_ci
4486e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.AVCast
4487e41f4b71Sopenharmony_ci
4488e41f4b71Sopenharmony_ci**参数:**
4489e41f4b71Sopenharmony_ci
4490e41f4b71Sopenharmony_ci| 参数名 | 类型   | 必填 | 说明                                      |
4491e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ----------------------------------------- |
4492e41f4b71Sopenharmony_ci| type   | string | 是   | 错误事件回调类型,取消注册的事件:'error' |
4493e41f4b71Sopenharmony_ci
4494e41f4b71Sopenharmony_ci**错误码:**
4495e41f4b71Sopenharmony_ci
4496e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体服务错误码](../apis-media-kit/errorcode-media.md)以及[媒体会话管理错误码](errorcode-avsession.md)。
4497e41f4b71Sopenharmony_ci
4498e41f4b71Sopenharmony_ci| 错误码ID | 错误信息              |
4499e41f4b71Sopenharmony_ci| -------- | --------------------- |
4500e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
4501e41f4b71Sopenharmony_ci| 5400101  | No memory.            |
4502e41f4b71Sopenharmony_ci| 5400102  | Operation not allowed.   |
4503e41f4b71Sopenharmony_ci| 5400103  | I/O error.             |
4504e41f4b71Sopenharmony_ci| 5400104  | Time out.      |
4505e41f4b71Sopenharmony_ci| 5400105  | Service died.         |
4506e41f4b71Sopenharmony_ci| 5400106  | Unsupport format.     |
4507e41f4b71Sopenharmony_ci| 6600101  | Session service exception.     |
4508e41f4b71Sopenharmony_ci
4509e41f4b71Sopenharmony_ci**示例:**
4510e41f4b71Sopenharmony_ci
4511e41f4b71Sopenharmony_ci```ts
4512e41f4b71Sopenharmony_ciaVCastController.off('error')
4513e41f4b71Sopenharmony_ci```
4514e41f4b71Sopenharmony_ci
4515e41f4b71Sopenharmony_ci### on('keyRequest')<sup>12+</sup>
4516e41f4b71Sopenharmony_ci
4517e41f4b71Sopenharmony_cion(type: 'keyRequest', callback: KeyRequestCallback): void
4518e41f4b71Sopenharmony_ci
4519e41f4b71Sopenharmony_ci在线DRM资源投播时,设置许可证请求的事件监听。
4520e41f4b71Sopenharmony_ci
4521e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
4522e41f4b71Sopenharmony_ci
4523e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.AVCast
4524e41f4b71Sopenharmony_ci
4525e41f4b71Sopenharmony_ci**参数:**
4526e41f4b71Sopenharmony_ci
4527e41f4b71Sopenharmony_ci| 参数名 | 类型   | 必填 | 说明                                      |
4528e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ----------------------------------------- |
4529e41f4b71Sopenharmony_ci| type     | string  | 是   | 事件回调类型,支持事件`'keyRequest'`:当DRM资源播放需要许可证时,触发该事件。 |
4530e41f4b71Sopenharmony_ci| callback | [KeyRequestCallback](#keyrequestcallback12)  | 是   | 回调函数,媒体资源及许可证请求数据。|
4531e41f4b71Sopenharmony_ci
4532e41f4b71Sopenharmony_ci
4533e41f4b71Sopenharmony_ci**错误码:**
4534e41f4b71Sopenharmony_ci
4535e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
4536e41f4b71Sopenharmony_ci
4537e41f4b71Sopenharmony_ci| 错误码ID | 错误信息           |
4538e41f4b71Sopenharmony_ci| -------- | ---------------- |
4539e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
4540e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
4541e41f4b71Sopenharmony_ci
4542e41f4b71Sopenharmony_ci**示例:**
4543e41f4b71Sopenharmony_ci
4544e41f4b71Sopenharmony_ci```ts
4545e41f4b71Sopenharmony_cilet keyRequestCallback: avSession.KeyRequestCallback = async(assetId: string, requestData: Uint8Array) => {
4546e41f4b71Sopenharmony_ci  console.info(`Succeeded in keyRequestCallback. assetId: ${assetId}, requestData: ${requestData}`);
4547e41f4b71Sopenharmony_ci}
4548e41f4b71Sopenharmony_ciaVCastController.on('keyRequest', keyRequestCallback);
4549e41f4b71Sopenharmony_ci```
4550e41f4b71Sopenharmony_ci### off('keyRequest')<sup>12+</sup>
4551e41f4b71Sopenharmony_ci
4552e41f4b71Sopenharmony_cioff(type: 'keyRequest', callback?: KeyRequestCallback): void
4553e41f4b71Sopenharmony_ci
4554e41f4b71Sopenharmony_ci取消监听许可证请求的事件。
4555e41f4b71Sopenharmony_ci
4556e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
4557e41f4b71Sopenharmony_ci
4558e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.AVCast
4559e41f4b71Sopenharmony_ci
4560e41f4b71Sopenharmony_ci**参数:**
4561e41f4b71Sopenharmony_ci
4562e41f4b71Sopenharmony_ci| 参数名 | 类型   | 必填 | 说明                                      |
4563e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ----------------------------------------- |
4564e41f4b71Sopenharmony_ci| type     | string                                                       | 是   | 取消对应的监听事件,支持的事件是`'keyRequest'`。 |
4565e41f4b71Sopenharmony_ci| callback |  [KeyRequestCallback](#keyrequestcallback12)  | 否   | 回调函数。当监听事件取消成功,err为undefined,否则返回错误对象。该参数为可选参数,若不填写该参数,则认为取消所有相关会话的事件监听。                            |
4566e41f4b71Sopenharmony_ci
4567e41f4b71Sopenharmony_ci**错误码:**
4568e41f4b71Sopenharmony_ci
4569e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
4570e41f4b71Sopenharmony_ci
4571e41f4b71Sopenharmony_ci| 错误码ID | 错误信息           |
4572e41f4b71Sopenharmony_ci| -------- | ---------------- |
4573e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
4574e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
4575e41f4b71Sopenharmony_ci
4576e41f4b71Sopenharmony_ci**示例:**
4577e41f4b71Sopenharmony_ci
4578e41f4b71Sopenharmony_ci```ts
4579e41f4b71Sopenharmony_ciaVCastController.off('keyRequest');
4580e41f4b71Sopenharmony_ci```
4581e41f4b71Sopenharmony_ci## KeyRequestCallback<sup>12+</sup>
4582e41f4b71Sopenharmony_citype KeyRequestCallback = (assetId: string, requestData: Uint8Array) => void
4583e41f4b71Sopenharmony_ci
4584e41f4b71Sopenharmony_ci许可证请求事件的回调函数。
4585e41f4b71Sopenharmony_ci
4586e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
4587e41f4b71Sopenharmony_ci
4588e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.AVCast
4589e41f4b71Sopenharmony_ci
4590e41f4b71Sopenharmony_ci**参数:**
4591e41f4b71Sopenharmony_ci
4592e41f4b71Sopenharmony_ci| 参数名 | 类型   | 必填 | 说明                                      |
4593e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ----------------------------------------- |
4594e41f4b71Sopenharmony_ci| assetId     | string  | 是   | 媒体ID。 |
4595e41f4b71Sopenharmony_ci| requestData |  Uint8Array  | 是   | 媒体许可证请求数据。                            |
4596e41f4b71Sopenharmony_ci
4597e41f4b71Sopenharmony_ci**示例:**
4598e41f4b71Sopenharmony_ci<!--code_no_check-->
4599e41f4b71Sopenharmony_ci```ts
4600e41f4b71Sopenharmony_cilet keyRequestCallback: avSession.KeyRequestCallback = async(assetId: string, requestData: Uint8Array) => {
4601e41f4b71Sopenharmony_ci  console.info(`Succeeded in keyRequestCallback. assetId: ${assetId}, requestData: ${requestData}`);
4602e41f4b71Sopenharmony_ci}
4603e41f4b71Sopenharmony_ci```
4604e41f4b71Sopenharmony_ci
4605e41f4b71Sopenharmony_ci### on('castControlGenericError')<sup>13+</sup>
4606e41f4b71Sopenharmony_ci
4607e41f4b71Sopenharmony_cion(type: 'castControlGenericError', callback: ErrorCallback): void
4608e41f4b71Sopenharmony_ci
4609e41f4b71Sopenharmony_ci监听投播通用错误事件。
4610e41f4b71Sopenharmony_ci
4611e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 13开始,该接口支持在原子化服务中使用。
4612e41f4b71Sopenharmony_ci
4613e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.AVCast
4614e41f4b71Sopenharmony_ci
4615e41f4b71Sopenharmony_ci**参数:**
4616e41f4b71Sopenharmony_ci
4617e41f4b71Sopenharmony_ci| 参数名   | 类型     | 必填 | 说明                                                         |
4618e41f4b71Sopenharmony_ci| -------- | -------- | ---- | ------------------------------------------------------------ |
4619e41f4b71Sopenharmony_ci| type     | string   | 是   | 错误事件回调类型,支持的事件:'castControlGenericError'。 |
4620e41f4b71Sopenharmony_ci| callback | ErrorCallback | 是   | 投播通用错误事件回调方法。 |
4621e41f4b71Sopenharmony_ci
4622e41f4b71Sopenharmony_ci**错误码:**
4623e41f4b71Sopenharmony_ci
4624e41f4b71Sopenharmony_ci| 错误码ID | 错误信息              |
4625e41f4b71Sopenharmony_ci| -------- | --------------------- |
4626e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
4627e41f4b71Sopenharmony_ci| 6611000  | The error code for cast control is unspecified.      |
4628e41f4b71Sopenharmony_ci| 6611001  | An unspecified error occurs in the remote player.   |
4629e41f4b71Sopenharmony_ci| 6611002  | The playback position falls behind the live window.     |
4630e41f4b71Sopenharmony_ci| 6611003  | The process of cast control times out.    |
4631e41f4b71Sopenharmony_ci| 6611004  | The runtime check failed.      |
4632e41f4b71Sopenharmony_ci| 6611100  | Cross-device data transmission is locked.    |
4633e41f4b71Sopenharmony_ci| 6611101  | The specified seek mode is not supported.   |
4634e41f4b71Sopenharmony_ci| 6611102  | The position to seek to is out of the range of the media asset or the specified seek mode is not supported.  |
4635e41f4b71Sopenharmony_ci| 6611103  | The specified playback mode is not supported.       |
4636e41f4b71Sopenharmony_ci| 6611104  | The specified playback speed is not supported.    |
4637e41f4b71Sopenharmony_ci| 6611105  | The action failed because either the media source device or the media sink device has been revoked.   |
4638e41f4b71Sopenharmony_ci| 6611106  | The parameter is invalid, for example, the url is illegal to play.  |
4639e41f4b71Sopenharmony_ci| 6611107  | Allocation of memory failed.  |
4640e41f4b71Sopenharmony_ci| 6611108  | Operation is not allowed.    |
4641e41f4b71Sopenharmony_ci
4642e41f4b71Sopenharmony_ci**示例:**
4643e41f4b71Sopenharmony_ci
4644e41f4b71Sopenharmony_ci```ts
4645e41f4b71Sopenharmony_ciaVCastController.on('castControlGenericError', (error: BusinessError) => {
4646e41f4b71Sopenharmony_ci  console.info(`castControlGenericError happened, error code: ${error.code}, error message : ${error.message}.`)
4647e41f4b71Sopenharmony_ci})
4648e41f4b71Sopenharmony_ci```
4649e41f4b71Sopenharmony_ci
4650e41f4b71Sopenharmony_ci### off('castControlGenericError')<sup>13+</sup>
4651e41f4b71Sopenharmony_ci
4652e41f4b71Sopenharmony_cioff(type: 'castControlGenericError', callback?: ErrorCallback): void
4653e41f4b71Sopenharmony_ci
4654e41f4b71Sopenharmony_ci取消监听投播通用的错误事件。
4655e41f4b71Sopenharmony_ci
4656e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 13开始,该接口支持在原子化服务中使用。
4657e41f4b71Sopenharmony_ci
4658e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.AVCast
4659e41f4b71Sopenharmony_ci
4660e41f4b71Sopenharmony_ci**参数:**
4661e41f4b71Sopenharmony_ci
4662e41f4b71Sopenharmony_ci| 参数名   | 类型     | 必填 | 说明                                                         |
4663e41f4b71Sopenharmony_ci| -------- | -------- | ---- | ------------------------------------------------------------ |
4664e41f4b71Sopenharmony_ci| type     | string   | 是   | 	取消对应的监听事件,支持的事件是'castControlGenericError'。 |
4665e41f4b71Sopenharmony_ci| callback | ErrorCallback | 否   | 回调函数。当监听事件取消成功,err为undefined,否则返回错误对象。该参数为可选参数,若不填写该参数,则认为取消所有相关会话的事件监听。 |
4666e41f4b71Sopenharmony_ci
4667e41f4b71Sopenharmony_ci**错误码:**
4668e41f4b71Sopenharmony_ci
4669e41f4b71Sopenharmony_ci| 错误码ID | 错误信息              |
4670e41f4b71Sopenharmony_ci| -------- | --------------------- |
4671e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
4672e41f4b71Sopenharmony_ci
4673e41f4b71Sopenharmony_ci**示例:**
4674e41f4b71Sopenharmony_ci
4675e41f4b71Sopenharmony_ci```ts
4676e41f4b71Sopenharmony_ciaVCastController.off('castControlGenericError');
4677e41f4b71Sopenharmony_ci```
4678e41f4b71Sopenharmony_ci
4679e41f4b71Sopenharmony_ci### on('castControlIoError')<sup>13+</sup>
4680e41f4b71Sopenharmony_ci
4681e41f4b71Sopenharmony_cion(type: 'castControlIoError', callback: ErrorCallback): void
4682e41f4b71Sopenharmony_ci
4683e41f4b71Sopenharmony_ci监听投播输入/输出的错误事件。
4684e41f4b71Sopenharmony_ci
4685e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 13开始,该接口支持在原子化服务中使用。
4686e41f4b71Sopenharmony_ci
4687e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.AVCast
4688e41f4b71Sopenharmony_ci
4689e41f4b71Sopenharmony_ci**参数:**
4690e41f4b71Sopenharmony_ci
4691e41f4b71Sopenharmony_ci| 参数名   | 类型     | 必填 | 说明                                                         |
4692e41f4b71Sopenharmony_ci| -------- | -------- | ---- | ------------------------------------------------------------ |
4693e41f4b71Sopenharmony_ci| type     | string   | 是   | 错误事件回调类型,支持的事件:'castControlIoError'。 |
4694e41f4b71Sopenharmony_ci| callback | ErrorCallback | 是   | 投播输入/输出的错误事件回调方法。 |
4695e41f4b71Sopenharmony_ci
4696e41f4b71Sopenharmony_ci**错误码:**
4697e41f4b71Sopenharmony_ci
4698e41f4b71Sopenharmony_ci| 错误码ID | 错误信息              |
4699e41f4b71Sopenharmony_ci| -------- | --------------------- |
4700e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
4701e41f4b71Sopenharmony_ci| 6612000  | An unspecified input/output error occurs.     |
4702e41f4b71Sopenharmony_ci| 6612001  | Network connection failure.   |
4703e41f4b71Sopenharmony_ci| 6612002  | Network timeout.     |
4704e41f4b71Sopenharmony_ci| 6612003  | Invalid "Content-Type" HTTP header.    |
4705e41f4b71Sopenharmony_ci| 6612004  | The HTTP server returns an unexpected HTTP response status code.      |
4706e41f4b71Sopenharmony_ci| 6612005  | The file does not exist.    |
4707e41f4b71Sopenharmony_ci| 6612006  | No permission is granted to perform the IO operation.   |
4708e41f4b71Sopenharmony_ci| 6612007  | Access to cleartext HTTP traffic is not allowed by the app's network security configuration. |
4709e41f4b71Sopenharmony_ci| 6612008  | Reading data out of the data bound.    |
4710e41f4b71Sopenharmony_ci| 6612100  | The media does not contain any contents that can be played.   |
4711e41f4b71Sopenharmony_ci| 6612101  | The media cannot be read, for example, because of dust or scratches.   |
4712e41f4b71Sopenharmony_ci| 6612102  | This resource is already in use. |
4713e41f4b71Sopenharmony_ci| 6612103  | The content using the validity interval has expired.  |
4714e41f4b71Sopenharmony_ci| 6612104  | Using the requested content to play is not allowed.    |
4715e41f4b71Sopenharmony_ci| 6612105  | The use of the allowed content cannot be verified.  |
4716e41f4b71Sopenharmony_ci| 6612106  | The number of times this content has been used as requested has reached the maximum allowed number of uses.  |
4717e41f4b71Sopenharmony_ci| 6612107  | An error occurs when sending packet from source device to sink device.    |
4718e41f4b71Sopenharmony_ci
4719e41f4b71Sopenharmony_ci**示例:**
4720e41f4b71Sopenharmony_ci
4721e41f4b71Sopenharmony_ci```ts
4722e41f4b71Sopenharmony_ciaVCastController.on('castControlIoError', (error: BusinessError) => {
4723e41f4b71Sopenharmony_ci  console.info(`castControlIoError happened, error code: ${error.code}, error message : ${error.message}.`)
4724e41f4b71Sopenharmony_ci})
4725e41f4b71Sopenharmony_ci```
4726e41f4b71Sopenharmony_ci
4727e41f4b71Sopenharmony_ci### off('castControlIoError')<sup>13+</sup>
4728e41f4b71Sopenharmony_ci
4729e41f4b71Sopenharmony_cioff(type: 'castControlIoError', callback?: ErrorCallback): void
4730e41f4b71Sopenharmony_ci
4731e41f4b71Sopenharmony_ci取消监听投播输入/输出的错误事件。
4732e41f4b71Sopenharmony_ci
4733e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 13开始,该接口支持在原子化服务中使用。
4734e41f4b71Sopenharmony_ci
4735e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.AVCast
4736e41f4b71Sopenharmony_ci
4737e41f4b71Sopenharmony_ci**参数:**
4738e41f4b71Sopenharmony_ci
4739e41f4b71Sopenharmony_ci| 参数名   | 类型     | 必填 | 说明                                                         |
4740e41f4b71Sopenharmony_ci| -------- | -------- | ---- | ------------------------------------------------------------ |
4741e41f4b71Sopenharmony_ci| type     | string   | 是   | 	取消对应的监听事件,支持的事件是'castControlIoError'。 |
4742e41f4b71Sopenharmony_ci| callback | ErrorCallback | 否   | 回调函数。当监听事件取消成功,err为undefined,否则返回错误对象。该参数为可选参数,若不填写该参数,则认为取消所有相关会话的事件监听。 |
4743e41f4b71Sopenharmony_ci
4744e41f4b71Sopenharmony_ci**错误码:**
4745e41f4b71Sopenharmony_ci
4746e41f4b71Sopenharmony_ci| 错误码ID | 错误信息              |
4747e41f4b71Sopenharmony_ci| -------- | --------------------- |
4748e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
4749e41f4b71Sopenharmony_ci
4750e41f4b71Sopenharmony_ci**示例:**
4751e41f4b71Sopenharmony_ci
4752e41f4b71Sopenharmony_ci```ts
4753e41f4b71Sopenharmony_ciaVCastController.off('castControlIoError');
4754e41f4b71Sopenharmony_ci```
4755e41f4b71Sopenharmony_ci
4756e41f4b71Sopenharmony_ci### on('castControlParsingError')<sup>13+</sup>
4757e41f4b71Sopenharmony_ci
4758e41f4b71Sopenharmony_cion(type: 'castControlParsingError', callback: ErrorCallback): void
4759e41f4b71Sopenharmony_ci
4760e41f4b71Sopenharmony_ci监听投播解析的错误事件。
4761e41f4b71Sopenharmony_ci
4762e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 13开始,该接口支持在原子化服务中使用。
4763e41f4b71Sopenharmony_ci
4764e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.AVCast
4765e41f4b71Sopenharmony_ci
4766e41f4b71Sopenharmony_ci**参数:**
4767e41f4b71Sopenharmony_ci
4768e41f4b71Sopenharmony_ci| 参数名   | 类型     | 必填 | 说明                                                         |
4769e41f4b71Sopenharmony_ci| -------- | -------- | ---- | ------------------------------------------------------------ |
4770e41f4b71Sopenharmony_ci| type     | string   | 是   | 错误事件回调类型,支持的事件:'castControlParsingError'。 |
4771e41f4b71Sopenharmony_ci| callback | ErrorCallback | 是   | 投播解析的错误事件回调方法。 |
4772e41f4b71Sopenharmony_ci
4773e41f4b71Sopenharmony_ci**错误码:**
4774e41f4b71Sopenharmony_ci
4775e41f4b71Sopenharmony_ci| 错误码ID  | 错误信息              |
4776e41f4b71Sopenharmony_ci| -------- | --------------------- |
4777e41f4b71Sopenharmony_ci| 401      |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
4778e41f4b71Sopenharmony_ci| 6613000  | Unspecified error related to content parsing.     |
4779e41f4b71Sopenharmony_ci| 6613001  | Parsing error associated with media container format bit streams.   |
4780e41f4b71Sopenharmony_ci| 6613002  | Parsing error associated with the media manifest.     |
4781e41f4b71Sopenharmony_ci| 6613003  | An error occurs when attempting to extract a file with an unsupported media container format or an unsupported media container feature.    |
4782e41f4b71Sopenharmony_ci| 6613004  | Unsupported feature in the media manifest.    |
4783e41f4b71Sopenharmony_ci
4784e41f4b71Sopenharmony_ci**示例:**
4785e41f4b71Sopenharmony_ci
4786e41f4b71Sopenharmony_ci```ts
4787e41f4b71Sopenharmony_ciaVCastController.on('castControlParsingError', (error: BusinessError) => {
4788e41f4b71Sopenharmony_ci  console.info(`castControlParsingError happened, error code: ${error.code}, error message : ${error.message}.`)
4789e41f4b71Sopenharmony_ci})
4790e41f4b71Sopenharmony_ci```
4791e41f4b71Sopenharmony_ci
4792e41f4b71Sopenharmony_ci### off('castControlParsingError')<sup>13+</sup>
4793e41f4b71Sopenharmony_ci
4794e41f4b71Sopenharmony_cioff(type: 'castControlParsingError', callback?: ErrorCallback): void
4795e41f4b71Sopenharmony_ci
4796e41f4b71Sopenharmony_ci取消监听投播解析的错误事件。
4797e41f4b71Sopenharmony_ci
4798e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 13开始,该接口支持在原子化服务中使用。
4799e41f4b71Sopenharmony_ci
4800e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.AVCast
4801e41f4b71Sopenharmony_ci
4802e41f4b71Sopenharmony_ci**参数:**
4803e41f4b71Sopenharmony_ci
4804e41f4b71Sopenharmony_ci| 参数名   | 类型     | 必填 | 说明                                                         |
4805e41f4b71Sopenharmony_ci| -------- | -------- | ---- | ------------------------------------------------------------ |
4806e41f4b71Sopenharmony_ci| type     | string   | 是   | 	取消对应的监听事件,支持的事件是'castControlParsingError'。 |
4807e41f4b71Sopenharmony_ci| callback | ErrorCallback | 否   | 回调函数。当监听事件取消成功,err为undefined,否则返回错误对象。该参数为可选参数,若不填写该参数,则认为取消所有相关会话的事件监听。 |
4808e41f4b71Sopenharmony_ci
4809e41f4b71Sopenharmony_ci**错误码:**
4810e41f4b71Sopenharmony_ci
4811e41f4b71Sopenharmony_ci| 错误码ID | 错误信息              |
4812e41f4b71Sopenharmony_ci| -------- | --------------------- |
4813e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
4814e41f4b71Sopenharmony_ci
4815e41f4b71Sopenharmony_ci**示例:**
4816e41f4b71Sopenharmony_ci
4817e41f4b71Sopenharmony_ci```ts
4818e41f4b71Sopenharmony_ciaVCastController.off('castControlParsingError');
4819e41f4b71Sopenharmony_ci```
4820e41f4b71Sopenharmony_ci
4821e41f4b71Sopenharmony_ci### on('castControlDecodingError')<sup>13+</sup>
4822e41f4b71Sopenharmony_ci
4823e41f4b71Sopenharmony_cion(type: 'castControlDecodingError', callback: ErrorCallback): void
4824e41f4b71Sopenharmony_ci
4825e41f4b71Sopenharmony_ci监听投播解码的错误事件。
4826e41f4b71Sopenharmony_ci
4827e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 13开始,该接口支持在原子化服务中使用。
4828e41f4b71Sopenharmony_ci
4829e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.AVCast
4830e41f4b71Sopenharmony_ci
4831e41f4b71Sopenharmony_ci**参数:**
4832e41f4b71Sopenharmony_ci
4833e41f4b71Sopenharmony_ci| 参数名   | 类型     | 必填 | 说明                                                         |
4834e41f4b71Sopenharmony_ci| -------- | -------- | ---- | ------------------------------------------------------------ |
4835e41f4b71Sopenharmony_ci| type     | string   | 是   | 错误事件回调类型,支持的事件:'castControlDecodingError'。 |
4836e41f4b71Sopenharmony_ci| callback | ErrorCallback | 是   | 投播解码的错误事件回调方法。 |
4837e41f4b71Sopenharmony_ci
4838e41f4b71Sopenharmony_ci**错误码:**
4839e41f4b71Sopenharmony_ci
4840e41f4b71Sopenharmony_ci| 错误码ID | 错误信息              |
4841e41f4b71Sopenharmony_ci| -------- | --------------------- |
4842e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
4843e41f4b71Sopenharmony_ci| 6614000  | Unspecified decoding error.     |
4844e41f4b71Sopenharmony_ci| 6614001  | Decoder initialization failed.   |
4845e41f4b71Sopenharmony_ci| 6614002  | Decoder query failed.     |
4846e41f4b71Sopenharmony_ci| 6614003  | Decoding the media samples failed.    |
4847e41f4b71Sopenharmony_ci| 6614004  | The format of the content to decode exceeds the capabilities of the device.    |
4848e41f4b71Sopenharmony_ci| 6614005  | The format of the content to decode is not supported.    |
4849e41f4b71Sopenharmony_ci
4850e41f4b71Sopenharmony_ci**示例:**
4851e41f4b71Sopenharmony_ci
4852e41f4b71Sopenharmony_ci```ts
4853e41f4b71Sopenharmony_ciaVCastController.on('castControlDecodingError', (error: BusinessError) => {
4854e41f4b71Sopenharmony_ci  console.info(`castControlDecodingError happened, error code: ${error.code}, error message : ${error.message}.`)
4855e41f4b71Sopenharmony_ci})
4856e41f4b71Sopenharmony_ci```
4857e41f4b71Sopenharmony_ci### off('castControlDecodingError')<sup>13+</sup>
4858e41f4b71Sopenharmony_ci
4859e41f4b71Sopenharmony_cioff(type: 'castControlDecodingError', callback?: ErrorCallback): void
4860e41f4b71Sopenharmony_ci
4861e41f4b71Sopenharmony_ci取消监听投播解码的错误事件。
4862e41f4b71Sopenharmony_ci
4863e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 13开始,该接口支持在原子化服务中使用。
4864e41f4b71Sopenharmony_ci
4865e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.AVCast
4866e41f4b71Sopenharmony_ci
4867e41f4b71Sopenharmony_ci**参数:**
4868e41f4b71Sopenharmony_ci
4869e41f4b71Sopenharmony_ci| 参数名   | 类型     | 必填 | 说明                                                         |
4870e41f4b71Sopenharmony_ci| -------- | -------- | ---- | ------------------------------------------------------------ |
4871e41f4b71Sopenharmony_ci| type     | string   | 是   | 	取消对应的监听事件,支持的事件是'castControlDecodingError'。 |
4872e41f4b71Sopenharmony_ci| callback | ErrorCallback | 否   | 回调函数。当监听事件取消成功,err为undefined,否则返回错误对象。该参数为可选参数,若不填写该参数,则认为取消所有相关会话的事件监听。 |
4873e41f4b71Sopenharmony_ci
4874e41f4b71Sopenharmony_ci**错误码:**
4875e41f4b71Sopenharmony_ci
4876e41f4b71Sopenharmony_ci| 错误码ID | 错误信息              |
4877e41f4b71Sopenharmony_ci| -------- | --------------------- |
4878e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
4879e41f4b71Sopenharmony_ci
4880e41f4b71Sopenharmony_ci**示例:**
4881e41f4b71Sopenharmony_ci
4882e41f4b71Sopenharmony_ci```ts
4883e41f4b71Sopenharmony_ciaVCastController.off('castControlDecodingError');
4884e41f4b71Sopenharmony_ci```
4885e41f4b71Sopenharmony_ci
4886e41f4b71Sopenharmony_ci### on('castControlAudioRendererError')<sup>13+</sup>
4887e41f4b71Sopenharmony_ci
4888e41f4b71Sopenharmony_cion(type: 'castControlAudioRendererError', callback: ErrorCallback): void
4889e41f4b71Sopenharmony_ci
4890e41f4b71Sopenharmony_ci监听投播音频渲染器的错误事件。
4891e41f4b71Sopenharmony_ci
4892e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 13开始,该接口支持在原子化服务中使用。
4893e41f4b71Sopenharmony_ci
4894e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.AVCast
4895e41f4b71Sopenharmony_ci
4896e41f4b71Sopenharmony_ci**参数:**
4897e41f4b71Sopenharmony_ci
4898e41f4b71Sopenharmony_ci| 参数名   | 类型     | 必填 | 说明                                                         |
4899e41f4b71Sopenharmony_ci| -------- | -------- | ---- | ------------------------------------------------------------ |
4900e41f4b71Sopenharmony_ci| type     | string   | 是   | 错误事件回调类型,支持的事件:'castControlAudioRendererError'。 |
4901e41f4b71Sopenharmony_ci| callback | ErrorCallback | 是   | 投播音频渲染器的错误事件回调方法。 |
4902e41f4b71Sopenharmony_ci
4903e41f4b71Sopenharmony_ci**错误码:**
4904e41f4b71Sopenharmony_ci
4905e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体服务错误码](../apis-media-kit/errorcode-media.md)以及[媒体会话管理错误码](errorcode-avsession.md)。
4906e41f4b71Sopenharmony_ci
4907e41f4b71Sopenharmony_ci| 错误码ID | 错误信息              |
4908e41f4b71Sopenharmony_ci| -------- | --------------------- |
4909e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
4910e41f4b71Sopenharmony_ci| 6615000  | Unspecified errors related to the audio renderer.     |
4911e41f4b71Sopenharmony_ci| 6615001  | Initializing the audio renderer failed.   |
4912e41f4b71Sopenharmony_ci| 6615002  | The audio renderer fails to write data.     |
4913e41f4b71Sopenharmony_ci
4914e41f4b71Sopenharmony_ci**示例:**
4915e41f4b71Sopenharmony_ci
4916e41f4b71Sopenharmony_ci```ts
4917e41f4b71Sopenharmony_ciaVCastController.on('castControlAudioRendererError', (error: BusinessError) => {
4918e41f4b71Sopenharmony_ci  console.info(`castControlAudioRendererError happened, error code: ${error.code}, error message : ${error.message}.`)
4919e41f4b71Sopenharmony_ci})
4920e41f4b71Sopenharmony_ci```
4921e41f4b71Sopenharmony_ci### off('castControlAudioRendererError')<sup>13+</sup>
4922e41f4b71Sopenharmony_ci
4923e41f4b71Sopenharmony_cioff(type: 'castControlAudioRendererError', callback?: ErrorCallback): void
4924e41f4b71Sopenharmony_ci
4925e41f4b71Sopenharmony_ci取消监听投播音频渲染器的错误事件。
4926e41f4b71Sopenharmony_ci
4927e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 13开始,该接口支持在原子化服务中使用。
4928e41f4b71Sopenharmony_ci
4929e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.AVCast
4930e41f4b71Sopenharmony_ci
4931e41f4b71Sopenharmony_ci**参数:**
4932e41f4b71Sopenharmony_ci
4933e41f4b71Sopenharmony_ci| 参数名   | 类型     | 必填 | 说明                                                         |
4934e41f4b71Sopenharmony_ci| -------- | -------- | ---- | ------------------------------------------------------------ |
4935e41f4b71Sopenharmony_ci| type     | string   | 是   | 	取消对应的监听事件,支持的事件是'castControlAudioRendererError'。 |
4936e41f4b71Sopenharmony_ci| callback | ErrorCallback | 否   | 回调函数。当监听事件取消成功,err为undefined,否则返回错误对象。该参数为可选参数,若不填写该参数,则认为取消所有相关会话的事件监听。 |
4937e41f4b71Sopenharmony_ci
4938e41f4b71Sopenharmony_ci**错误码:**
4939e41f4b71Sopenharmony_ci
4940e41f4b71Sopenharmony_ci| 错误码ID | 错误信息              |
4941e41f4b71Sopenharmony_ci| -------- | --------------------- |
4942e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
4943e41f4b71Sopenharmony_ci
4944e41f4b71Sopenharmony_ci**示例:**
4945e41f4b71Sopenharmony_ci
4946e41f4b71Sopenharmony_ci```ts
4947e41f4b71Sopenharmony_ciaVCastController.off('castControlAudioRendererError');
4948e41f4b71Sopenharmony_ci```
4949e41f4b71Sopenharmony_ci
4950e41f4b71Sopenharmony_ci### on('castControlDrmError')<sup>13+</sup>
4951e41f4b71Sopenharmony_ci
4952e41f4b71Sopenharmony_cion(type: 'castControlDrmError', callback: ErrorCallback): void
4953e41f4b71Sopenharmony_ci
4954e41f4b71Sopenharmony_ci监听投播drm的错误事件。
4955e41f4b71Sopenharmony_ci
4956e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 13开始,该接口支持在原子化服务中使用。
4957e41f4b71Sopenharmony_ci
4958e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.AVCast
4959e41f4b71Sopenharmony_ci
4960e41f4b71Sopenharmony_ci**参数:**
4961e41f4b71Sopenharmony_ci
4962e41f4b71Sopenharmony_ci| 参数名   | 类型     | 必填 | 说明                                                         |
4963e41f4b71Sopenharmony_ci| -------- | -------- | ---- | ------------------------------------------------------------ |
4964e41f4b71Sopenharmony_ci| type     | string   | 是   | 错误事件回调类型,支持的事件:'castControlDrmError'。 |
4965e41f4b71Sopenharmony_ci| callback | ErrorCallback | 是   | 投播drm的错误事件回调方法。 |
4966e41f4b71Sopenharmony_ci
4967e41f4b71Sopenharmony_ci**错误码:**
4968e41f4b71Sopenharmony_ci
4969e41f4b71Sopenharmony_ci| 错误码ID | 错误信息              |
4970e41f4b71Sopenharmony_ci| -------- | --------------------- |
4971e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
4972e41f4b71Sopenharmony_ci| 6616000  | Unspecified error related to DRM.     |
4973e41f4b71Sopenharmony_ci| 6616001  | The chosen DRM protection scheme is not supported by the device.  |
4974e41f4b71Sopenharmony_ci| 6615002  | Device provisioning failed.    |
4975e41f4b71Sopenharmony_ci| 6616003  | The DRM-protected content to play is incompatible.     |
4976e41f4b71Sopenharmony_ci| 6616004  | Failed to obtain a license.   |
4977e41f4b71Sopenharmony_ci| 6616005  | The operation is disallowed by the license policy.     |
4978e41f4b71Sopenharmony_ci| 6616006  | An error occurs in the DRM system.     |
4979e41f4b71Sopenharmony_ci| 6616007  | The device has revoked DRM privileges.   |
4980e41f4b71Sopenharmony_ci| 6616008  | The DRM license being loaded into the open DRM session has expired.      |
4981e41f4b71Sopenharmony_ci| 6616100  | An error occurs when the DRM processes the key response.     |
4982e41f4b71Sopenharmony_ci
4983e41f4b71Sopenharmony_ci**示例:**
4984e41f4b71Sopenharmony_ci
4985e41f4b71Sopenharmony_ci```ts
4986e41f4b71Sopenharmony_ciaVCastController.on('castControlDrmError', (error: BusinessError) => {
4987e41f4b71Sopenharmony_ci  console.info(`castControlDrmError happened, error code: ${error.code}, error message : ${error.message}.`)
4988e41f4b71Sopenharmony_ci})
4989e41f4b71Sopenharmony_ci```
4990e41f4b71Sopenharmony_ci
4991e41f4b71Sopenharmony_ci### off('castControlDrmError')<sup>13+</sup>
4992e41f4b71Sopenharmony_ci
4993e41f4b71Sopenharmony_cioff(type: 'castControlDrmError', callback?: ErrorCallback): void
4994e41f4b71Sopenharmony_ci
4995e41f4b71Sopenharmony_ci取消监听投播drm的错误事件。
4996e41f4b71Sopenharmony_ci
4997e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 13开始,该接口支持在原子化服务中使用。
4998e41f4b71Sopenharmony_ci
4999e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.AVCast
5000e41f4b71Sopenharmony_ci
5001e41f4b71Sopenharmony_ci**参数:**
5002e41f4b71Sopenharmony_ci
5003e41f4b71Sopenharmony_ci| 参数名   | 类型     | 必填 | 说明                                                         |
5004e41f4b71Sopenharmony_ci| -------- | -------- | ---- | ------------------------------------------------------------ |
5005e41f4b71Sopenharmony_ci| type     | string   | 是   | 	取消对应的监听事件,支持的事件是'castControlDrmError'。 |
5006e41f4b71Sopenharmony_ci| callback | ErrorCallback | 否   | 回调函数。当监听事件取消成功,err为undefined,否则返回错误对象。该参数为可选参数,若不填写该参数,则认为取消所有相关会话的事件监听。 |
5007e41f4b71Sopenharmony_ci
5008e41f4b71Sopenharmony_ci**错误码:**
5009e41f4b71Sopenharmony_ci
5010e41f4b71Sopenharmony_ci| 错误码ID | 错误信息              |
5011e41f4b71Sopenharmony_ci| -------- | --------------------- |
5012e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
5013e41f4b71Sopenharmony_ci
5014e41f4b71Sopenharmony_ci**示例:**
5015e41f4b71Sopenharmony_ci
5016e41f4b71Sopenharmony_ci```ts
5017e41f4b71Sopenharmony_ciaVCastController.off('castControlDrmError');
5018e41f4b71Sopenharmony_ci```
5019e41f4b71Sopenharmony_ci
5020e41f4b71Sopenharmony_ci## CastDisplayState<sup>12+</sup>
5021e41f4b71Sopenharmony_ci
5022e41f4b71Sopenharmony_ci投播显示设备状态的枚举。
5023e41f4b71Sopenharmony_ci
5024e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
5025e41f4b71Sopenharmony_ci
5026e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.ExtendedDisplayCast
5027e41f4b71Sopenharmony_ci
5028e41f4b71Sopenharmony_ci| 名称                        | 值   | 说明         |
5029e41f4b71Sopenharmony_ci| --------------------------- | ---- | ----------- |
5030e41f4b71Sopenharmony_ci| STATE_OFF      | 1    | 设备断开,扩展屏不再显示内容。    |
5031e41f4b71Sopenharmony_ci| STATE_ON      | 2    | 设备连接成功,扩展屏可用。 |
5032e41f4b71Sopenharmony_ci
5033e41f4b71Sopenharmony_ci
5034e41f4b71Sopenharmony_ci## CastDisplayInfo<sup>12+</sup>
5035e41f4b71Sopenharmony_ci
5036e41f4b71Sopenharmony_ci扩展屏投播显示设备相关属性。
5037e41f4b71Sopenharmony_ci
5038e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
5039e41f4b71Sopenharmony_ci
5040e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.ExtendedDisplayCast
5041e41f4b71Sopenharmony_ci
5042e41f4b71Sopenharmony_ci| 名称            | 类型                      | 只读 | 可选 | 说明                                                                  |
5043e41f4b71Sopenharmony_ci| --------------- |-------------------------| ---- | ---- |---------------------------------------------------------------------|
5044e41f4b71Sopenharmony_ci| id            | number                  | 否    | 否    | 投播显示设备的ID,该参数应为整数。  |
5045e41f4b71Sopenharmony_ci| name     | string                  | 否    | 否    | 投播显示设备的名称。           |
5046e41f4b71Sopenharmony_ci| state          | [CastDisplayState](#castdisplaystate12)          | 否    | 否    |投播显示设备状态。            |
5047e41f4b71Sopenharmony_ci| width          | number          | 否    | 否    | 投播显示设备的屏幕宽度,单位为px,该参数应为整数。          |  
5048e41f4b71Sopenharmony_ci| height          | number          | 否    | 否    | 投播显示设备的屏幕高度,单位为px,该参数应为整数。            |  
5049e41f4b71Sopenharmony_ci
5050e41f4b71Sopenharmony_ci## ConnectionState<sup>10+</sup>
5051e41f4b71Sopenharmony_ci
5052e41f4b71Sopenharmony_ci连接状态枚举。
5053e41f4b71Sopenharmony_ci
5054e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
5055e41f4b71Sopenharmony_ci
5056e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
5057e41f4b71Sopenharmony_ci
5058e41f4b71Sopenharmony_ci| 名称                        | 值   | 说明         |
5059e41f4b71Sopenharmony_ci| --------------------------- | ---- | ----------- |
5060e41f4b71Sopenharmony_ci| STATE_CONNECTING      | 0    | 设备连接中    |
5061e41f4b71Sopenharmony_ci| STATE_CONNECTED      | 1    | 设备连接成功 |
5062e41f4b71Sopenharmony_ci| STATE_DISCONNECTED      | 6    | 设备断开连接 |
5063e41f4b71Sopenharmony_ci
5064e41f4b71Sopenharmony_ci## AVMetadata<sup>10+</sup>
5065e41f4b71Sopenharmony_ci
5066e41f4b71Sopenharmony_ci媒体元数据的相关属性。
5067e41f4b71Sopenharmony_ci
5068e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
5069e41f4b71Sopenharmony_ci
5070e41f4b71Sopenharmony_ci| 名称            | 类型                      | 必填 | 说明                                                                  |
5071e41f4b71Sopenharmony_ci| --------------- |-------------------------| ---- |---------------------------------------------------------------------|
5072e41f4b71Sopenharmony_ci| assetId         | string                  | 是   | 媒体ID。歌曲的唯一标识,由应用自定义。<br>**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。                                     |
5073e41f4b71Sopenharmony_ci| title           | string                  | 否   | 标题。<br>**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。                                                                 |
5074e41f4b71Sopenharmony_ci| artist          | string                  | 否   | 艺术家。<br>**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。                                                                |
5075e41f4b71Sopenharmony_ci| author          | string                  | 否   | 专辑作者。<br>**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。                                                               |
5076e41f4b71Sopenharmony_ci| avQueueName<sup>12+</sup>       | string                  | 否   | 歌单(歌曲列表)名称。                                                               |
5077e41f4b71Sopenharmony_ci| avQueueId<sup>11+</sup>       | string                  | 否   | 歌单(歌曲列表)唯一标识Id。                                                               |
5078e41f4b71Sopenharmony_ci| avQueueImage<sup>11+</sup>    | [image.PixelMap](../apis-image-kit/js-apis-image.md#pixelmap7) &#124; string | 否   | 歌单(歌曲列表)封面图,图片的像素数据或者图片路径地址(本地路径或网络路径)。<br>应用通过setAVMetadata设置图片数据,当设置的数据类型为PixelMap时,通过getAVMetadata获取的将为PixelMap。设置为url图片路径,获取的亦为url图片路径  |                       
5079e41f4b71Sopenharmony_ci| album           | string                  | 否   | 专辑名称。<br>**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。                                                               |
5080e41f4b71Sopenharmony_ci| writer          | string                  | 否   | 词作者。<br>**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。                                                                |
5081e41f4b71Sopenharmony_ci| composer        | string                  | 否   | 作曲者。                                                                |
5082e41f4b71Sopenharmony_ci| duration        | number                  | 否   | 媒体时长,单位毫秒(ms)。<br>**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。                                                  |
5083e41f4b71Sopenharmony_ci| mediaImage      | [image.PixelMap](../apis-image-kit/js-apis-image.md#pixelmap7) &#124; string | 否   | 图片的像素数据或者图片路径地址(本地路径或网络路径)。<br>应用通过setAVMetadata设置图片数据,当设置的数据类型为PixelMap时,通过getAVMetadata获取的将为PixelMap。设置为url图片路径,获取的亦为url图片路径  <br>**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。                             |
5084e41f4b71Sopenharmony_ci| publishDate     | Date                    | 否   | 发行日期。                                                             |
5085e41f4b71Sopenharmony_ci| subtitle        | string                  | 否   | 子标题。<br>**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。                                                                |
5086e41f4b71Sopenharmony_ci| description     | string                  | 否   | 媒体描述。<br>**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。                                                               |
5087e41f4b71Sopenharmony_ci| lyric           | string                  | 否   | 媒体歌词内容。应用需将歌词内容拼接为一个字符串传入。<br>字符串长度需小于等于40960字节。<br>**说明:** 系统支持简单版的LRC格式(Simple LRC format)的歌词文本内容。当传入的歌词内容不规范(如出现重复的时间戳等),将导致解析失败以及在系统中显示异常。 |
5088e41f4b71Sopenharmony_ci| previousAssetId | string                  | 否   | 上一首媒体ID。<br>**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。                                                            |
5089e41f4b71Sopenharmony_ci| nextAssetId     | string                  | 否   | 下一首媒体ID。<br>**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。                                                            |
5090e41f4b71Sopenharmony_ci| filter<sup>11+</sup>        | number         | 否   | 当前session支持的协议,默认为TYPE_CAST_PLUS_STREAM。具体取值参考[ProtocolType](#protocoltype11)。<br>**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。                   |
5091e41f4b71Sopenharmony_ci| drmSchemes<sup>12+</sup>        | Array\<string>         | 否   | 当前session支持的DRM方案,取值为DRM方案uuid。|
5092e41f4b71Sopenharmony_ci| skipIntervals<sup>11+</sup>  | [SkipIntervals](#skipintervals11)        | 否   | 快进快退支持的时间间隔,默认为SECONDS_15,即15秒。                            |
5093e41f4b71Sopenharmony_ci|displayTags<sup>11+</sup>     | number                           | 否   | 媒体资源的金标类型,取值参考[DisplayTag](#displaytag11)。                                                          |
5094e41f4b71Sopenharmony_ci
5095e41f4b71Sopenharmony_ci## AVMediaDescription<sup>10+</sup>
5096e41f4b71Sopenharmony_ci
5097e41f4b71Sopenharmony_ci播放列表媒体元数据的相关属性。
5098e41f4b71Sopenharmony_ci
5099e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
5100e41f4b71Sopenharmony_ci
5101e41f4b71Sopenharmony_ci| 名称         | 类型                    | 必填  | 说明                     |
5102e41f4b71Sopenharmony_ci| ------------ | ----------------------- | ---- | ----------------------- |
5103e41f4b71Sopenharmony_ci| assetId      | string                  | 是   | 播放列表媒体ID。<br>**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。          |
5104e41f4b71Sopenharmony_ci| title        | string                  | 否   | 播放列表媒体标题。<br>**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。        |
5105e41f4b71Sopenharmony_ci| subtitle     | string                  | 否   | 播放列表媒体子标题。<br>**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。      |
5106e41f4b71Sopenharmony_ci| description  | string                  | 否   | 播放列表媒体描述的文本。<br>**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。   |
5107e41f4b71Sopenharmony_ci| mediaImage | image.PixelMap \| string   | 否   | 播放列表媒体图片像素数据。<br>**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。 |
5108e41f4b71Sopenharmony_ci| extras       | {[key: string]: Object}    | 否   | 播放列表媒体额外字段。     |
5109e41f4b71Sopenharmony_ci| mediaUri     | string                  | 否   | 播放列表媒体URI。<br>**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。         |
5110e41f4b71Sopenharmony_ci| mediaType     | string                  | 否   | 播放列表媒体类型。<br>**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。         |
5111e41f4b71Sopenharmony_ci| mediaSize     | number                  | 否   | 播放列表媒体的大小。<br>**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。         |
5112e41f4b71Sopenharmony_ci| albumTitle     | string                  | 否   | 播放列表媒体专辑标题。<br>**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。         |
5113e41f4b71Sopenharmony_ci| albumCoverUri     | string                  | 否   | 播放列表媒体专辑标题URI。<br>**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。    |
5114e41f4b71Sopenharmony_ci| lyricContent     | string                  | 否   | 播放列表媒体歌词内容。<br>**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。         |
5115e41f4b71Sopenharmony_ci| lyricUri     | string                  | 否   | 播放列表媒体歌词URI。<br>**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。         |
5116e41f4b71Sopenharmony_ci| artist     | string                  | 否   | 播放列表媒体专辑作者。<br>**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。         |
5117e41f4b71Sopenharmony_ci| fdSrc     | media.AVFileDescriptor        | 否   | 播放列表媒体本地文件的句柄。<br>**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。         |
5118e41f4b71Sopenharmony_ci| dataSrc<sup>12+</sup>     | media.AVDataSrcDescriptor        | 否   | 播放列表数据源描述。         |
5119e41f4b71Sopenharmony_ci| drmScheme<sup>12+</sup>     | string        | 否   | 播放列表媒体支持的DRM方案,由uuid表示。       |
5120e41f4b71Sopenharmony_ci| duration     | number                  | 否   | 播放列表媒体播放时长。<br>**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。         |
5121e41f4b71Sopenharmony_ci| startPosition     | number                  | 否   | 播放列表媒体起始播放位置。<br>**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。         |
5122e41f4b71Sopenharmony_ci| creditsPosition     | number                  | 否   | 播放列表媒体的片尾播放位置。<br>**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。         |
5123e41f4b71Sopenharmony_ci| appName     | string                  | 否   | 播放列表提供的应用的名字。<br>**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。         |
5124e41f4b71Sopenharmony_ci|displayTags<sup>11+</sup>     | number | 否   | 媒体资源的金标类型,取值参考[DisplayTag](#displaytag11)。<br>**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。        |
5125e41f4b71Sopenharmony_ci
5126e41f4b71Sopenharmony_ci## AVQueueItem<sup>10+</sup>
5127e41f4b71Sopenharmony_ci
5128e41f4b71Sopenharmony_ci播放列表中单项的相关属性。
5129e41f4b71Sopenharmony_ci
5130e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
5131e41f4b71Sopenharmony_ci
5132e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
5133e41f4b71Sopenharmony_ci
5134e41f4b71Sopenharmony_ci| 名称         | 类型                                        | 必填 | 说明                        |
5135e41f4b71Sopenharmony_ci| ------------ | ------------------------------------------ | ---- | --------------------------- |
5136e41f4b71Sopenharmony_ci| itemId       | number                                     | 是   | 播放列表中单项的ID。          |
5137e41f4b71Sopenharmony_ci| description  | [AVMediaDescription](#avmediadescription10)  | 否   | 播放列表中单项的媒体元数据。   |
5138e41f4b71Sopenharmony_ci
5139e41f4b71Sopenharmony_ci## AVPlaybackState<sup>10+</sup>
5140e41f4b71Sopenharmony_ci
5141e41f4b71Sopenharmony_ci媒体播放状态的相关属性。
5142e41f4b71Sopenharmony_ci
5143e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
5144e41f4b71Sopenharmony_ci
5145e41f4b71Sopenharmony_ci| 名称         | 类型                                  | 必填 | 说明     |
5146e41f4b71Sopenharmony_ci| ------------ | ------------------------------------- | ---- | ------- |
5147e41f4b71Sopenharmony_ci| state        | [PlaybackState](#playbackstate10)       | 否   | 播放状态<br>**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。 |
5148e41f4b71Sopenharmony_ci| speed        | number                                | 否   | 播放倍速<br>**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。 |
5149e41f4b71Sopenharmony_ci| position     | [PlaybackPosition](#playbackposition10) | 否   | 播放位置<br>**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。 |
5150e41f4b71Sopenharmony_ci| bufferedTime | number                                | 否   | 缓冲时间<br>**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。 |
5151e41f4b71Sopenharmony_ci| loopMode     | [LoopMode](#loopmode10)                 | 否   | 循环模式<br>**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。 |
5152e41f4b71Sopenharmony_ci| isFavorite   | boolean                               | 否   | 是否收藏<br>**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。 |
5153e41f4b71Sopenharmony_ci| activeItemId<sup>10+</sup> | number                  | 否   | 正在播放的媒体Id<br>**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。 |
5154e41f4b71Sopenharmony_ci| volume<sup>10+</sup> | number                  | 否   | 正在播放的媒体音量<br>**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。 |
5155e41f4b71Sopenharmony_ci| maxVolume<sup>11+</sup> | number                    | 否   | 最大音量<br>**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。 |
5156e41f4b71Sopenharmony_ci| muted<sup>11+</sup>     | boolean                   | 否   | 当前静音状态,true表示静音<br>**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。 |
5157e41f4b71Sopenharmony_ci| duration<sup>11+</sup>     | number                   | 否   | 当前媒体资源的时长 |
5158e41f4b71Sopenharmony_ci| videoWidth<sup>11+</sup>  | number                  | 否   | 媒体资源的视频宽度,单位为像素(px)。<br>**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。 |
5159e41f4b71Sopenharmony_ci| videoHeight<sup>11+</sup> |  number                 | 否   | 媒体资源的视频高度,单位为像素(px)。<br>**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。 |
5160e41f4b71Sopenharmony_ci| extras<sup>10+</sup> | {[key: string]: Object}       | 否   | 自定义媒体数据<br>**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。 |
5161e41f4b71Sopenharmony_ci
5162e41f4b71Sopenharmony_ci## PlaybackPosition<sup>10+</sup>
5163e41f4b71Sopenharmony_ci
5164e41f4b71Sopenharmony_ci媒体播放位置的相关属性。
5165e41f4b71Sopenharmony_ci
5166e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
5167e41f4b71Sopenharmony_ci
5168e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
5169e41f4b71Sopenharmony_ci
5170e41f4b71Sopenharmony_ci| 名称        | 类型   | 必填 | 说明               |
5171e41f4b71Sopenharmony_ci| ----------- | ------ | ---- | ------------------ |
5172e41f4b71Sopenharmony_ci| elapsedTime | number | 是   | 已用时间,单位毫秒(ms)。 |
5173e41f4b71Sopenharmony_ci| updateTime  | number | 是   | 更新时间,单位毫秒(ms)。 |
5174e41f4b71Sopenharmony_ci
5175e41f4b71Sopenharmony_ci## CallMetadata<sup>11+</sup>
5176e41f4b71Sopenharmony_ci
5177e41f4b71Sopenharmony_ci通话会话元数据相关属性。
5178e41f4b71Sopenharmony_ci
5179e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
5180e41f4b71Sopenharmony_ci
5181e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
5182e41f4b71Sopenharmony_ci
5183e41f4b71Sopenharmony_ci| 名称            | 类型                      | 必填 | 说明                                                                  |
5184e41f4b71Sopenharmony_ci| --------------- |-------------------------| ---- |---------------------------------------------------------------------|
5185e41f4b71Sopenharmony_ci| name            | string                  | 否    | 来电人姓名(别名)。    |                                                                                                                      
5186e41f4b71Sopenharmony_ci| phoneNumber     | string                  | 否    | 来电电话号码            |                                                   
5187e41f4b71Sopenharmony_ci| avatar          | [image.PixelMap](../apis-image-kit/js-apis-image.md#pixelmap7)          | 否    | 来电人头像。            |                                                   
5188e41f4b71Sopenharmony_ci
5189e41f4b71Sopenharmony_ci## AVCallState<sup>11+</sup>
5190e41f4b71Sopenharmony_ci
5191e41f4b71Sopenharmony_ci通话状态相关属性。
5192e41f4b71Sopenharmony_ci
5193e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
5194e41f4b71Sopenharmony_ci
5195e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
5196e41f4b71Sopenharmony_ci
5197e41f4b71Sopenharmony_ci| 名称            | 类型                      | 必填 | 说明                                                                  |
5198e41f4b71Sopenharmony_ci| --------------- |-------------------------  | ---- |---------------------------------------------------------------------|
5199e41f4b71Sopenharmony_ci| state           | [CallState](#callstate11)                 | 是    | 当前通话状态。      |                                                                                                                      
5200e41f4b71Sopenharmony_ci| muted           | boolean                   | 是    | 通话mic是否静音。 <br>true:静音。 <br>false:不是静音。|                                                                  
5201e41f4b71Sopenharmony_ci 
5202e41f4b71Sopenharmony_ci## CallState<sup>11+</sup>
5203e41f4b71Sopenharmony_ci
5204e41f4b71Sopenharmony_ci表示通话状态的枚举。
5205e41f4b71Sopenharmony_ci
5206e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
5207e41f4b71Sopenharmony_ci
5208e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
5209e41f4b71Sopenharmony_ci
5210e41f4b71Sopenharmony_ci| 名称                        | 值   | 说明      |
5211e41f4b71Sopenharmony_ci| --------------------------  | ---- | -------- |
5212e41f4b71Sopenharmony_ci| CALL_STATE_IDLE             | 0    | 空闲状态   |
5213e41f4b71Sopenharmony_ci| CALL_STATE_INCOMING         | 1    | 来电     |
5214e41f4b71Sopenharmony_ci| CALL_STATE_ACTIVE           | 2    | 接通     |
5215e41f4b71Sopenharmony_ci| CALL_STATE_DIALING          | 3    | 响铃     |
5216e41f4b71Sopenharmony_ci| CALL_STATE_WAITING          | 4    | 等待接通  |
5217e41f4b71Sopenharmony_ci| CALL_STATE_HOLDING          | 5    | 保持     |
5218e41f4b71Sopenharmony_ci| CALL_STATE_DISCONNECTING    | 6    | 挂断     |
5219e41f4b71Sopenharmony_ci
5220e41f4b71Sopenharmony_ci## DisplayTag<sup>11+</sup>
5221e41f4b71Sopenharmony_ci
5222e41f4b71Sopenharmony_ci枚举,表示当前媒体资源的金标,即应用媒体音源的特殊类型标识。
5223e41f4b71Sopenharmony_ci
5224e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
5225e41f4b71Sopenharmony_ci
5226e41f4b71Sopenharmony_ci| 名称                        | 值   | 说明           |
5227e41f4b71Sopenharmony_ci| --------------------------  | ---- | ------------ |
5228e41f4b71Sopenharmony_ci| TAG_AUDIO_VIVID             | 1    | AUDIO VIVID  |
5229e41f4b71Sopenharmony_ci
5230e41f4b71Sopenharmony_ci## AVCastCategory<sup>10+</sup>
5231e41f4b71Sopenharmony_ci
5232e41f4b71Sopenharmony_ci投播的类别枚举。
5233e41f4b71Sopenharmony_ci
5234e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
5235e41f4b71Sopenharmony_ci
5236e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.AVCast
5237e41f4b71Sopenharmony_ci
5238e41f4b71Sopenharmony_ci| 名称                        | 值   | 说明         |
5239e41f4b71Sopenharmony_ci| --------------------------- | ---- | ----------- |
5240e41f4b71Sopenharmony_ci| CATEGORY_LOCAL      | 0    | 本地播放,默认播放设备,声音从本机或者连接的蓝牙耳机设备出声。     |
5241e41f4b71Sopenharmony_ci| CATEGORY_REMOTE      | 1    | 远端播放,远端播放设备,声音从其他设备发出声音或者画面。  |
5242e41f4b71Sopenharmony_ci
5243e41f4b71Sopenharmony_ci## DeviceType<sup>10+</sup>
5244e41f4b71Sopenharmony_ci
5245e41f4b71Sopenharmony_ci播放设备的类型枚举。
5246e41f4b71Sopenharmony_ci
5247e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
5248e41f4b71Sopenharmony_ci
5249e41f4b71Sopenharmony_ci| 名称                        | 值   | 说明         |
5250e41f4b71Sopenharmony_ci| --------------------------- | ---- | ----------- |
5251e41f4b71Sopenharmony_ci| DEVICE_TYPE_LOCAL      | 0    | 本地播放类型 <br> **系统能力:** SystemCapability.Multimedia.AVSession.Core|
5252e41f4b71Sopenharmony_ci| DEVICE_TYPE_BLUETOOTH      | 10   | 蓝牙设备 <br> **系统能力:** SystemCapability.Multimedia.AVSession.Core |
5253e41f4b71Sopenharmony_ci| DEVICE_TYPE_TV      | 2    | 电视 <br> **系统能力:** SystemCapability.Multimedia.AVSession.AVCast |
5254e41f4b71Sopenharmony_ci| DEVICE_TYPE_SMART_SPEAKER      | 3   | 音箱设备 <br> **系统能力:** SystemCapability.Multimedia.AVSession.AVCast |
5255e41f4b71Sopenharmony_ci
5256e41f4b71Sopenharmony_ci## DeviceInfo<sup>10+</sup>
5257e41f4b71Sopenharmony_ci
5258e41f4b71Sopenharmony_ci播放设备的相关信息。
5259e41f4b71Sopenharmony_ci
5260e41f4b71Sopenharmony_ci| 名称       | 类型           | 必填 | 说明                   |
5261e41f4b71Sopenharmony_ci| ---------- | -------------- | ---- | ---------------------- |
5262e41f4b71Sopenharmony_ci| castCategory   | AVCastCategory        | 是   | 投播的类别。  <br> **系统能力:** SystemCapability.Multimedia.AVSession.Core  <br>**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。|
5263e41f4b71Sopenharmony_ci| deviceId   | string | 是   | 播放设备的ID。<br> **系统能力:** SystemCapability.Multimedia.AVSession.Core  <br>**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。|
5264e41f4b71Sopenharmony_ci| deviceName | string | 是   | 播放设备的名称。<br>**系统能力:** SystemCapability.Multimedia.AVSession.Core <br>**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。|
5265e41f4b71Sopenharmony_ci| deviceType | DeviceType | 是   | 播放设备的类型。<br>**系统能力:** SystemCapability.Multimedia.AVSession.Core <br>**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。|
5266e41f4b71Sopenharmony_ci| supportedProtocols<sup>11+</sup> | number | 否   | 播放设备支持的协议。默认为TYPE_LOCAL。具体取值参考[ProtocolType](#protocoltype11)。 <br> **系统能力:** SystemCapability.Multimedia.AVSession.AVCast   <br>**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。 |
5267e41f4b71Sopenharmony_ci| manufacturer<sup>13+</sup> | string | 否   | 播放设备生产厂家。 <br> **系统能力:** SystemCapability.Multimedia.AVSession.AVCast  <br>**原子化服务API:** 从API version 13开始,该接口支持在原子化服务中使用。|
5268e41f4b71Sopenharmony_ci| modelName<sup>13+</sup> | string | 否   | 播放设备型号名称。 <br> **系统能力:** SystemCapability.Multimedia.AVSession.AVCast  <br>**原子化服务API:** 从API version 13开始,该接口支持在原子化服务中使用。|
5269e41f4b71Sopenharmony_ci
5270e41f4b71Sopenharmony_ci## OutputDeviceInfo<sup>10+</sup>
5271e41f4b71Sopenharmony_ci
5272e41f4b71Sopenharmony_ci播放设备的相关信息。
5273e41f4b71Sopenharmony_ci
5274e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
5275e41f4b71Sopenharmony_ci
5276e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
5277e41f4b71Sopenharmony_ci
5278e41f4b71Sopenharmony_ci| 名称       | 类型           | 必填 | 说明                   |
5279e41f4b71Sopenharmony_ci| ---------- | -------------- | ---- | ---------------------- |
5280e41f4b71Sopenharmony_ci| devices | Array\<DeviceInfo\> | 是   | 播放设备的集合。    |
5281e41f4b71Sopenharmony_ci
5282e41f4b71Sopenharmony_ci## LoopMode<sup>10+</sup>
5283e41f4b71Sopenharmony_ci
5284e41f4b71Sopenharmony_ci表示媒体播放循环模式的枚举。
5285e41f4b71Sopenharmony_ci
5286e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
5287e41f4b71Sopenharmony_ci
5288e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
5289e41f4b71Sopenharmony_ci
5290e41f4b71Sopenharmony_ci| 名称               | 值   | 说明     |
5291e41f4b71Sopenharmony_ci| ------------------ | ---- | -------- |
5292e41f4b71Sopenharmony_ci| LOOP_MODE_SEQUENCE | 0    | 顺序播放 |
5293e41f4b71Sopenharmony_ci| LOOP_MODE_SINGLE   | 1    | 单曲循环 |
5294e41f4b71Sopenharmony_ci| LOOP_MODE_LIST     | 2    | 表单循环 |
5295e41f4b71Sopenharmony_ci| LOOP_MODE_SHUFFLE  | 3    | 随机播放 |
5296e41f4b71Sopenharmony_ci| LOOP_MODE_CUSTOM<sup>11+</sup>   | 4    | 自定义播放  |
5297e41f4b71Sopenharmony_ci
5298e41f4b71Sopenharmony_ci## PlaybackState<sup>10+</sup>
5299e41f4b71Sopenharmony_ci
5300e41f4b71Sopenharmony_ci表示媒体播放状态的枚举。
5301e41f4b71Sopenharmony_ci
5302e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
5303e41f4b71Sopenharmony_ci
5304e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
5305e41f4b71Sopenharmony_ci
5306e41f4b71Sopenharmony_ci| 名称                        | 值   | 说明         |
5307e41f4b71Sopenharmony_ci| --------------------------- | ---- | ----------- |
5308e41f4b71Sopenharmony_ci| PLAYBACK_STATE_INITIAL      | 0    | 初始状态     |
5309e41f4b71Sopenharmony_ci| PLAYBACK_STATE_PREPARE      | 1    | 播放准备状态  |
5310e41f4b71Sopenharmony_ci| PLAYBACK_STATE_PLAY         | 2    | 正在播放     |
5311e41f4b71Sopenharmony_ci| PLAYBACK_STATE_PAUSE        | 3    | 暂停         |
5312e41f4b71Sopenharmony_ci| PLAYBACK_STATE_FAST_FORWARD | 4    | 快进         |
5313e41f4b71Sopenharmony_ci| PLAYBACK_STATE_REWIND       | 5    | 快退         |
5314e41f4b71Sopenharmony_ci| PLAYBACK_STATE_STOP         | 6    | 停止         |
5315e41f4b71Sopenharmony_ci| PLAYBACK_STATE_COMPLETED    | 7    | 播放完成     |
5316e41f4b71Sopenharmony_ci| PLAYBACK_STATE_RELEASED     | 8    | 释放         |
5317e41f4b71Sopenharmony_ci| PLAYBACK_STATE_ERROR        | 9    | 错误         |
5318e41f4b71Sopenharmony_ci| PLAYBACK_STATE_IDLE<sup>11+</sup>        | 10    | 空闲     |
5319e41f4b71Sopenharmony_ci| PLAYBACK_STATE_BUFFERING<sup>11+</sup>         | 11    | 缓冲   |
5320e41f4b71Sopenharmony_ci
5321e41f4b71Sopenharmony_ci## AVSessionController<sup>10+</sup>
5322e41f4b71Sopenharmony_ci
5323e41f4b71Sopenharmony_ciAVSessionController控制器可查看会话ID,并可完成对会话发送命令及事件,获取会话元数据,播放状态信息等操作。
5324e41f4b71Sopenharmony_ci
5325e41f4b71Sopenharmony_ci### 属性
5326e41f4b71Sopenharmony_ci
5327e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
5328e41f4b71Sopenharmony_ci
5329e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
5330e41f4b71Sopenharmony_ci
5331e41f4b71Sopenharmony_ci| 名称      | 类型   | 可读 | 可写 | 说明                                    |
5332e41f4b71Sopenharmony_ci| :-------- | :----- | :--- | :--- | :-------------------------------------- |
5333e41f4b71Sopenharmony_ci| sessionId | string | 是   | 否   | AVSessionController对象唯一的会话标识。 |
5334e41f4b71Sopenharmony_ci
5335e41f4b71Sopenharmony_ci
5336e41f4b71Sopenharmony_ci**示例:**
5337e41f4b71Sopenharmony_ci
5338e41f4b71Sopenharmony_ci```ts
5339e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
5340e41f4b71Sopenharmony_ci
5341e41f4b71Sopenharmony_cilet AVSessionController: avSession.AVSessionController;
5342e41f4b71Sopenharmony_ciavSession.createController(currentAVSession.sessionId).then((controller: avSession.AVSessionController) => {
5343e41f4b71Sopenharmony_ci  AVSessionController = controller;
5344e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
5345e41f4b71Sopenharmony_ci  console.error(`CreateController BusinessError: code: ${err.code}, message: ${err.message}`);
5346e41f4b71Sopenharmony_ci});
5347e41f4b71Sopenharmony_ci```
5348e41f4b71Sopenharmony_ci
5349e41f4b71Sopenharmony_ci### getAVPlaybackState<sup>10+</sup>
5350e41f4b71Sopenharmony_ci
5351e41f4b71Sopenharmony_cigetAVPlaybackState(callback: AsyncCallback\<AVPlaybackState>): void
5352e41f4b71Sopenharmony_ci
5353e41f4b71Sopenharmony_ci获取当前的远端播放状态。结果通过callback异步回调方式返回。
5354e41f4b71Sopenharmony_ci
5355e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
5356e41f4b71Sopenharmony_ci
5357e41f4b71Sopenharmony_ci**参数:**
5358e41f4b71Sopenharmony_ci
5359e41f4b71Sopenharmony_ci| 参数名    | 类型                                                        | 必填 | 说明                                                         |
5360e41f4b71Sopenharmony_ci| --------- | ----------------------------------------------------------- | ---- | ------------------------------------------------------------ |
5361e41f4b71Sopenharmony_ci| callback  | AsyncCallback<[AVPlaybackState](#avplaybackstate10)\> | 是   | 回调函数,返回远端播放状态。 |
5362e41f4b71Sopenharmony_ci
5363e41f4b71Sopenharmony_ci**错误码:**
5364e41f4b71Sopenharmony_ci
5365e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
5366e41f4b71Sopenharmony_ci
5367e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
5368e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
5369e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
5370e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
5371e41f4b71Sopenharmony_ci| 6600103  | The session controller does not exist. |
5372e41f4b71Sopenharmony_ci
5373e41f4b71Sopenharmony_ci**示例:**
5374e41f4b71Sopenharmony_ci
5375e41f4b71Sopenharmony_ci```ts
5376e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
5377e41f4b71Sopenharmony_ci
5378e41f4b71Sopenharmony_ciavsessionController.getAVPlaybackState((err: BusinessError, state: avSession.AVPlaybackState) => {
5379e41f4b71Sopenharmony_ci  if (err) {
5380e41f4b71Sopenharmony_ci    console.error(`getAVPlaybackState BusinessError: code: ${err.code}, message: ${err.message}`);
5381e41f4b71Sopenharmony_ci  } else {
5382e41f4b71Sopenharmony_ci    console.info('getAVPlaybackState : SUCCESS');
5383e41f4b71Sopenharmony_ci  }
5384e41f4b71Sopenharmony_ci});
5385e41f4b71Sopenharmony_ci```
5386e41f4b71Sopenharmony_ci
5387e41f4b71Sopenharmony_ci### getAVPlaybackState<sup>10+</sup>
5388e41f4b71Sopenharmony_ci
5389e41f4b71Sopenharmony_cigetAVPlaybackState(): Promise\<AVPlaybackState>
5390e41f4b71Sopenharmony_ci
5391e41f4b71Sopenharmony_ci获取当前的远端播放状态。结果通过Promise异步回调方式返回。
5392e41f4b71Sopenharmony_ci
5393e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
5394e41f4b71Sopenharmony_ci
5395e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
5396e41f4b71Sopenharmony_ci
5397e41f4b71Sopenharmony_ci**返回值:**
5398e41f4b71Sopenharmony_ci
5399e41f4b71Sopenharmony_ci| 类型                                                        | 说明                                                         |
5400e41f4b71Sopenharmony_ci| --------- | ------------------------------------------------------------ |
5401e41f4b71Sopenharmony_ci| Promise<[AVPlaybackState](#avplaybackstate10)\>  | Promise对象。返回远端播放状态。  |
5402e41f4b71Sopenharmony_ci
5403e41f4b71Sopenharmony_ci**错误码:**
5404e41f4b71Sopenharmony_ci
5405e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
5406e41f4b71Sopenharmony_ci
5407e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
5408e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
5409e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
5410e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
5411e41f4b71Sopenharmony_ci| 6600103  | The session controller does not exist. |
5412e41f4b71Sopenharmony_ci
5413e41f4b71Sopenharmony_ci**示例:**
5414e41f4b71Sopenharmony_ci
5415e41f4b71Sopenharmony_ci```ts
5416e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
5417e41f4b71Sopenharmony_ci
5418e41f4b71Sopenharmony_ciavsessionController.getAVPlaybackState().then((state: avSession.AVPlaybackState) => {
5419e41f4b71Sopenharmony_ci  console.info('getAVPlaybackState : SUCCESS');
5420e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
5421e41f4b71Sopenharmony_ci  console.error(`getAVPlaybackState BusinessError: code: ${err.code}, message: ${err.message}`);
5422e41f4b71Sopenharmony_ci});
5423e41f4b71Sopenharmony_ci```
5424e41f4b71Sopenharmony_ci
5425e41f4b71Sopenharmony_ci### getAVMetadata<sup>10+</sup>
5426e41f4b71Sopenharmony_ci
5427e41f4b71Sopenharmony_cigetAVMetadata(): Promise\<AVMetadata>
5428e41f4b71Sopenharmony_ci
5429e41f4b71Sopenharmony_ci获取会话元数据。结果通过Promise异步回调方式返回。
5430e41f4b71Sopenharmony_ci
5431e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
5432e41f4b71Sopenharmony_ci
5433e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
5434e41f4b71Sopenharmony_ci
5435e41f4b71Sopenharmony_ci**返回值:**
5436e41f4b71Sopenharmony_ci
5437e41f4b71Sopenharmony_ci| 类型                                | 说明                          |
5438e41f4b71Sopenharmony_ci| ----------------------------------- | ----------------------------- |
5439e41f4b71Sopenharmony_ci| Promise<[AVMetadata](#avmetadata10)\> | Promise对象,返回会话元数据。 |
5440e41f4b71Sopenharmony_ci
5441e41f4b71Sopenharmony_ci**错误码:**
5442e41f4b71Sopenharmony_ci
5443e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
5444e41f4b71Sopenharmony_ci
5445e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
5446e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
5447e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
5448e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
5449e41f4b71Sopenharmony_ci| 6600103  | The session controller does not exist. |
5450e41f4b71Sopenharmony_ci
5451e41f4b71Sopenharmony_ci**示例:**
5452e41f4b71Sopenharmony_ci
5453e41f4b71Sopenharmony_ci```ts
5454e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
5455e41f4b71Sopenharmony_ci
5456e41f4b71Sopenharmony_ciavsessionController.getAVMetadata().then((metadata: avSession.AVMetadata) => {
5457e41f4b71Sopenharmony_ci  console.info(`GetAVMetadata : SUCCESS : assetId : ${metadata.assetId}`);
5458e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
5459e41f4b71Sopenharmony_ci  console.error(`GetAVMetadata BusinessError: code: ${err.code}, message: ${err.message}`);
5460e41f4b71Sopenharmony_ci});
5461e41f4b71Sopenharmony_ci```
5462e41f4b71Sopenharmony_ci
5463e41f4b71Sopenharmony_ci### getAVMetadata<sup>10+</sup>
5464e41f4b71Sopenharmony_ci
5465e41f4b71Sopenharmony_cigetAVMetadata(callback: AsyncCallback\<AVMetadata>): void
5466e41f4b71Sopenharmony_ci
5467e41f4b71Sopenharmony_ci获取会话元数据。结果通过callback异步回调方式返回。
5468e41f4b71Sopenharmony_ci
5469e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
5470e41f4b71Sopenharmony_ci
5471e41f4b71Sopenharmony_ci**参数:**
5472e41f4b71Sopenharmony_ci
5473e41f4b71Sopenharmony_ci| 参数名   | 类型                                      | 必填 | 说明                       |
5474e41f4b71Sopenharmony_ci| -------- | ----------------------------------------- | ---- | -------------------------- |
5475e41f4b71Sopenharmony_ci| callback | AsyncCallback<[AVMetadata](#avmetadata10)\> | 是   | 回调函数,返回会话元数据。 |
5476e41f4b71Sopenharmony_ci
5477e41f4b71Sopenharmony_ci**错误码:**
5478e41f4b71Sopenharmony_ci
5479e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
5480e41f4b71Sopenharmony_ci
5481e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
5482e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
5483e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
5484e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
5485e41f4b71Sopenharmony_ci| 6600103  | The session controller does not exist. |
5486e41f4b71Sopenharmony_ci
5487e41f4b71Sopenharmony_ci**示例:**
5488e41f4b71Sopenharmony_ci
5489e41f4b71Sopenharmony_ci```ts
5490e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
5491e41f4b71Sopenharmony_ci
5492e41f4b71Sopenharmony_ciavsessionController.getAVMetadata((err: BusinessError, metadata: avSession.AVMetadata) => {
5493e41f4b71Sopenharmony_ci  if (err) {
5494e41f4b71Sopenharmony_ci    console.error(`GetAVMetadata BusinessError: code: ${err.code}, message: ${err.message}`);
5495e41f4b71Sopenharmony_ci  } else {
5496e41f4b71Sopenharmony_ci    console.info(`GetAVMetadata : SUCCESS : assetId : ${metadata.assetId}`);
5497e41f4b71Sopenharmony_ci  }
5498e41f4b71Sopenharmony_ci});
5499e41f4b71Sopenharmony_ci```
5500e41f4b71Sopenharmony_ci
5501e41f4b71Sopenharmony_ci### getAVQueueTitle<sup>10+</sup>
5502e41f4b71Sopenharmony_ci
5503e41f4b71Sopenharmony_cigetAVQueueTitle(): Promise\<string>
5504e41f4b71Sopenharmony_ci
5505e41f4b71Sopenharmony_ci获取当前会话播放列表的名称。结果通过Promise异步回调方式返回。
5506e41f4b71Sopenharmony_ci
5507e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
5508e41f4b71Sopenharmony_ci
5509e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
5510e41f4b71Sopenharmony_ci
5511e41f4b71Sopenharmony_ci**返回值:**
5512e41f4b71Sopenharmony_ci
5513e41f4b71Sopenharmony_ci| 类型             | 说明                           |
5514e41f4b71Sopenharmony_ci| ---------------- | ----------------------------- |
5515e41f4b71Sopenharmony_ci| Promise<string\> | Promise对象。返回播放列表名称。 |
5516e41f4b71Sopenharmony_ci
5517e41f4b71Sopenharmony_ci**错误码:**
5518e41f4b71Sopenharmony_ci
5519e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
5520e41f4b71Sopenharmony_ci
5521e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
5522e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
5523e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
5524e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
5525e41f4b71Sopenharmony_ci| 6600103  | The session controller does not exist. |
5526e41f4b71Sopenharmony_ci
5527e41f4b71Sopenharmony_ci**示例:**
5528e41f4b71Sopenharmony_ci
5529e41f4b71Sopenharmony_ci```ts
5530e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
5531e41f4b71Sopenharmony_ci
5532e41f4b71Sopenharmony_ciavsessionController.getAVQueueTitle().then((title: string) => {
5533e41f4b71Sopenharmony_ci  console.info(`GetAVQueueTitle : SUCCESS : title : ${title}`);
5534e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
5535e41f4b71Sopenharmony_ci  console.error(`GetAVQueueTitle BusinessError: code: ${err.code}, message: ${err.message}`);
5536e41f4b71Sopenharmony_ci});
5537e41f4b71Sopenharmony_ci```
5538e41f4b71Sopenharmony_ci
5539e41f4b71Sopenharmony_ci### getAVQueueTitle<sup>10+</sup>
5540e41f4b71Sopenharmony_ci
5541e41f4b71Sopenharmony_cigetAVQueueTitle(callback: AsyncCallback\<string>): void
5542e41f4b71Sopenharmony_ci
5543e41f4b71Sopenharmony_ci获取当前播放列表的名称。结果通过callback异步回调方式返回。
5544e41f4b71Sopenharmony_ci
5545e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
5546e41f4b71Sopenharmony_ci
5547e41f4b71Sopenharmony_ci**参数:**
5548e41f4b71Sopenharmony_ci
5549e41f4b71Sopenharmony_ci| 参数名   | 类型                    | 必填 | 说明                      |
5550e41f4b71Sopenharmony_ci| -------- | ---------------------- | ---- | ------------------------- |
5551e41f4b71Sopenharmony_ci| callback | AsyncCallback<string\> | 是   | 回调函数,返回播放列表名称。 |
5552e41f4b71Sopenharmony_ci
5553e41f4b71Sopenharmony_ci**错误码:**
5554e41f4b71Sopenharmony_ci
5555e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
5556e41f4b71Sopenharmony_ci
5557e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
5558e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
5559e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
5560e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
5561e41f4b71Sopenharmony_ci| 6600103  | The session controller does not exist. |
5562e41f4b71Sopenharmony_ci
5563e41f4b71Sopenharmony_ci**示例:**
5564e41f4b71Sopenharmony_ci
5565e41f4b71Sopenharmony_ci```ts
5566e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
5567e41f4b71Sopenharmony_ci
5568e41f4b71Sopenharmony_ciavsessionController.getAVQueueTitle((err: BusinessError, title: string) => {
5569e41f4b71Sopenharmony_ci  if (err) {
5570e41f4b71Sopenharmony_ci    console.error(`GetAVQueueTitle BusinessError: code: ${err.code}, message: ${err.message}`);
5571e41f4b71Sopenharmony_ci  } else {
5572e41f4b71Sopenharmony_ci    console.info(`GetAVQueueTitle : SUCCESS : title : ${title}`);
5573e41f4b71Sopenharmony_ci  }
5574e41f4b71Sopenharmony_ci});
5575e41f4b71Sopenharmony_ci```
5576e41f4b71Sopenharmony_ci
5577e41f4b71Sopenharmony_ci### getAVQueueItems<sup>10+</sup>
5578e41f4b71Sopenharmony_ci
5579e41f4b71Sopenharmony_cigetAVQueueItems(): Promise\<Array\<AVQueueItem>>
5580e41f4b71Sopenharmony_ci
5581e41f4b71Sopenharmony_ci获取当前会话播放列表相关信息。结果通过Promise异步回调方式返回。
5582e41f4b71Sopenharmony_ci
5583e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
5584e41f4b71Sopenharmony_ci
5585e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
5586e41f4b71Sopenharmony_ci
5587e41f4b71Sopenharmony_ci**返回值:**
5588e41f4b71Sopenharmony_ci
5589e41f4b71Sopenharmony_ci| 类型                                          | 说明                           |
5590e41f4b71Sopenharmony_ci| --------------------------------------------- | ----------------------------- |
5591e41f4b71Sopenharmony_ci| Promise<Array<[AVQueueItem](#avqueueitem10)\>\> | Promise对象。返回播放列表队列。 |
5592e41f4b71Sopenharmony_ci
5593e41f4b71Sopenharmony_ci**错误码:**
5594e41f4b71Sopenharmony_ci
5595e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
5596e41f4b71Sopenharmony_ci
5597e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
5598e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
5599e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
5600e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
5601e41f4b71Sopenharmony_ci| 6600103  | The session controller does not exist. |
5602e41f4b71Sopenharmony_ci
5603e41f4b71Sopenharmony_ci**示例:**
5604e41f4b71Sopenharmony_ci
5605e41f4b71Sopenharmony_ci```ts
5606e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
5607e41f4b71Sopenharmony_ci
5608e41f4b71Sopenharmony_ciavsessionController.getAVQueueItems().then((items: avSession.AVQueueItem[]) => {
5609e41f4b71Sopenharmony_ci  console.info(`GetAVQueueItems : SUCCESS : length : ${items.length}`);
5610e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
5611e41f4b71Sopenharmony_ci  console.error(`GetAVQueueItems BusinessError: code: ${err.code}, message: ${err.message}`);
5612e41f4b71Sopenharmony_ci});
5613e41f4b71Sopenharmony_ci```
5614e41f4b71Sopenharmony_ci
5615e41f4b71Sopenharmony_ci### getAVQueueItems<sup>10+</sup>
5616e41f4b71Sopenharmony_ci
5617e41f4b71Sopenharmony_cigetAVQueueItems(callback: AsyncCallback\<Array\<AVQueueItem>>): void
5618e41f4b71Sopenharmony_ci
5619e41f4b71Sopenharmony_ci获取当前播放列表相关信息。结果通过callback异步回调方式返回。
5620e41f4b71Sopenharmony_ci
5621e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
5622e41f4b71Sopenharmony_ci
5623e41f4b71Sopenharmony_ci**参数:**
5624e41f4b71Sopenharmony_ci
5625e41f4b71Sopenharmony_ci| 参数名   | 类型                                                 | 必填 | 说明                      |
5626e41f4b71Sopenharmony_ci| -------- | --------------------------------------------------- | ---- | ------------------------- |
5627e41f4b71Sopenharmony_ci| callback | AsyncCallback<Array<[AVQueueItem](#avqueueitem10)\>\> | 是   | 回调函数,返回播放列表队列。 |
5628e41f4b71Sopenharmony_ci
5629e41f4b71Sopenharmony_ci**错误码:**
5630e41f4b71Sopenharmony_ci
5631e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
5632e41f4b71Sopenharmony_ci
5633e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
5634e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
5635e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
5636e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
5637e41f4b71Sopenharmony_ci| 6600103  | The session controller does not exist. |
5638e41f4b71Sopenharmony_ci
5639e41f4b71Sopenharmony_ci**示例:**
5640e41f4b71Sopenharmony_ci
5641e41f4b71Sopenharmony_ci```ts
5642e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
5643e41f4b71Sopenharmony_ci
5644e41f4b71Sopenharmony_ciavsessionController.getAVQueueItems((err: BusinessError, items: avSession.AVQueueItem[]) => {
5645e41f4b71Sopenharmony_ci  if (err) {
5646e41f4b71Sopenharmony_ci    console.error(`GetAVQueueItems BusinessError: code: ${err.code}, message: ${err.message}`);
5647e41f4b71Sopenharmony_ci  } else {
5648e41f4b71Sopenharmony_ci    console.info(`GetAVQueueItems : SUCCESS : length : ${items.length}`);
5649e41f4b71Sopenharmony_ci  }
5650e41f4b71Sopenharmony_ci});
5651e41f4b71Sopenharmony_ci```
5652e41f4b71Sopenharmony_ci
5653e41f4b71Sopenharmony_ci### skipToQueueItem<sup>10+</sup>
5654e41f4b71Sopenharmony_ci
5655e41f4b71Sopenharmony_ciskipToQueueItem(itemId: number): Promise\<void>
5656e41f4b71Sopenharmony_ci
5657e41f4b71Sopenharmony_ci设置指定播放列表单项的ID,发送给session端处理,session端可以选择对这个单项歌曲进行播放。结果通过Promise异步回调方式返回。
5658e41f4b71Sopenharmony_ci
5659e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
5660e41f4b71Sopenharmony_ci
5661e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
5662e41f4b71Sopenharmony_ci
5663e41f4b71Sopenharmony_ci**参数:**
5664e41f4b71Sopenharmony_ci
5665e41f4b71Sopenharmony_ci| 参数名  | 类型    | 必填 | 说明                                        |
5666e41f4b71Sopenharmony_ci| ------ | ------- | ---- | ------------------------------------------- |
5667e41f4b71Sopenharmony_ci| itemId | number  | 是   | 播放列表单项的ID值,用以表示选中的播放列表单项。 |
5668e41f4b71Sopenharmony_ci
5669e41f4b71Sopenharmony_ci**返回值:**
5670e41f4b71Sopenharmony_ci
5671e41f4b71Sopenharmony_ci| 类型           | 说明                                                             |
5672e41f4b71Sopenharmony_ci| -------------- | --------------------------------------------------------------- |
5673e41f4b71Sopenharmony_ci| Promise\<void> | Promise对象。当播放列表单项ID设置成功,无返回结果,否则返回错误对象。 |
5674e41f4b71Sopenharmony_ci
5675e41f4b71Sopenharmony_ci**错误码:**
5676e41f4b71Sopenharmony_ci
5677e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
5678e41f4b71Sopenharmony_ci
5679e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
5680e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
5681e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Parameter verification failed. |
5682e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
5683e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
5684e41f4b71Sopenharmony_ci| 6600103  | The session controller does not exist. |
5685e41f4b71Sopenharmony_ci
5686e41f4b71Sopenharmony_ci**示例:**
5687e41f4b71Sopenharmony_ci
5688e41f4b71Sopenharmony_ci```ts
5689e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
5690e41f4b71Sopenharmony_ci
5691e41f4b71Sopenharmony_cilet queueItemId = 0;
5692e41f4b71Sopenharmony_ciavsessionController.skipToQueueItem(queueItemId).then(() => {
5693e41f4b71Sopenharmony_ci  console.info('SkipToQueueItem successfully');
5694e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
5695e41f4b71Sopenharmony_ci  console.error(`SkipToQueueItem BusinessError: code: ${err.code}, message: ${err.message}`);
5696e41f4b71Sopenharmony_ci});
5697e41f4b71Sopenharmony_ci```
5698e41f4b71Sopenharmony_ci
5699e41f4b71Sopenharmony_ci### skipToQueueItem<sup>10+</sup>
5700e41f4b71Sopenharmony_ci
5701e41f4b71Sopenharmony_ciskipToQueueItem(itemId: number, callback: AsyncCallback\<void>): void
5702e41f4b71Sopenharmony_ci
5703e41f4b71Sopenharmony_ci设置指定播放列表单项的ID,发送给session端处理,session端可以选择对这个单项歌曲进行播放。结果通过callback异步回调方式返回。
5704e41f4b71Sopenharmony_ci
5705e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
5706e41f4b71Sopenharmony_ci
5707e41f4b71Sopenharmony_ci**参数:**
5708e41f4b71Sopenharmony_ci
5709e41f4b71Sopenharmony_ci| 参数名    | 类型                  | 必填 | 说明                                                        |
5710e41f4b71Sopenharmony_ci| -------- | --------------------- | ---- | ----------------------------------------------------------- |
5711e41f4b71Sopenharmony_ci| itemId   | number                | 是   | 播放列表单项的ID值,用以表示选中的播放列表单项。                |
5712e41f4b71Sopenharmony_ci| callback | AsyncCallback\<void>  | 是   | 回调函数。当播放状态设置成功,err为undefined,否则返回错误对象。 |
5713e41f4b71Sopenharmony_ci
5714e41f4b71Sopenharmony_ci**错误码:**
5715e41f4b71Sopenharmony_ci
5716e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
5717e41f4b71Sopenharmony_ci
5718e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
5719e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
5720e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Parameter verification failed. |
5721e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
5722e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
5723e41f4b71Sopenharmony_ci| 6600103  | The session controller does not exist. |
5724e41f4b71Sopenharmony_ci
5725e41f4b71Sopenharmony_ci**示例:**
5726e41f4b71Sopenharmony_ci
5727e41f4b71Sopenharmony_ci```ts
5728e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
5729e41f4b71Sopenharmony_ci
5730e41f4b71Sopenharmony_cilet queueItemId = 0;
5731e41f4b71Sopenharmony_ciavsessionController.skipToQueueItem(queueItemId, (err: BusinessError) => {
5732e41f4b71Sopenharmony_ci  if (err) {
5733e41f4b71Sopenharmony_ci    console.error(`SkipToQueueItem BusinessError: code: ${err.code}, message: ${err.message}`);
5734e41f4b71Sopenharmony_ci  } else {
5735e41f4b71Sopenharmony_ci    console.info('SkipToQueueItem successfully');
5736e41f4b71Sopenharmony_ci  }
5737e41f4b71Sopenharmony_ci});
5738e41f4b71Sopenharmony_ci```
5739e41f4b71Sopenharmony_ci
5740e41f4b71Sopenharmony_ci### getOutputDevice<sup>10+</sup>
5741e41f4b71Sopenharmony_ci
5742e41f4b71Sopenharmony_cigetOutputDevice(): Promise\<OutputDeviceInfo>
5743e41f4b71Sopenharmony_ci
5744e41f4b71Sopenharmony_ci获取播放设备信息。结果通过Promise异步回调方式返回。
5745e41f4b71Sopenharmony_ci
5746e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
5747e41f4b71Sopenharmony_ci
5748e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
5749e41f4b71Sopenharmony_ci
5750e41f4b71Sopenharmony_ci**返回值:**
5751e41f4b71Sopenharmony_ci
5752e41f4b71Sopenharmony_ci| 类型                                            | 说明                              |
5753e41f4b71Sopenharmony_ci| ----------------------------------------------- | --------------------------------- |
5754e41f4b71Sopenharmony_ci| Promise<[OutputDeviceInfo](#outputdeviceinfo10)\> | Promise对象,返回播放设备信息。 |
5755e41f4b71Sopenharmony_ci
5756e41f4b71Sopenharmony_ci**错误码:**
5757e41f4b71Sopenharmony_ci
5758e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
5759e41f4b71Sopenharmony_ci
5760e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
5761e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
5762e41f4b71Sopenharmony_ci| 600101  | Session service exception. |
5763e41f4b71Sopenharmony_ci| 600103  | The session controller does not exist. |
5764e41f4b71Sopenharmony_ci
5765e41f4b71Sopenharmony_ci**示例:**
5766e41f4b71Sopenharmony_ci
5767e41f4b71Sopenharmony_ci```ts
5768e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
5769e41f4b71Sopenharmony_ci
5770e41f4b71Sopenharmony_ciavsessionController.getOutputDevice().then((deviceInfo: avSession.OutputDeviceInfo) => {
5771e41f4b71Sopenharmony_ci  console.info('GetOutputDevice : SUCCESS');
5772e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
5773e41f4b71Sopenharmony_ci  console.error(`GetOutputDevice BusinessError: code: ${err.code}, message: ${err.message}`);
5774e41f4b71Sopenharmony_ci});
5775e41f4b71Sopenharmony_ci```
5776e41f4b71Sopenharmony_ci
5777e41f4b71Sopenharmony_ci### getOutputDevice<sup>10+</sup>
5778e41f4b71Sopenharmony_ci
5779e41f4b71Sopenharmony_cigetOutputDevice(callback: AsyncCallback\<OutputDeviceInfo>): void
5780e41f4b71Sopenharmony_ci
5781e41f4b71Sopenharmony_ci获取播放设备信息。结果通过callback异步回调方式返回。
5782e41f4b71Sopenharmony_ci
5783e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
5784e41f4b71Sopenharmony_ci
5785e41f4b71Sopenharmony_ci**参数:**
5786e41f4b71Sopenharmony_ci
5787e41f4b71Sopenharmony_ci| 参数名   | 类型                                                  | 必填 | 说明                           |
5788e41f4b71Sopenharmony_ci| -------- | ----------------------------------------------------- | ---- | ------------------------------ |
5789e41f4b71Sopenharmony_ci| callback | AsyncCallback<[OutputDeviceInfo](#outputdeviceinfo10)\> | 是   | 回调函数,返回播放设备信息。 |
5790e41f4b71Sopenharmony_ci
5791e41f4b71Sopenharmony_ci**错误码:**
5792e41f4b71Sopenharmony_ci
5793e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
5794e41f4b71Sopenharmony_ci
5795e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
5796e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
5797e41f4b71Sopenharmony_ci| 600101  | Session service exception. |
5798e41f4b71Sopenharmony_ci| 600103  | The session controller does not exist. |
5799e41f4b71Sopenharmony_ci
5800e41f4b71Sopenharmony_ci**示例:**
5801e41f4b71Sopenharmony_ci
5802e41f4b71Sopenharmony_ci```ts
5803e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
5804e41f4b71Sopenharmony_ci
5805e41f4b71Sopenharmony_ciavsessionController.getOutputDevice((err: BusinessError, deviceInfo: avSession.OutputDeviceInfo) => {
5806e41f4b71Sopenharmony_ci  if (err) {
5807e41f4b71Sopenharmony_ci    console.error(`GetOutputDevice BusinessError: code: ${err.code}, message: ${err.message}`);
5808e41f4b71Sopenharmony_ci  } else {
5809e41f4b71Sopenharmony_ci    console.info('GetOutputDevice : SUCCESS');
5810e41f4b71Sopenharmony_ci  }
5811e41f4b71Sopenharmony_ci});
5812e41f4b71Sopenharmony_ci```
5813e41f4b71Sopenharmony_ci
5814e41f4b71Sopenharmony_ci### sendAVKeyEvent<sup>10+</sup>
5815e41f4b71Sopenharmony_ci
5816e41f4b71Sopenharmony_cisendAVKeyEvent(event: KeyEvent): Promise\<void>
5817e41f4b71Sopenharmony_ci
5818e41f4b71Sopenharmony_ci发送按键事件到控制器对应的会话。结果通过Promise异步回调方式返回。
5819e41f4b71Sopenharmony_ci
5820e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
5821e41f4b71Sopenharmony_ci
5822e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
5823e41f4b71Sopenharmony_ci
5824e41f4b71Sopenharmony_ci**参数:**
5825e41f4b71Sopenharmony_ci
5826e41f4b71Sopenharmony_ci| 参数名 | 类型                                                         | 必填 | 说明       |
5827e41f4b71Sopenharmony_ci| ------ | ------------------------------------------------------------ | ---- | ---------- |
5828e41f4b71Sopenharmony_ci| event  | [KeyEvent](../apis-input-kit/js-apis-keyevent.md) | 是   | 按键事件。 |
5829e41f4b71Sopenharmony_ci
5830e41f4b71Sopenharmony_ci**错误码:**
5831e41f4b71Sopenharmony_ci
5832e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
5833e41f4b71Sopenharmony_ci
5834e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
5835e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
5836e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Parameter verification failed. |
5837e41f4b71Sopenharmony_ci| 600101  | Session service exception. |
5838e41f4b71Sopenharmony_ci| 600102  | The session does not exist. |
5839e41f4b71Sopenharmony_ci| 600103  | The session controller does not exist. |
5840e41f4b71Sopenharmony_ci| 600105  | Invalid session command. |
5841e41f4b71Sopenharmony_ci| 600106  | The session is not activated. |
5842e41f4b71Sopenharmony_ci
5843e41f4b71Sopenharmony_ci**返回值:**
5844e41f4b71Sopenharmony_ci
5845e41f4b71Sopenharmony_ci| 类型           | 说明                          |
5846e41f4b71Sopenharmony_ci| -------------- | ----------------------------- |
5847e41f4b71Sopenharmony_ci| Promise\<void> | Promise对象。当事件发送成功,无返回结果,否则返回错误对象。 |
5848e41f4b71Sopenharmony_ci
5849e41f4b71Sopenharmony_ci**示例:**
5850e41f4b71Sopenharmony_ci
5851e41f4b71Sopenharmony_ci```ts
5852e41f4b71Sopenharmony_ciimport { Key, KeyEvent } from '@kit.InputKit';
5853e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
5854e41f4b71Sopenharmony_ci
5855e41f4b71Sopenharmony_cilet keyItem: Key = {code:0x49, pressedTime:2, deviceId:0};
5856e41f4b71Sopenharmony_cilet event:KeyEvent = {id:1, deviceId:0, actionTime:1, screenId:1, windowId:1, action:2, key:keyItem, unicodeChar:0, keys:[keyItem], ctrlKey:false, altKey:false, shiftKey:false, logoKey:false, fnKey:false, capsLock:false, numLock:false, scrollLock:false};
5857e41f4b71Sopenharmony_ci
5858e41f4b71Sopenharmony_ci
5859e41f4b71Sopenharmony_ciavsessionController.sendAVKeyEvent(event).then(() => {
5860e41f4b71Sopenharmony_ci  console.info('SendAVKeyEvent Successfully');
5861e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
5862e41f4b71Sopenharmony_ci  console.error(`SendAVKeyEvent BusinessError: code: ${err.code}, message: ${err.message}`);
5863e41f4b71Sopenharmony_ci});
5864e41f4b71Sopenharmony_ci```
5865e41f4b71Sopenharmony_ci
5866e41f4b71Sopenharmony_ci### sendAVKeyEvent<sup>10+</sup>
5867e41f4b71Sopenharmony_ci
5868e41f4b71Sopenharmony_cisendAVKeyEvent(event: KeyEvent, callback: AsyncCallback\<void>): void
5869e41f4b71Sopenharmony_ci
5870e41f4b71Sopenharmony_ci发送按键事件到会话。结果通过callback异步回调方式返回。
5871e41f4b71Sopenharmony_ci
5872e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
5873e41f4b71Sopenharmony_ci
5874e41f4b71Sopenharmony_ci**参数:**
5875e41f4b71Sopenharmony_ci
5876e41f4b71Sopenharmony_ci| 参数名   | 类型                                                         | 必填 | 说明       |
5877e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | ---- | ---------- |
5878e41f4b71Sopenharmony_ci| event    | [KeyEvent](../apis-input-kit/js-apis-keyevent.md) | 是   | 按键事件。 |
5879e41f4b71Sopenharmony_ci| callback | AsyncCallback\<void>                                         | 是   | 回调函数。当事件发送成功,err为undefined,否则返回错误对象。 |
5880e41f4b71Sopenharmony_ci
5881e41f4b71Sopenharmony_ci**错误码:**
5882e41f4b71Sopenharmony_ci
5883e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
5884e41f4b71Sopenharmony_ci
5885e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
5886e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
5887e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Parameter verification failed. |
5888e41f4b71Sopenharmony_ci| 600101  | Session service exception. |
5889e41f4b71Sopenharmony_ci| 600102  | The session does not exist. |
5890e41f4b71Sopenharmony_ci| 600103  | The session controller does not exist. |
5891e41f4b71Sopenharmony_ci| 600105  | Invalid session command. |
5892e41f4b71Sopenharmony_ci| 600106  | The session is not activated. |
5893e41f4b71Sopenharmony_ci
5894e41f4b71Sopenharmony_ci**示例:**
5895e41f4b71Sopenharmony_ci
5896e41f4b71Sopenharmony_ci```ts
5897e41f4b71Sopenharmony_ciimport { Key, KeyEvent } from '@kit.InputKit';
5898e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
5899e41f4b71Sopenharmony_ci
5900e41f4b71Sopenharmony_cilet keyItem: Key = {code:0x49, pressedTime:2, deviceId:0};
5901e41f4b71Sopenharmony_cilet event:KeyEvent = {id:1, deviceId:0, actionTime:1, screenId:1, windowId:1, action:2, key:keyItem, unicodeChar:0, keys:[keyItem], ctrlKey:false, altKey:false, shiftKey:false, logoKey:false, fnKey:false, capsLock:false, numLock:false, scrollLock:false};
5902e41f4b71Sopenharmony_ciavsessionController.sendAVKeyEvent(event, (err: BusinessError) => {
5903e41f4b71Sopenharmony_ci  if (err) {
5904e41f4b71Sopenharmony_ci    console.error(`SendAVKeyEvent BusinessError: code: ${err.code}, message: ${err.message}`);
5905e41f4b71Sopenharmony_ci  } else {
5906e41f4b71Sopenharmony_ci    console.info('SendAVKeyEvent Successfully');
5907e41f4b71Sopenharmony_ci  }
5908e41f4b71Sopenharmony_ci});
5909e41f4b71Sopenharmony_ci```
5910e41f4b71Sopenharmony_ci
5911e41f4b71Sopenharmony_ci### getLaunchAbility<sup>10+</sup>
5912e41f4b71Sopenharmony_ci
5913e41f4b71Sopenharmony_cigetLaunchAbility(): Promise\<WantAgent>
5914e41f4b71Sopenharmony_ci
5915e41f4b71Sopenharmony_ci获取应用在会话中保存的WantAgent对象。结果通过Promise异步回调方式返回。
5916e41f4b71Sopenharmony_ci
5917e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
5918e41f4b71Sopenharmony_ci
5919e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
5920e41f4b71Sopenharmony_ci
5921e41f4b71Sopenharmony_ci**返回值:**
5922e41f4b71Sopenharmony_ci
5923e41f4b71Sopenharmony_ci| 类型                                                    | 说明                                                         |
5924e41f4b71Sopenharmony_ci| ------------------------------------------------------- | ------------------------------------------------------------ |
5925e41f4b71Sopenharmony_ci| Promise<[WantAgent](../apis-ability-kit/js-apis-app-ability-wantAgent.md)\> | Promise对象,返回在[setLaunchAbility](#setlaunchability10)保存的对象,包括应用的相关属性信息,如bundleName,abilityName,deviceId等。 |
5926e41f4b71Sopenharmony_ci
5927e41f4b71Sopenharmony_ci**错误码:**
5928e41f4b71Sopenharmony_ci
5929e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
5930e41f4b71Sopenharmony_ci
5931e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
5932e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
5933e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
5934e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
5935e41f4b71Sopenharmony_ci| 6600103  | The session controller does not exist. |
5936e41f4b71Sopenharmony_ci
5937e41f4b71Sopenharmony_ci**示例:**
5938e41f4b71Sopenharmony_ci
5939e41f4b71Sopenharmony_ci```ts
5940e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
5941e41f4b71Sopenharmony_ci
5942e41f4b71Sopenharmony_ciavsessionController.getLaunchAbility().then((agent: object) => {
5943e41f4b71Sopenharmony_ci  console.info(`GetLaunchAbility : SUCCESS : wantAgent : ${agent}`);
5944e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
5945e41f4b71Sopenharmony_ci  console.error(`GetLaunchAbility BusinessError: code: ${err.code}, message: ${err.message}`);
5946e41f4b71Sopenharmony_ci});
5947e41f4b71Sopenharmony_ci```
5948e41f4b71Sopenharmony_ci
5949e41f4b71Sopenharmony_ci### getLaunchAbility<sup>10+</sup>
5950e41f4b71Sopenharmony_ci
5951e41f4b71Sopenharmony_cigetLaunchAbility(callback: AsyncCallback\<WantAgent>): void
5952e41f4b71Sopenharmony_ci
5953e41f4b71Sopenharmony_ci获取应用在会话中保存的WantAgent对象。结果通过callback异步回调方式返回。
5954e41f4b71Sopenharmony_ci
5955e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
5956e41f4b71Sopenharmony_ci
5957e41f4b71Sopenharmony_ci**参数:**
5958e41f4b71Sopenharmony_ci
5959e41f4b71Sopenharmony_ci| 参数名   | 类型                                                         | 必填 | 说明                                                         |
5960e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
5961e41f4b71Sopenharmony_ci| callback | AsyncCallback<[WantAgent](../apis-ability-kit/js-apis-app-ability-wantAgent.md)\> | 是   | 回调函数。返回在[setLaunchAbility](#setlaunchability10)保存的对象,包括应用的相关属性信息,如bundleName,abilityName,deviceId等。 |
5962e41f4b71Sopenharmony_ci
5963e41f4b71Sopenharmony_ci**错误码:**
5964e41f4b71Sopenharmony_ci
5965e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
5966e41f4b71Sopenharmony_ci
5967e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
5968e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
5969e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
5970e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
5971e41f4b71Sopenharmony_ci| 6600103  | The session controller does not exist. |
5972e41f4b71Sopenharmony_ci
5973e41f4b71Sopenharmony_ci**示例:**
5974e41f4b71Sopenharmony_ci
5975e41f4b71Sopenharmony_ci```ts
5976e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
5977e41f4b71Sopenharmony_ci
5978e41f4b71Sopenharmony_ciavsessionController.getLaunchAbility((err: BusinessError, agent: object) => {
5979e41f4b71Sopenharmony_ci  if (err) {
5980e41f4b71Sopenharmony_ci    console.error(`GetLaunchAbility BusinessError: code: ${err.code}, message: ${err.message}`);
5981e41f4b71Sopenharmony_ci  } else {
5982e41f4b71Sopenharmony_ci    console.info(`GetLaunchAbility : SUCCESS : wantAgent : ${agent}`);
5983e41f4b71Sopenharmony_ci  }
5984e41f4b71Sopenharmony_ci});
5985e41f4b71Sopenharmony_ci```
5986e41f4b71Sopenharmony_ci
5987e41f4b71Sopenharmony_ci### getRealPlaybackPositionSync<sup>10+</sup>
5988e41f4b71Sopenharmony_ci
5989e41f4b71Sopenharmony_cigetRealPlaybackPositionSync(): number
5990e41f4b71Sopenharmony_ci
5991e41f4b71Sopenharmony_ci获取当前播放位置。
5992e41f4b71Sopenharmony_ci
5993e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
5994e41f4b71Sopenharmony_ci
5995e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
5996e41f4b71Sopenharmony_ci
5997e41f4b71Sopenharmony_ci**返回值:**
5998e41f4b71Sopenharmony_ci
5999e41f4b71Sopenharmony_ci| 类型   | 说明               |
6000e41f4b71Sopenharmony_ci| ------ | ------------------ |
6001e41f4b71Sopenharmony_ci| number | 时间节点,毫秒数。 |
6002e41f4b71Sopenharmony_ci
6003e41f4b71Sopenharmony_ci**错误码:**
6004e41f4b71Sopenharmony_ci
6005e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
6006e41f4b71Sopenharmony_ci
6007e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
6008e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
6009e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
6010e41f4b71Sopenharmony_ci| 6600103  | The session controller does not exist. |
6011e41f4b71Sopenharmony_ci
6012e41f4b71Sopenharmony_ci**示例:**
6013e41f4b71Sopenharmony_ci
6014e41f4b71Sopenharmony_ci```ts
6015e41f4b71Sopenharmony_cilet time: number = avsessionController.getRealPlaybackPositionSync();
6016e41f4b71Sopenharmony_ci```
6017e41f4b71Sopenharmony_ci
6018e41f4b71Sopenharmony_ci### isActive<sup>10+</sup>
6019e41f4b71Sopenharmony_ci
6020e41f4b71Sopenharmony_ciisActive(): Promise\<boolean>
6021e41f4b71Sopenharmony_ci
6022e41f4b71Sopenharmony_ci获取会话是否被激活。结果通过Promise异步回调方式返回。
6023e41f4b71Sopenharmony_ci
6024e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
6025e41f4b71Sopenharmony_ci
6026e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
6027e41f4b71Sopenharmony_ci
6028e41f4b71Sopenharmony_ci**返回值:**
6029e41f4b71Sopenharmony_ci
6030e41f4b71Sopenharmony_ci| 类型              | 说明                                                         |
6031e41f4b71Sopenharmony_ci| ----------------- | ------------------------------------------------------------ |
6032e41f4b71Sopenharmony_ci| Promise<boolean\> | Promise对象,返回会话是否为激活状态,true表示被激活,false表示禁用。 |
6033e41f4b71Sopenharmony_ci
6034e41f4b71Sopenharmony_ci**错误码:**
6035e41f4b71Sopenharmony_ci
6036e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
6037e41f4b71Sopenharmony_ci
6038e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
6039e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
6040e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
6041e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
6042e41f4b71Sopenharmony_ci| 6600103  | The session controller does not exist. |
6043e41f4b71Sopenharmony_ci
6044e41f4b71Sopenharmony_ci**示例:**
6045e41f4b71Sopenharmony_ci
6046e41f4b71Sopenharmony_ci```ts
6047e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
6048e41f4b71Sopenharmony_ci
6049e41f4b71Sopenharmony_ciavsessionController.isActive().then((isActive: boolean) => {
6050e41f4b71Sopenharmony_ci  console.info(`IsActive : SUCCESS : isactive : ${isActive}`);
6051e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
6052e41f4b71Sopenharmony_ci  console.error(`IsActive BusinessError: code: ${err.code}, message: ${err.message}`);
6053e41f4b71Sopenharmony_ci});
6054e41f4b71Sopenharmony_ci```
6055e41f4b71Sopenharmony_ci
6056e41f4b71Sopenharmony_ci### isActive<sup>10+</sup>
6057e41f4b71Sopenharmony_ci
6058e41f4b71Sopenharmony_ciisActive(callback: AsyncCallback\<boolean>): void
6059e41f4b71Sopenharmony_ci
6060e41f4b71Sopenharmony_ci判断会话是否被激活。结果通过callback异步回调方式返回。
6061e41f4b71Sopenharmony_ci
6062e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
6063e41f4b71Sopenharmony_ci
6064e41f4b71Sopenharmony_ci**参数:**
6065e41f4b71Sopenharmony_ci
6066e41f4b71Sopenharmony_ci| 参数名   | 类型                    | 必填 | 说明                                                         |
6067e41f4b71Sopenharmony_ci| -------- | ----------------------- | ---- | ------------------------------------------------------------ |
6068e41f4b71Sopenharmony_ci| callback | AsyncCallback<boolean\> | 是   | 回调函数,返回会话是否为激活状态,true表示被激活,false表示禁用。 |
6069e41f4b71Sopenharmony_ci
6070e41f4b71Sopenharmony_ci**错误码:**
6071e41f4b71Sopenharmony_ci
6072e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
6073e41f4b71Sopenharmony_ci
6074e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
6075e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
6076e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
6077e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
6078e41f4b71Sopenharmony_ci| 6600103  | The session controller does not exist. |
6079e41f4b71Sopenharmony_ci
6080e41f4b71Sopenharmony_ci**示例:**
6081e41f4b71Sopenharmony_ci
6082e41f4b71Sopenharmony_ci```ts
6083e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
6084e41f4b71Sopenharmony_ci
6085e41f4b71Sopenharmony_ciavsessionController.isActive((err: BusinessError, isActive: boolean) => {
6086e41f4b71Sopenharmony_ci  if (err) {
6087e41f4b71Sopenharmony_ci    console.error(`IsActive BusinessError: code: ${err.code}, message: ${err.message}`);
6088e41f4b71Sopenharmony_ci  } else {
6089e41f4b71Sopenharmony_ci    console.info(`IsActive : SUCCESS : isactive : ${isActive}`);
6090e41f4b71Sopenharmony_ci  }
6091e41f4b71Sopenharmony_ci});
6092e41f4b71Sopenharmony_ci```
6093e41f4b71Sopenharmony_ci
6094e41f4b71Sopenharmony_ci### destroy<sup>10+</sup>
6095e41f4b71Sopenharmony_ci
6096e41f4b71Sopenharmony_cidestroy(): Promise\<void>
6097e41f4b71Sopenharmony_ci
6098e41f4b71Sopenharmony_ci销毁当前控制器,销毁后当前控制器不可再用。结果通过Promise异步回调方式返回。
6099e41f4b71Sopenharmony_ci
6100e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
6101e41f4b71Sopenharmony_ci
6102e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
6103e41f4b71Sopenharmony_ci
6104e41f4b71Sopenharmony_ci**返回值:**
6105e41f4b71Sopenharmony_ci
6106e41f4b71Sopenharmony_ci| 类型           | 说明                          |
6107e41f4b71Sopenharmony_ci| -------------- | ----------------------------- |
6108e41f4b71Sopenharmony_ci| Promise\<void> | Promise对象。当控制器销毁成功,无返回结果,否则返回错误对象。 |
6109e41f4b71Sopenharmony_ci
6110e41f4b71Sopenharmony_ci**错误码:**
6111e41f4b71Sopenharmony_ci
6112e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
6113e41f4b71Sopenharmony_ci
6114e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
6115e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
6116e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
6117e41f4b71Sopenharmony_ci| 6600103  | The session controller does not exist. |
6118e41f4b71Sopenharmony_ci
6119e41f4b71Sopenharmony_ci**示例:**
6120e41f4b71Sopenharmony_ci
6121e41f4b71Sopenharmony_ci```ts
6122e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
6123e41f4b71Sopenharmony_ci
6124e41f4b71Sopenharmony_ciavsessionController.destroy().then(() => {
6125e41f4b71Sopenharmony_ci  console.info('Destroy : SUCCESS ');
6126e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
6127e41f4b71Sopenharmony_ci  console.error(`Destroy BusinessError: code: ${err.code}, message: ${err.message}`);
6128e41f4b71Sopenharmony_ci});
6129e41f4b71Sopenharmony_ci```
6130e41f4b71Sopenharmony_ci
6131e41f4b71Sopenharmony_ci### destroy<sup>10+</sup>
6132e41f4b71Sopenharmony_ci
6133e41f4b71Sopenharmony_cidestroy(callback: AsyncCallback\<void>): void
6134e41f4b71Sopenharmony_ci
6135e41f4b71Sopenharmony_ci销毁当前控制器,销毁后当前控制器不可再用。结果通过callback异步回调方式返回。
6136e41f4b71Sopenharmony_ci
6137e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
6138e41f4b71Sopenharmony_ci
6139e41f4b71Sopenharmony_ci**参数:**
6140e41f4b71Sopenharmony_ci
6141e41f4b71Sopenharmony_ci| 参数名   | 类型                 | 必填 | 说明       |
6142e41f4b71Sopenharmony_ci| -------- | -------------------- | ---- | ---------- |
6143e41f4b71Sopenharmony_ci| callback | AsyncCallback\<void> | 是   | 回调函数。当控制器销毁成功,err为undefined,否则返回错误对象。 |
6144e41f4b71Sopenharmony_ci
6145e41f4b71Sopenharmony_ci**错误码:**
6146e41f4b71Sopenharmony_ci
6147e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
6148e41f4b71Sopenharmony_ci
6149e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
6150e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
6151e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
6152e41f4b71Sopenharmony_ci| 6600103  | The session controller does not exist. |
6153e41f4b71Sopenharmony_ci
6154e41f4b71Sopenharmony_ci**示例:**
6155e41f4b71Sopenharmony_ci
6156e41f4b71Sopenharmony_ci```ts
6157e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
6158e41f4b71Sopenharmony_ci
6159e41f4b71Sopenharmony_ciavsessionController.destroy((err: BusinessError) => {
6160e41f4b71Sopenharmony_ci  if (err) {
6161e41f4b71Sopenharmony_ci    console.error(`Destroy BusinessError: code: ${err.code}, message: ${err.message}`);
6162e41f4b71Sopenharmony_ci  } else {
6163e41f4b71Sopenharmony_ci    console.info('Destroy : SUCCESS ');
6164e41f4b71Sopenharmony_ci  }
6165e41f4b71Sopenharmony_ci});
6166e41f4b71Sopenharmony_ci```
6167e41f4b71Sopenharmony_ci
6168e41f4b71Sopenharmony_ci### getValidCommands<sup>10+</sup>
6169e41f4b71Sopenharmony_ci
6170e41f4b71Sopenharmony_cigetValidCommands(): Promise\<Array\<AVControlCommandType>>
6171e41f4b71Sopenharmony_ci
6172e41f4b71Sopenharmony_ci获取会话支持的有效命令。结果通过Promise异步回调方式返回。
6173e41f4b71Sopenharmony_ci
6174e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
6175e41f4b71Sopenharmony_ci
6176e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
6177e41f4b71Sopenharmony_ci
6178e41f4b71Sopenharmony_ci**返回值:**
6179e41f4b71Sopenharmony_ci
6180e41f4b71Sopenharmony_ci| 类型                                                         | 说明                              |
6181e41f4b71Sopenharmony_ci| ------------------------------------------------------------ | --------------------------------- |
6182e41f4b71Sopenharmony_ci| Promise<Array<[AVControlCommandType](#avcontrolcommandtype10)\>\> | Promise对象。返回有效命令的集合。 |
6183e41f4b71Sopenharmony_ci
6184e41f4b71Sopenharmony_ci**错误码:**
6185e41f4b71Sopenharmony_ci
6186e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
6187e41f4b71Sopenharmony_ci
6188e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
6189e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
6190e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
6191e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
6192e41f4b71Sopenharmony_ci| 6600103  | The session controller does not exist. |
6193e41f4b71Sopenharmony_ci
6194e41f4b71Sopenharmony_ci**示例:**
6195e41f4b71Sopenharmony_ci
6196e41f4b71Sopenharmony_ci```ts
6197e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
6198e41f4b71Sopenharmony_ci
6199e41f4b71Sopenharmony_ciavsessionController.getValidCommands().then((validCommands: avSession.AVControlCommandType[]) => {
6200e41f4b71Sopenharmony_ci  console.info(`GetValidCommands : SUCCESS : size : ${validCommands.length}`);
6201e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
6202e41f4b71Sopenharmony_ci  console.error(`GetValidCommands BusinessError: code: ${err.code}, message: ${err.message}`);
6203e41f4b71Sopenharmony_ci});
6204e41f4b71Sopenharmony_ci```
6205e41f4b71Sopenharmony_ci
6206e41f4b71Sopenharmony_ci### getValidCommands<sup>10+</sup>
6207e41f4b71Sopenharmony_ci
6208e41f4b71Sopenharmony_cigetValidCommands(callback: AsyncCallback\<Array\<AVControlCommandType>>): void
6209e41f4b71Sopenharmony_ci
6210e41f4b71Sopenharmony_ci获取会话支持的有效命令。结果通过callback异步回调方式返回。
6211e41f4b71Sopenharmony_ci
6212e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
6213e41f4b71Sopenharmony_ci
6214e41f4b71Sopenharmony_ci**参数:**
6215e41f4b71Sopenharmony_ci
6216e41f4b71Sopenharmony_ci| 参数名   | 类型                                                         | 必填 | 说明                           |
6217e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | ---- | ------------------------------ |
6218e41f4b71Sopenharmony_ci| callback | AsyncCallback\<Array\<[AVControlCommandType](#avcontrolcommandtype10)\>\> | 是   | 回调函数,返回有效命令的集合。 |
6219e41f4b71Sopenharmony_ci
6220e41f4b71Sopenharmony_ci**错误码:**
6221e41f4b71Sopenharmony_ci
6222e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
6223e41f4b71Sopenharmony_ci
6224e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
6225e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
6226e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
6227e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
6228e41f4b71Sopenharmony_ci| 6600103  | The session controller does not exist. |
6229e41f4b71Sopenharmony_ci
6230e41f4b71Sopenharmony_ci**示例:**
6231e41f4b71Sopenharmony_ci
6232e41f4b71Sopenharmony_ci```ts
6233e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
6234e41f4b71Sopenharmony_ci
6235e41f4b71Sopenharmony_ciavsessionController.getValidCommands((err: BusinessError, validCommands: avSession.AVControlCommandType[]) => {
6236e41f4b71Sopenharmony_ci  if (err) {
6237e41f4b71Sopenharmony_ci    console.error(`GetValidCommands BusinessError: code: ${err.code}, message: ${err.message}`);
6238e41f4b71Sopenharmony_ci  } else {
6239e41f4b71Sopenharmony_ci    console.info(`GetValidCommands : SUCCESS : size : ${validCommands.length}`);
6240e41f4b71Sopenharmony_ci  }
6241e41f4b71Sopenharmony_ci});
6242e41f4b71Sopenharmony_ci```
6243e41f4b71Sopenharmony_ci
6244e41f4b71Sopenharmony_ci### sendControlCommand<sup>10+</sup>
6245e41f4b71Sopenharmony_ci
6246e41f4b71Sopenharmony_cisendControlCommand(command: AVControlCommand): Promise\<void>
6247e41f4b71Sopenharmony_ci
6248e41f4b71Sopenharmony_ci通过控制器发送命令到其对应的会话。结果通过Promise异步回调方式返回。
6249e41f4b71Sopenharmony_ci
6250e41f4b71Sopenharmony_ci> **说明:**
6251e41f4b71Sopenharmony_ci>
6252e41f4b71Sopenharmony_ci> 媒体控制方在使用sendControlCommand命令前,需要确保控制对应的媒体会话注册了对应的监听,注册媒体会话相关监听的方法请参见接口[on'play'](#onplay10)、[on'pause'](#onpause10)等。
6253e41f4b71Sopenharmony_ci
6254e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
6255e41f4b71Sopenharmony_ci
6256e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
6257e41f4b71Sopenharmony_ci
6258e41f4b71Sopenharmony_ci**参数:**
6259e41f4b71Sopenharmony_ci
6260e41f4b71Sopenharmony_ci| 参数名    | 类型                                  | 必填 | 说明                           |
6261e41f4b71Sopenharmony_ci| ------- | ------------------------------------- | ---- | ------------------------------ |
6262e41f4b71Sopenharmony_ci| command | [AVControlCommand](#avcontrolcommand10) | 是   | 会话的相关命令和命令相关参数。 |
6263e41f4b71Sopenharmony_ci
6264e41f4b71Sopenharmony_ci**返回值:**
6265e41f4b71Sopenharmony_ci
6266e41f4b71Sopenharmony_ci| 类型           | 说明                          |
6267e41f4b71Sopenharmony_ci| -------------- | ----------------------------- |
6268e41f4b71Sopenharmony_ci| Promise\<void> | Promise对象。当命令发送成功,无返回结果,否则返回错误对象。 |
6269e41f4b71Sopenharmony_ci
6270e41f4b71Sopenharmony_ci**错误码:**
6271e41f4b71Sopenharmony_ci
6272e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
6273e41f4b71Sopenharmony_ci
6274e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
6275e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
6276e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Parameter verification failed. |
6277e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
6278e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
6279e41f4b71Sopenharmony_ci| 6600103  | The session controller does not exist. |
6280e41f4b71Sopenharmony_ci| 6600105  | Invalid session command. |
6281e41f4b71Sopenharmony_ci| 6600106  | The session is not activated. |
6282e41f4b71Sopenharmony_ci| 6600107  | Too many commands or events. |
6283e41f4b71Sopenharmony_ci
6284e41f4b71Sopenharmony_ci**示例:**
6285e41f4b71Sopenharmony_ci
6286e41f4b71Sopenharmony_ci```ts
6287e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
6288e41f4b71Sopenharmony_ci
6289e41f4b71Sopenharmony_cilet avCommand: avSession.AVControlCommand = {command:'play'};
6290e41f4b71Sopenharmony_ciavsessionController.sendControlCommand(avCommand).then(() => {
6291e41f4b71Sopenharmony_ci  console.info('SendControlCommand successfully');
6292e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
6293e41f4b71Sopenharmony_ci  console.error(`SendControlCommand BusinessError: code: ${err.code}, message: ${err.message}`);
6294e41f4b71Sopenharmony_ci});
6295e41f4b71Sopenharmony_ci```
6296e41f4b71Sopenharmony_ci
6297e41f4b71Sopenharmony_ci### sendControlCommand<sup>10+</sup>
6298e41f4b71Sopenharmony_ci
6299e41f4b71Sopenharmony_cisendControlCommand(command: AVControlCommand, callback: AsyncCallback\<void>): void
6300e41f4b71Sopenharmony_ci
6301e41f4b71Sopenharmony_ci通过会话控制器发送命令到其对应的会话。结果通过callback异步回调方式返回。
6302e41f4b71Sopenharmony_ci
6303e41f4b71Sopenharmony_ci> **说明:**
6304e41f4b71Sopenharmony_ci>
6305e41f4b71Sopenharmony_ci> 媒体控制方在使用sendControlCommand命令前,需要确保控制对应的媒体会话注册了对应的监听,注册媒体会话相关监听的方法请参见接口[on'play'](#onplay10)、[on'pause'](#onpause10)等。
6306e41f4b71Sopenharmony_ci
6307e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
6308e41f4b71Sopenharmony_ci
6309e41f4b71Sopenharmony_ci**参数:**
6310e41f4b71Sopenharmony_ci
6311e41f4b71Sopenharmony_ci| 参数名   | 类型                                  | 必填 | 说明                           |
6312e41f4b71Sopenharmony_ci| -------- | ------------------------------------- | ---- | ------------------------------ |
6313e41f4b71Sopenharmony_ci| command  | [AVControlCommand](#avcontrolcommand10) | 是   | 会话的相关命令和命令相关参数。 |
6314e41f4b71Sopenharmony_ci| callback | AsyncCallback\<void>                  | 是   | 回调函数。当命令发送成功,err为undefined,否则返回错误对象。                     |
6315e41f4b71Sopenharmony_ci
6316e41f4b71Sopenharmony_ci**错误码:**
6317e41f4b71Sopenharmony_ci
6318e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
6319e41f4b71Sopenharmony_ci
6320e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
6321e41f4b71Sopenharmony_ci| -------- | ------------------------------- |
6322e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Parameter verification failed. |
6323e41f4b71Sopenharmony_ci| 6600101  | Session service exception.                |
6324e41f4b71Sopenharmony_ci| 6600102  | The session does not exist.     |
6325e41f4b71Sopenharmony_ci| 6600103  | The session controller does not exist.   |
6326e41f4b71Sopenharmony_ci| 6600105  | Invalid session command.           |
6327e41f4b71Sopenharmony_ci| 6600106  | The session is not activated.                |
6328e41f4b71Sopenharmony_ci| 6600107  | Too many commands or events.      |
6329e41f4b71Sopenharmony_ci
6330e41f4b71Sopenharmony_ci**示例:**
6331e41f4b71Sopenharmony_ci
6332e41f4b71Sopenharmony_ci```ts
6333e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
6334e41f4b71Sopenharmony_ci
6335e41f4b71Sopenharmony_cilet avCommand: avSession.AVControlCommand = {command:'play'};
6336e41f4b71Sopenharmony_ciavsessionController.sendControlCommand(avCommand, (err: BusinessError) => {
6337e41f4b71Sopenharmony_ci  if (err) {
6338e41f4b71Sopenharmony_ci    console.error(`SendControlCommand BusinessError: code: ${err.code}, message: ${err.message}`);
6339e41f4b71Sopenharmony_ci  } else {
6340e41f4b71Sopenharmony_ci    console.info('SendControlCommand successfully');
6341e41f4b71Sopenharmony_ci  }
6342e41f4b71Sopenharmony_ci});
6343e41f4b71Sopenharmony_ci```
6344e41f4b71Sopenharmony_ci
6345e41f4b71Sopenharmony_ci### sendCommonCommand<sup>10+</sup>
6346e41f4b71Sopenharmony_ci
6347e41f4b71Sopenharmony_cisendCommonCommand(command: string, args: {[key: string]: Object}): Promise\<void>
6348e41f4b71Sopenharmony_ci
6349e41f4b71Sopenharmony_ci通过会话控制器发送自定义控制命令到其对应的会话。结果通过Promise异步回调方式返回。
6350e41f4b71Sopenharmony_ci
6351e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
6352e41f4b71Sopenharmony_ci
6353e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
6354e41f4b71Sopenharmony_ci
6355e41f4b71Sopenharmony_ci**参数:**
6356e41f4b71Sopenharmony_ci
6357e41f4b71Sopenharmony_ci| 参数名    | 类型                                  | 必填 | 说明                           |
6358e41f4b71Sopenharmony_ci| ------- | ------------------------------------- | ---- | ------------------------------ |
6359e41f4b71Sopenharmony_ci| command | string | 是   | 需要设置的自定义控制命令的名称 |
6360e41f4b71Sopenharmony_ci| args | {[key: string]: Object} | 是   | 需要传递的控制命令键值对 |
6361e41f4b71Sopenharmony_ci
6362e41f4b71Sopenharmony_ci> **说明:**
6363e41f4b71Sopenharmony_ci> 参数args支持的数据类型有:字符串、数字、布尔、对象、数组和文件描述符等,详细介绍请参见[@ohos.app.ability.Want(Want)](../apis-ability-kit/js-apis-app-ability-want.md)。
6364e41f4b71Sopenharmony_ci
6365e41f4b71Sopenharmony_ci**返回值:**
6366e41f4b71Sopenharmony_ci
6367e41f4b71Sopenharmony_ci| 类型           | 说明                          |
6368e41f4b71Sopenharmony_ci| -------------- | ----------------------------- |
6369e41f4b71Sopenharmony_ci| Promise\<void> | Promise对象。当命令发送成功,无返回结果,否则返回错误对象。 |
6370e41f4b71Sopenharmony_ci
6371e41f4b71Sopenharmony_ci**错误码:**
6372e41f4b71Sopenharmony_ci
6373e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
6374e41f4b71Sopenharmony_ci
6375e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
6376e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
6377e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Parameter verification failed. |
6378e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
6379e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
6380e41f4b71Sopenharmony_ci| 6600103  | The session controller does not exist. |
6381e41f4b71Sopenharmony_ci| 6600105  | Invalid session command. |
6382e41f4b71Sopenharmony_ci| 6600106  | The session is not activated. |
6383e41f4b71Sopenharmony_ci| 6600107  | Too many commands or events. |
6384e41f4b71Sopenharmony_ci
6385e41f4b71Sopenharmony_ci**示例:**
6386e41f4b71Sopenharmony_ci
6387e41f4b71Sopenharmony_ci```ts
6388e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
6389e41f4b71Sopenharmony_ci
6390e41f4b71Sopenharmony_cilet avSessionController: avSession.AVSessionController | undefined = undefined;
6391e41f4b71Sopenharmony_cilet currentAVSession: avSession.AVSession | undefined = undefined;
6392e41f4b71Sopenharmony_cilet tag = "createNewSession";
6393e41f4b71Sopenharmony_cilet context: Context = getContext(this);
6394e41f4b71Sopenharmony_cilet sessionId: string = "";
6395e41f4b71Sopenharmony_ciavSession.createAVSession(context, tag, "audio", (err: BusinessError, data: avSession.AVSession) => {
6396e41f4b71Sopenharmony_ci  if (err) {
6397e41f4b71Sopenharmony_ci    console.error(`CreateAVSession BusinessError: code: ${err.code}, message: ${err.message}`);
6398e41f4b71Sopenharmony_ci  } else {
6399e41f4b71Sopenharmony_ci    currentAVSession = data;
6400e41f4b71Sopenharmony_ci  }
6401e41f4b71Sopenharmony_ci});
6402e41f4b71Sopenharmony_ciif (currentAVSession !== undefined) {
6403e41f4b71Sopenharmony_ci  sessionId = (currentAVSession as avSession.AVSession).sessionId;
6404e41f4b71Sopenharmony_ci  avSession.createController(sessionId).then((controller: avSession.AVSessionController) => {
6405e41f4b71Sopenharmony_ci    avSessionController = controller;
6406e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
6407e41f4b71Sopenharmony_ci    console.error(`CreateController BusinessError: code: ${err.code}, message: ${err.message}`);
6408e41f4b71Sopenharmony_ci  });
6409e41f4b71Sopenharmony_ci}
6410e41f4b71Sopenharmony_ci
6411e41f4b71Sopenharmony_cilet commandName = "my_command";
6412e41f4b71Sopenharmony_ciif (avSessionController !== undefined) {
6413e41f4b71Sopenharmony_ci  (avSessionController as avSession.AVSessionController).sendCommonCommand(commandName, {command : "This is my command"}).then(() => {
6414e41f4b71Sopenharmony_ci    console.info('SendCommonCommand successfully');
6415e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
6416e41f4b71Sopenharmony_ci    console.error(`SendCommonCommand BusinessError: code: ${err.code}, message: ${err.message}`);
6417e41f4b71Sopenharmony_ci  })
6418e41f4b71Sopenharmony_ci}
6419e41f4b71Sopenharmony_ci```
6420e41f4b71Sopenharmony_ci
6421e41f4b71Sopenharmony_ci### sendCommonCommand<sup>10+</sup>
6422e41f4b71Sopenharmony_ci
6423e41f4b71Sopenharmony_cisendCommonCommand(command: string, args: {[key: string]: Object}, callback: AsyncCallback\<void>): void
6424e41f4b71Sopenharmony_ci
6425e41f4b71Sopenharmony_ci通过会话控制器发送自定义命令到其对应的会话。结果通过callback异步回调方式返回。
6426e41f4b71Sopenharmony_ci
6427e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
6428e41f4b71Sopenharmony_ci
6429e41f4b71Sopenharmony_ci**参数:**
6430e41f4b71Sopenharmony_ci
6431e41f4b71Sopenharmony_ci| 参数名    | 类型                                  | 必填 | 说明                           |
6432e41f4b71Sopenharmony_ci| ------- | ------------------------------------- | ---- | ------------------------------ |
6433e41f4b71Sopenharmony_ci| command | string | 是   | 需要设置的自定义控制命令的名称 |
6434e41f4b71Sopenharmony_ci| args | {[key: string]: Object} | 是   | 需要传递的控制命令键值对 |
6435e41f4b71Sopenharmony_ci| callback | AsyncCallback\<void>                  | 是   | 回调函数。当命令发送成功,err为undefined,否则返回错误对象。                     |
6436e41f4b71Sopenharmony_ci
6437e41f4b71Sopenharmony_ci> **说明:**
6438e41f4b71Sopenharmony_ci> 参数args支持的数据类型有:字符串、数字、布尔、对象、数组和文件描述符等,详细介绍请参见[@ohos.app.ability.Want(Want)](../apis-ability-kit/js-apis-app-ability-want.md)。
6439e41f4b71Sopenharmony_ci
6440e41f4b71Sopenharmony_ci**错误码:**
6441e41f4b71Sopenharmony_ci
6442e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
6443e41f4b71Sopenharmony_ci
6444e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
6445e41f4b71Sopenharmony_ci| -------- | ------------------------------- |
6446e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Parameter verification failed.|
6447e41f4b71Sopenharmony_ci| 6600101  | Session service exception.                |
6448e41f4b71Sopenharmony_ci| 6600102  | The session does not exist.     |
6449e41f4b71Sopenharmony_ci| 6600103  | The session controller does not exist.   |
6450e41f4b71Sopenharmony_ci| 6600105  | Invalid session command.           |
6451e41f4b71Sopenharmony_ci| 6600106  | The session is not activated.                |
6452e41f4b71Sopenharmony_ci| 6600107  | Too many commands or events.      |
6453e41f4b71Sopenharmony_ci
6454e41f4b71Sopenharmony_ci**示例:**
6455e41f4b71Sopenharmony_ci
6456e41f4b71Sopenharmony_ci```ts
6457e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
6458e41f4b71Sopenharmony_cilet avSessionController: avSession.AVSessionController | undefined = undefined;
6459e41f4b71Sopenharmony_cilet currentAVSession: avSession.AVSession | undefined = undefined;
6460e41f4b71Sopenharmony_cilet tag = "createNewSession";
6461e41f4b71Sopenharmony_cilet context: Context = getContext(this);
6462e41f4b71Sopenharmony_ci
6463e41f4b71Sopenharmony_ciavSession.createAVSession(context, tag, "audio", (err: BusinessError, data: avSession.AVSession) => {
6464e41f4b71Sopenharmony_ci  if (err) {
6465e41f4b71Sopenharmony_ci    console.error(`CreateAVSession BusinessError: code: ${err.code}, message: ${err.message}`);
6466e41f4b71Sopenharmony_ci  } else {
6467e41f4b71Sopenharmony_ci    currentAVSession = data;
6468e41f4b71Sopenharmony_ci  }
6469e41f4b71Sopenharmony_ci});
6470e41f4b71Sopenharmony_ciif (currentAVSession !== undefined) {
6471e41f4b71Sopenharmony_ci  avSession.createController((currentAVSession as avSession.AVSession).sessionId).then((controller: avSession.AVSessionController) => {
6472e41f4b71Sopenharmony_ci    avSessionController = controller;
6473e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
6474e41f4b71Sopenharmony_ci    console.error(`CreateController BusinessError: code: ${err.code}, message: ${err.message}`);
6475e41f4b71Sopenharmony_ci  });
6476e41f4b71Sopenharmony_ci}
6477e41f4b71Sopenharmony_ci
6478e41f4b71Sopenharmony_cilet commandName = "my_command";
6479e41f4b71Sopenharmony_ciif (avSessionController !== undefined) {
6480e41f4b71Sopenharmony_ci  (avSessionController as avSession.AVSessionController).sendCommonCommand(commandName, {command : "This is my command"}, (err: BusinessError) => {
6481e41f4b71Sopenharmony_ci    if (err) {
6482e41f4b71Sopenharmony_ci        console.error(`SendCommonCommand BusinessError: code: ${err.code}, message: ${err.message}`);
6483e41f4b71Sopenharmony_ci    }
6484e41f4b71Sopenharmony_ci  })
6485e41f4b71Sopenharmony_ci}
6486e41f4b71Sopenharmony_ci```
6487e41f4b71Sopenharmony_ci
6488e41f4b71Sopenharmony_ci### getExtras<sup>10+</sup>
6489e41f4b71Sopenharmony_ci
6490e41f4b71Sopenharmony_cigetExtras(): Promise\<{[key: string]: Object}>
6491e41f4b71Sopenharmony_ci
6492e41f4b71Sopenharmony_ci获取媒体提供方设置的自定义媒体数据包。结果通过Promise异步回调方式返回。
6493e41f4b71Sopenharmony_ci
6494e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
6495e41f4b71Sopenharmony_ci
6496e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
6497e41f4b71Sopenharmony_ci
6498e41f4b71Sopenharmony_ci**返回值:**
6499e41f4b71Sopenharmony_ci
6500e41f4b71Sopenharmony_ci| 类型                                | 说明                          |
6501e41f4b71Sopenharmony_ci| ----------------------------------- | ----------------------------- |
6502e41f4b71Sopenharmony_ci| Promise<{[key: string]: Object}\>   | Promise对象,返回媒体提供方设置的自定义媒体数据包,数据包的内容与setExtras设置的内容完全一致。 |
6503e41f4b71Sopenharmony_ci
6504e41f4b71Sopenharmony_ci**错误码:**
6505e41f4b71Sopenharmony_ci
6506e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
6507e41f4b71Sopenharmony_ci
6508e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
6509e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
6510e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 3.Parameter verification failed. |
6511e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
6512e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
6513e41f4b71Sopenharmony_ci| 6600103  | The session controller does not exist. |
6514e41f4b71Sopenharmony_ci| 6600105  | Invalid session command. |
6515e41f4b71Sopenharmony_ci| 6600107  | Too many commands or events. |
6516e41f4b71Sopenharmony_ci
6517e41f4b71Sopenharmony_ci**示例:**
6518e41f4b71Sopenharmony_ci
6519e41f4b71Sopenharmony_ci```ts
6520e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
6521e41f4b71Sopenharmony_ci
6522e41f4b71Sopenharmony_cilet avSessionController: avSession.AVSessionController | undefined = undefined;
6523e41f4b71Sopenharmony_cilet currentAVSession: avSession.AVSession | undefined = undefined;
6524e41f4b71Sopenharmony_cilet tag = "createNewSession";
6525e41f4b71Sopenharmony_cilet context: Context = getContext(this);
6526e41f4b71Sopenharmony_ci
6527e41f4b71Sopenharmony_ciavSession.createAVSession(context, tag, "audio", (err: BusinessError, data: avSession.AVSession) => {
6528e41f4b71Sopenharmony_ci  if (err) {
6529e41f4b71Sopenharmony_ci    console.error(`CreateAVSession BusinessError: code: ${err.code}, message: ${err.message}`);
6530e41f4b71Sopenharmony_ci  } else {
6531e41f4b71Sopenharmony_ci    currentAVSession = data;
6532e41f4b71Sopenharmony_ci  }
6533e41f4b71Sopenharmony_ci});
6534e41f4b71Sopenharmony_ciif (currentAVSession !== undefined) {
6535e41f4b71Sopenharmony_ci  avSession.createController((currentAVSession as avSession.AVSession).sessionId).then((controller: avSession.AVSessionController) => {
6536e41f4b71Sopenharmony_ci    avSessionController = controller;
6537e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
6538e41f4b71Sopenharmony_ci    console.error(`CreateController BusinessError: code: ${err.code}, message: ${err.message}`);
6539e41f4b71Sopenharmony_ci  });
6540e41f4b71Sopenharmony_ci}
6541e41f4b71Sopenharmony_ci
6542e41f4b71Sopenharmony_ciif (avSessionController !== undefined) {
6543e41f4b71Sopenharmony_ci  (avSessionController as avSession.AVSessionController).getExtras().then((extras) => {
6544e41f4b71Sopenharmony_ci    console.info(`getExtras : SUCCESS : ${extras}`);
6545e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
6546e41f4b71Sopenharmony_ci    console.error(`getExtras BusinessError: code: ${err.code}, message: ${err.message}`);
6547e41f4b71Sopenharmony_ci  });
6548e41f4b71Sopenharmony_ci}
6549e41f4b71Sopenharmony_ci```
6550e41f4b71Sopenharmony_ci
6551e41f4b71Sopenharmony_ci### getExtras<sup>10+</sup>
6552e41f4b71Sopenharmony_ci
6553e41f4b71Sopenharmony_cigetExtras(callback: AsyncCallback\<{[key: string]: Object}>): void
6554e41f4b71Sopenharmony_ci
6555e41f4b71Sopenharmony_ci获取媒体提供方设置的自定义媒体数据包,结果通过callback异步回调方式返回。
6556e41f4b71Sopenharmony_ci
6557e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
6558e41f4b71Sopenharmony_ci
6559e41f4b71Sopenharmony_ci**参数:**
6560e41f4b71Sopenharmony_ci
6561e41f4b71Sopenharmony_ci| 参数名   | 类型                                      | 必填 | 说明                       |
6562e41f4b71Sopenharmony_ci| -------- | ----------------------------------------- | ---- | -------------------------- |
6563e41f4b71Sopenharmony_ci| callback | AsyncCallback<{[key: string]: Object}\> | 是   | 回调函数,返回媒体提供方设置的自定义媒体数据包,数据包的内容与setExtras设置的内容完全一致。 |
6564e41f4b71Sopenharmony_ci
6565e41f4b71Sopenharmony_ci**错误码:**
6566e41f4b71Sopenharmony_ci
6567e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
6568e41f4b71Sopenharmony_ci
6569e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
6570e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
6571e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 3.Parameter verification failed. |
6572e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
6573e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
6574e41f4b71Sopenharmony_ci| 6600103  | The session controller does not exist. |
6575e41f4b71Sopenharmony_ci| 6600105  | Invalid session command. |
6576e41f4b71Sopenharmony_ci| 6600107  | Too many commands or events. |
6577e41f4b71Sopenharmony_ci
6578e41f4b71Sopenharmony_ci**示例:**
6579e41f4b71Sopenharmony_ci
6580e41f4b71Sopenharmony_ci```ts
6581e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
6582e41f4b71Sopenharmony_ci
6583e41f4b71Sopenharmony_cilet avSessionController: avSession.AVSessionController | undefined = undefined;
6584e41f4b71Sopenharmony_cilet currentAVSession: avSession.AVSession | undefined = undefined;
6585e41f4b71Sopenharmony_cilet tag = "createNewSession";
6586e41f4b71Sopenharmony_cilet context: Context = getContext(this);
6587e41f4b71Sopenharmony_ci
6588e41f4b71Sopenharmony_ciavSession.createAVSession(context, tag, "audio", (err: BusinessError, data: avSession.AVSession) => {
6589e41f4b71Sopenharmony_ci  if (err) {
6590e41f4b71Sopenharmony_ci    console.error(`CreateAVSession BusinessError: code: ${err.code}, message: ${err.message}`);
6591e41f4b71Sopenharmony_ci  } else {
6592e41f4b71Sopenharmony_ci    currentAVSession = data;
6593e41f4b71Sopenharmony_ci  }
6594e41f4b71Sopenharmony_ci});
6595e41f4b71Sopenharmony_ciif (currentAVSession !== undefined) {
6596e41f4b71Sopenharmony_ci  avSession.createController((currentAVSession as avSession.AVSession).sessionId).then((controller: avSession.AVSessionController) => {
6597e41f4b71Sopenharmony_ci    avSessionController = controller;
6598e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
6599e41f4b71Sopenharmony_ci    console.error(`CreateController BusinessError: code: ${err.code}, message: ${err.message}`);
6600e41f4b71Sopenharmony_ci  });
6601e41f4b71Sopenharmony_ci}
6602e41f4b71Sopenharmony_ci
6603e41f4b71Sopenharmony_ciif (avSessionController !== undefined) {
6604e41f4b71Sopenharmony_ci  (avSessionController as avSession.AVSessionController).getExtras((err, extras) => {
6605e41f4b71Sopenharmony_ci    if (err) {
6606e41f4b71Sopenharmony_ci      console.error(`getExtras BusinessError: code: ${err.code}, message: ${err.message}`);
6607e41f4b71Sopenharmony_ci    } else {
6608e41f4b71Sopenharmony_ci      console.info(`getExtras : SUCCESS : ${extras}`);
6609e41f4b71Sopenharmony_ci    }
6610e41f4b71Sopenharmony_ci  });
6611e41f4b71Sopenharmony_ci}
6612e41f4b71Sopenharmony_ci```
6613e41f4b71Sopenharmony_ci
6614e41f4b71Sopenharmony_ci### on('metadataChange')<sup>10+</sup>
6615e41f4b71Sopenharmony_ci
6616e41f4b71Sopenharmony_cion(type: 'metadataChange', filter: Array\<keyof AVMetadata> | 'all', callback: (data: AVMetadata) => void)
6617e41f4b71Sopenharmony_ci
6618e41f4b71Sopenharmony_ci设置元数据变化的监听事件。
6619e41f4b71Sopenharmony_ci
6620e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
6621e41f4b71Sopenharmony_ci
6622e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
6623e41f4b71Sopenharmony_ci
6624e41f4b71Sopenharmony_ci**参数:**
6625e41f4b71Sopenharmony_ci
6626e41f4b71Sopenharmony_ci| 参数名   | 类型                                                         | 必填 | 说明                                                         |
6627e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
6628e41f4b71Sopenharmony_ci| type     | string                                                       | 是   | 事件回调类型,支持事件`'metadataChange'`:当元数据变化时,触发该事件。 |
6629e41f4b71Sopenharmony_ci| filter   | Array\<keyof&nbsp;[AVMetadata](#avmetadata10)\>&nbsp;&#124;&nbsp;'all' | 是   | 'all' 表示关注元数据所有字段变化;Array<keyof&nbsp;[AVMetadata](#avmetadata10)\> 表示关注Array中的字段变化。 |
6630e41f4b71Sopenharmony_ci| callback | (data: [AVMetadata](#avmetadata10)) => void                    | 是   | 回调函数,参数data是变化后的元数据。                         |
6631e41f4b71Sopenharmony_ci
6632e41f4b71Sopenharmony_ci**错误码:**
6633e41f4b71Sopenharmony_ci
6634e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
6635e41f4b71Sopenharmony_ci
6636e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
6637e41f4b71Sopenharmony_ci| -------- | ------------------------------ |
6638e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
6639e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
6640e41f4b71Sopenharmony_ci| 6600103  | The session controller does not exist. |
6641e41f4b71Sopenharmony_ci
6642e41f4b71Sopenharmony_ci**示例:**
6643e41f4b71Sopenharmony_ci
6644e41f4b71Sopenharmony_ci```ts
6645e41f4b71Sopenharmony_ciavsessionController.on('metadataChange', 'all', (metadata: avSession.AVMetadata) => {
6646e41f4b71Sopenharmony_ci  console.info(`on metadataChange assetId : ${metadata.assetId}`);
6647e41f4b71Sopenharmony_ci});
6648e41f4b71Sopenharmony_ci
6649e41f4b71Sopenharmony_ciavsessionController.on('metadataChange', ['assetId', 'title', 'description'], (metadata: avSession.AVMetadata) => {
6650e41f4b71Sopenharmony_ci  console.info(`on metadataChange assetId : ${metadata.assetId}`);
6651e41f4b71Sopenharmony_ci});
6652e41f4b71Sopenharmony_ci
6653e41f4b71Sopenharmony_ci```
6654e41f4b71Sopenharmony_ci
6655e41f4b71Sopenharmony_ci### off('metadataChange')<sup>10+</sup>
6656e41f4b71Sopenharmony_ci
6657e41f4b71Sopenharmony_cioff(type: 'metadataChange', callback?: (data: AVMetadata) => void)
6658e41f4b71Sopenharmony_ci
6659e41f4b71Sopenharmony_ci媒体控制器取消监听元数据变化的事件。
6660e41f4b71Sopenharmony_ci
6661e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
6662e41f4b71Sopenharmony_ci
6663e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
6664e41f4b71Sopenharmony_ci
6665e41f4b71Sopenharmony_ci**参数:**
6666e41f4b71Sopenharmony_ci
6667e41f4b71Sopenharmony_ci| 参数名   | 类型                                               | 必填 | 说明                                                    |
6668e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------ | ---- | ------------------------------------------------------ |
6669e41f4b71Sopenharmony_ci| type     | string                                           | 是   | 取消对应的监听事件,支持事件`'metadataChange'`。         |
6670e41f4b71Sopenharmony_ci| callback | (data: [AVMetadata](#avmetadata10)) => void        | 否   | 回调函数,参数data是变化后的元数据。<br>该参数为可选参数,若不填写该参数,则认为取消所有相关会话的事件监听。                         |
6671e41f4b71Sopenharmony_ci
6672e41f4b71Sopenharmony_ci**错误码:**
6673e41f4b71Sopenharmony_ci
6674e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
6675e41f4b71Sopenharmony_ci
6676e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
6677e41f4b71Sopenharmony_ci| -------- | ---------------- |
6678e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
6679e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
6680e41f4b71Sopenharmony_ci| 6600103  | The session controller does not exist. |
6681e41f4b71Sopenharmony_ci
6682e41f4b71Sopenharmony_ci**示例:**
6683e41f4b71Sopenharmony_ci
6684e41f4b71Sopenharmony_ci```ts
6685e41f4b71Sopenharmony_ciavsessionController.off('metadataChange');
6686e41f4b71Sopenharmony_ci```
6687e41f4b71Sopenharmony_ci
6688e41f4b71Sopenharmony_ci### on('playbackStateChange')<sup>10+</sup>
6689e41f4b71Sopenharmony_ci
6690e41f4b71Sopenharmony_cion(type: 'playbackStateChange', filter: Array\<keyof AVPlaybackState> | 'all', callback: (state: AVPlaybackState) => void)
6691e41f4b71Sopenharmony_ci
6692e41f4b71Sopenharmony_ci设置播放状态变化的监听事件。
6693e41f4b71Sopenharmony_ci
6694e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
6695e41f4b71Sopenharmony_ci
6696e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
6697e41f4b71Sopenharmony_ci
6698e41f4b71Sopenharmony_ci**参数:**
6699e41f4b71Sopenharmony_ci
6700e41f4b71Sopenharmony_ci| 参数名   | 类型       | 必填 | 说明      |
6701e41f4b71Sopenharmony_ci| --------| -----------|-----|------------|
6702e41f4b71Sopenharmony_ci| type     | string    | 是   | 事件回调类型,支持事件`'playbackStateChange'`:当播放状态变化时,触发该事件。 |
6703e41f4b71Sopenharmony_ci| filter   | Array\<keyof&nbsp;[AVPlaybackState](#avplaybackstate10)\>&nbsp;&#124;&nbsp;'all' | 是   | 'all' 表示关注播放状态所有字段变化;Array<keyof&nbsp;[AVPlaybackState](#avplaybackstate10)\> 表示关注Array中的字段变化。 |
6704e41f4b71Sopenharmony_ci| callback | (state: [AVPlaybackState](#avplaybackstate10)) => void       | 是   | 回调函数,参数state是变化后的播放状态。|
6705e41f4b71Sopenharmony_ci
6706e41f4b71Sopenharmony_ci**错误码:**
6707e41f4b71Sopenharmony_ci
6708e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
6709e41f4b71Sopenharmony_ci
6710e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
6711e41f4b71Sopenharmony_ci| -------- | ------------------------------ |
6712e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
6713e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
6714e41f4b71Sopenharmony_ci| 6600103  | The session controller does not exist. |
6715e41f4b71Sopenharmony_ci
6716e41f4b71Sopenharmony_ci**示例:**
6717e41f4b71Sopenharmony_ci
6718e41f4b71Sopenharmony_ci```ts
6719e41f4b71Sopenharmony_ciavsessionController.on('playbackStateChange', 'all', (playbackState: avSession.AVPlaybackState) => {
6720e41f4b71Sopenharmony_ci  console.info(`on playbackStateChange state : ${playbackState.state}`);
6721e41f4b71Sopenharmony_ci});
6722e41f4b71Sopenharmony_ci
6723e41f4b71Sopenharmony_ciavsessionController.on('playbackStateChange', ['state', 'speed', 'loopMode'], (playbackState: avSession.AVPlaybackState) => {
6724e41f4b71Sopenharmony_ci  console.info(`on playbackStateChange state : ${playbackState.state}`);
6725e41f4b71Sopenharmony_ci});
6726e41f4b71Sopenharmony_ci```
6727e41f4b71Sopenharmony_ci
6728e41f4b71Sopenharmony_ci### off('playbackStateChange')<sup>10+</sup>
6729e41f4b71Sopenharmony_ci
6730e41f4b71Sopenharmony_cioff(type: 'playbackStateChange', callback?: (state: AVPlaybackState) => void)
6731e41f4b71Sopenharmony_ci
6732e41f4b71Sopenharmony_ci媒体控制器取消监听播放状态变化的事件。
6733e41f4b71Sopenharmony_ci
6734e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
6735e41f4b71Sopenharmony_ci
6736e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
6737e41f4b71Sopenharmony_ci
6738e41f4b71Sopenharmony_ci**参数:**
6739e41f4b71Sopenharmony_ci
6740e41f4b71Sopenharmony_ci| 参数名   | 类型                                                         | 必填 | 说明                                                     |
6741e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | ---- | ----------------------------------------------------- |
6742e41f4b71Sopenharmony_ci| type     | string                                                       | 是   | 取消对应的监听事件,支持事件`'playbackStateChange'`。    |
6743e41f4b71Sopenharmony_ci| callback | (state: [AVPlaybackState](#avplaybackstate10)) => void         | 否   | 回调函数,参数state是变化后的播放状态。<br>该参数为可选参数,若不填写该参数,则认为取消所有相关会话的事件监听。                      |
6744e41f4b71Sopenharmony_ci
6745e41f4b71Sopenharmony_ci**错误码:**
6746e41f4b71Sopenharmony_ci
6747e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
6748e41f4b71Sopenharmony_ci
6749e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
6750e41f4b71Sopenharmony_ci| -------- | ---------------- |
6751e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
6752e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
6753e41f4b71Sopenharmony_ci| 6600103  | The session controller does not exist. |
6754e41f4b71Sopenharmony_ci
6755e41f4b71Sopenharmony_ci**示例:**
6756e41f4b71Sopenharmony_ci
6757e41f4b71Sopenharmony_ci```ts
6758e41f4b71Sopenharmony_ciavsessionController.off('playbackStateChange');
6759e41f4b71Sopenharmony_ci```
6760e41f4b71Sopenharmony_ci
6761e41f4b71Sopenharmony_ci### on('callMetadataChange')<sup>11+</sup>
6762e41f4b71Sopenharmony_ci
6763e41f4b71Sopenharmony_cion(type: 'callMetadataChange', filter: Array\<keyof CallMetadata> | 'all', callback: Callback\<CallMetadata>): void;
6764e41f4b71Sopenharmony_ci
6765e41f4b71Sopenharmony_ci设置通话元数据变化的监听事件。
6766e41f4b71Sopenharmony_ci
6767e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
6768e41f4b71Sopenharmony_ci
6769e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
6770e41f4b71Sopenharmony_ci
6771e41f4b71Sopenharmony_ci**参数:**
6772e41f4b71Sopenharmony_ci
6773e41f4b71Sopenharmony_ci| 参数名   | 类型       | 必填 | 说明      |
6774e41f4b71Sopenharmony_ci| --------| -----------|-----|------------|
6775e41f4b71Sopenharmony_ci| type     | string    | 是   | 事件回调类型,支持事件`'callMetadataChange'`:当通话元数据变化时,触发该事件。 |
6776e41f4b71Sopenharmony_ci| filter   | Array\<keyof&nbsp;[CallMetadata](#callmetadata11)\>&nbsp;&#124;&nbsp;'all' | 是   | 'all' 表示关注通话元数据所有字段变化;Array<keyof&nbsp;[CallMetadata](#callmetadata11)\> 表示关注Array中的字段变化。 |
6777e41f4b71Sopenharmony_ci| callback | Callback<[CallMetadata](#callmetadata11)\>\>   | 是   | 回调函数,参数callmetadata是变化后的通话元数据。|
6778e41f4b71Sopenharmony_ci
6779e41f4b71Sopenharmony_ci**错误码:**
6780e41f4b71Sopenharmony_ci
6781e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
6782e41f4b71Sopenharmony_ci
6783e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
6784e41f4b71Sopenharmony_ci| -------- | ------------------------------ |
6785e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
6786e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
6787e41f4b71Sopenharmony_ci| 6600103  | The session controller does not exist. |
6788e41f4b71Sopenharmony_ci
6789e41f4b71Sopenharmony_ci**示例:**
6790e41f4b71Sopenharmony_ci
6791e41f4b71Sopenharmony_ci```ts
6792e41f4b71Sopenharmony_ciavsessionController.on('callMetadataChange', 'all', (callmetadata: avSession.CallMetadata) => {
6793e41f4b71Sopenharmony_ci  console.info(`on callMetadataChange state : ${callmetadata.name}`);
6794e41f4b71Sopenharmony_ci});
6795e41f4b71Sopenharmony_ci
6796e41f4b71Sopenharmony_ciavsessionController.on('callMetadataChange', ['name'], (callmetadata: avSession.CallMetadata) => {
6797e41f4b71Sopenharmony_ci  console.info(`on callMetadataChange state : ${callmetadata.name}`);
6798e41f4b71Sopenharmony_ci});
6799e41f4b71Sopenharmony_ci```
6800e41f4b71Sopenharmony_ci
6801e41f4b71Sopenharmony_ci### off('callMetadataChange')<sup>11+</sup>
6802e41f4b71Sopenharmony_ci
6803e41f4b71Sopenharmony_cioff(type: 'callMetadataChange', callback?: Callback\<CallMetadata>): void;
6804e41f4b71Sopenharmony_ci
6805e41f4b71Sopenharmony_ci取消设置通话元数据变化的监听事件。
6806e41f4b71Sopenharmony_ci
6807e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
6808e41f4b71Sopenharmony_ci
6809e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
6810e41f4b71Sopenharmony_ci
6811e41f4b71Sopenharmony_ci**参数:**
6812e41f4b71Sopenharmony_ci
6813e41f4b71Sopenharmony_ci| 参数名   | 类型                                                         | 必填 | 说明                                                     |
6814e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | ---- | ----------------------------------------------------- |
6815e41f4b71Sopenharmony_ci| type     | string                                                       | 是   | 取消对应的监听事件,支持事件`'callMetadataChange'`。    |
6816e41f4b71Sopenharmony_ci| callback | Callback<[CallMetadata](#callmetadata11)\>       | 否   | 回调函数,参数calldata是变化后的通话原数据。<br>该参数为可选参数,若不填写该参数,则认为取消所有相关会话的事件监听。      |
6817e41f4b71Sopenharmony_ci
6818e41f4b71Sopenharmony_ci**错误码:**
6819e41f4b71Sopenharmony_ci
6820e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
6821e41f4b71Sopenharmony_ci
6822e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
6823e41f4b71Sopenharmony_ci| -------- | ---------------- |
6824e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
6825e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
6826e41f4b71Sopenharmony_ci| 6600103  | The session controller does not exist. |
6827e41f4b71Sopenharmony_ci
6828e41f4b71Sopenharmony_ci**示例:**
6829e41f4b71Sopenharmony_ci
6830e41f4b71Sopenharmony_ci```ts
6831e41f4b71Sopenharmony_ciavsessionController.off('callMetadataChange');
6832e41f4b71Sopenharmony_ci```
6833e41f4b71Sopenharmony_ci
6834e41f4b71Sopenharmony_ci### on('callStateChange')<sup>11+</sup>
6835e41f4b71Sopenharmony_ci
6836e41f4b71Sopenharmony_cion(type: 'callStateChange', filter: Array\<keyof AVCallState> | 'all', callback: Callback\<AVCallState>): void;
6837e41f4b71Sopenharmony_ci
6838e41f4b71Sopenharmony_ci设置通话状态变化的监听事件。
6839e41f4b71Sopenharmony_ci
6840e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
6841e41f4b71Sopenharmony_ci
6842e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
6843e41f4b71Sopenharmony_ci
6844e41f4b71Sopenharmony_ci**参数:**
6845e41f4b71Sopenharmony_ci
6846e41f4b71Sopenharmony_ci| 参数名   | 类型       | 必填 | 说明      |
6847e41f4b71Sopenharmony_ci| --------| -----------|-----|------------|
6848e41f4b71Sopenharmony_ci| type     | string    | 是   | 事件回调类型,支持事件`'callStateChange'`:当通话状态变化时,触发该事件。 |
6849e41f4b71Sopenharmony_ci| filter   | Array<keyof&nbsp;[AVCallState](#avcallstate11)\>&nbsp;&#124;&nbsp;'all' | 是   | 'all' 表示关注通话状态所有字段变化;Array<keyof&nbsp;[AVCallState](#avcallstate11)\> 表示关注Array中的字段变化。 |
6850e41f4b71Sopenharmony_ci| callback | Callback<[AVCallState](#avcallstate11)\>       | 是   | 回调函数,参数callstate是变化后的通话状态。|
6851e41f4b71Sopenharmony_ci
6852e41f4b71Sopenharmony_ci**错误码:**
6853e41f4b71Sopenharmony_ci
6854e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
6855e41f4b71Sopenharmony_ci
6856e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
6857e41f4b71Sopenharmony_ci| -------- | ------------------------------ |
6858e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
6859e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
6860e41f4b71Sopenharmony_ci| 6600103  | The session controller does not exist. |
6861e41f4b71Sopenharmony_ci
6862e41f4b71Sopenharmony_ci**示例:**
6863e41f4b71Sopenharmony_ci
6864e41f4b71Sopenharmony_ci```ts
6865e41f4b71Sopenharmony_ciavsessionController.on('callStateChange', 'all', (callstate: avSession.AVCallState) => {
6866e41f4b71Sopenharmony_ci  console.info(`on callStateChange state : ${callstate.state}`);
6867e41f4b71Sopenharmony_ci});
6868e41f4b71Sopenharmony_ci
6869e41f4b71Sopenharmony_ciavsessionController.on('callStateChange', ['state'], (callstate: avSession.AVCallState) => {
6870e41f4b71Sopenharmony_ci  console.info(`on callStateChange state : ${callstate.state}`);
6871e41f4b71Sopenharmony_ci});
6872e41f4b71Sopenharmony_ci```
6873e41f4b71Sopenharmony_ci
6874e41f4b71Sopenharmony_ci### off('callStateChange')<sup>11+</sup>
6875e41f4b71Sopenharmony_ci
6876e41f4b71Sopenharmony_cioff(type: 'callStateChange', callback?: Callback\<AVCallState>): void;
6877e41f4b71Sopenharmony_ci
6878e41f4b71Sopenharmony_ci取消设置通话状态变化的监听事件。
6879e41f4b71Sopenharmony_ci
6880e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
6881e41f4b71Sopenharmony_ci
6882e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
6883e41f4b71Sopenharmony_ci
6884e41f4b71Sopenharmony_ci**参数:**
6885e41f4b71Sopenharmony_ci
6886e41f4b71Sopenharmony_ci| 参数名   | 类型                                                         | 必填 | 说明                                                     |
6887e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | ---- | ----------------------------------------------------- |
6888e41f4b71Sopenharmony_ci| type     | string                                                       | 是   | 取消对应的监听事件,支持事件`'callStateChange'`。    |
6889e41f4b71Sopenharmony_ci| callback | Callback<[AVCallState](#avcallstate11)\>           | 否   | 回调函数,参数callstate是变化后的通话状态。<br>该参数为可选参数,若不填写该参数,则认为取消所有相关会话的事件监听。      |
6890e41f4b71Sopenharmony_ci
6891e41f4b71Sopenharmony_ci**错误码:**
6892e41f4b71Sopenharmony_ci
6893e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
6894e41f4b71Sopenharmony_ci
6895e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
6896e41f4b71Sopenharmony_ci| -------- | ---------------- |
6897e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
6898e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
6899e41f4b71Sopenharmony_ci| 6600103  | The session controller does not exist. |
6900e41f4b71Sopenharmony_ci
6901e41f4b71Sopenharmony_ci**示例:**
6902e41f4b71Sopenharmony_ci
6903e41f4b71Sopenharmony_ci```ts
6904e41f4b71Sopenharmony_ciavsessionController.off('callMetadataChange');
6905e41f4b71Sopenharmony_ci```
6906e41f4b71Sopenharmony_ci
6907e41f4b71Sopenharmony_ci### on('sessionDestroy')<sup>10+</sup>
6908e41f4b71Sopenharmony_ci
6909e41f4b71Sopenharmony_cion(type: 'sessionDestroy', callback: () => void)
6910e41f4b71Sopenharmony_ci
6911e41f4b71Sopenharmony_ci会话销毁的监听事件。
6912e41f4b71Sopenharmony_ci
6913e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
6914e41f4b71Sopenharmony_ci
6915e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
6916e41f4b71Sopenharmony_ci
6917e41f4b71Sopenharmony_ci**参数:**
6918e41f4b71Sopenharmony_ci
6919e41f4b71Sopenharmony_ci| 参数名   | 类型       | 必填 | 说明                                                         |
6920e41f4b71Sopenharmony_ci| -------- | ---------- | ---- | ------------------------------------------------------------ |
6921e41f4b71Sopenharmony_ci| type     | string     | 是   | 事件回调类型,支持事件`'sessionDestroy'`:当检测到会话销毁时,触发该事件)。 |
6922e41f4b71Sopenharmony_ci| callback | () => void | 是   | 回调函数。当监听事件注册成功,err为undefined,否则为错误对象。                  |
6923e41f4b71Sopenharmony_ci
6924e41f4b71Sopenharmony_ci**错误码:**
6925e41f4b71Sopenharmony_ci
6926e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
6927e41f4b71Sopenharmony_ci
6928e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
6929e41f4b71Sopenharmony_ci| -------- | ------------------------------ |
6930e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
6931e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
6932e41f4b71Sopenharmony_ci| 6600103  | The session controller does not exist. |
6933e41f4b71Sopenharmony_ci
6934e41f4b71Sopenharmony_ci**示例:**
6935e41f4b71Sopenharmony_ci
6936e41f4b71Sopenharmony_ci```ts
6937e41f4b71Sopenharmony_ciavsessionController.on('sessionDestroy', () => {
6938e41f4b71Sopenharmony_ci  console.info('on sessionDestroy : SUCCESS ');
6939e41f4b71Sopenharmony_ci});
6940e41f4b71Sopenharmony_ci```
6941e41f4b71Sopenharmony_ci
6942e41f4b71Sopenharmony_ci### off('sessionDestroy')<sup>10+</sup>
6943e41f4b71Sopenharmony_ci
6944e41f4b71Sopenharmony_cioff(type: 'sessionDestroy', callback?: () => void)
6945e41f4b71Sopenharmony_ci
6946e41f4b71Sopenharmony_ci媒体控制器取消监听会话的销毁事件。
6947e41f4b71Sopenharmony_ci
6948e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
6949e41f4b71Sopenharmony_ci
6950e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
6951e41f4b71Sopenharmony_ci
6952e41f4b71Sopenharmony_ci**参数:**
6953e41f4b71Sopenharmony_ci
6954e41f4b71Sopenharmony_ci| 参数名   | 类型       | 必填 | 说明                                                      |
6955e41f4b71Sopenharmony_ci| -------- | ---------- | ---- | ----------------------------------------------------- |
6956e41f4b71Sopenharmony_ci| type     | string     | 是   | 取消对应的监听事件,支持事件`'sessionDestroy'`。         |
6957e41f4b71Sopenharmony_ci| callback | () => void | 否   | 回调函数。当监听事件取消成功,err为undefined,否则返回错误对象。<br>该参数为可选参数,若不填写该参数,则认为取消所有相关会话的事件监听。                                               |
6958e41f4b71Sopenharmony_ci
6959e41f4b71Sopenharmony_ci**错误码:**
6960e41f4b71Sopenharmony_ci
6961e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
6962e41f4b71Sopenharmony_ci
6963e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
6964e41f4b71Sopenharmony_ci| -------- | ---------------- |
6965e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
6966e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
6967e41f4b71Sopenharmony_ci| 6600103  | The session controller does not exist. |
6968e41f4b71Sopenharmony_ci
6969e41f4b71Sopenharmony_ci**示例:**
6970e41f4b71Sopenharmony_ci
6971e41f4b71Sopenharmony_ci```ts
6972e41f4b71Sopenharmony_ciavsessionController.off('sessionDestroy');
6973e41f4b71Sopenharmony_ci```
6974e41f4b71Sopenharmony_ci
6975e41f4b71Sopenharmony_ci### on('activeStateChange')<sup>10+</sup>
6976e41f4b71Sopenharmony_ci
6977e41f4b71Sopenharmony_cion(type: 'activeStateChange', callback: (isActive: boolean) => void)
6978e41f4b71Sopenharmony_ci
6979e41f4b71Sopenharmony_ci会话的激活状态的监听事件。
6980e41f4b71Sopenharmony_ci
6981e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
6982e41f4b71Sopenharmony_ci
6983e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
6984e41f4b71Sopenharmony_ci
6985e41f4b71Sopenharmony_ci**参数:**
6986e41f4b71Sopenharmony_ci
6987e41f4b71Sopenharmony_ci| 参数名   | 类型                        | 必填 | 说明                                                         |
6988e41f4b71Sopenharmony_ci| -------- | --------------------------- | ---- | ------------------------------------------------------------ |
6989e41f4b71Sopenharmony_ci| type     | string                      | 是   | 事件回调类型,支持事件`'activeStateChange'`:当检测到会话的激活状态发生改变时,触发该事件。 |
6990e41f4b71Sopenharmony_ci| callback | (isActive: boolean) => void | 是   | 回调函数。参数isActive表示会话是否被激活。true表示被激活,false表示禁用。                   |
6991e41f4b71Sopenharmony_ci
6992e41f4b71Sopenharmony_ci**错误码:**
6993e41f4b71Sopenharmony_ci
6994e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
6995e41f4b71Sopenharmony_ci
6996e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
6997e41f4b71Sopenharmony_ci| -------- | ----------------------------- |
6998e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
6999e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
7000e41f4b71Sopenharmony_ci| 6600103  |The session controller does not exist. |
7001e41f4b71Sopenharmony_ci
7002e41f4b71Sopenharmony_ci**示例:**
7003e41f4b71Sopenharmony_ci
7004e41f4b71Sopenharmony_ci```ts
7005e41f4b71Sopenharmony_ciavsessionController.on('activeStateChange', (isActive: boolean) => {
7006e41f4b71Sopenharmony_ci  console.info(`on activeStateChange : SUCCESS : isActive ${isActive}`);
7007e41f4b71Sopenharmony_ci});
7008e41f4b71Sopenharmony_ci```
7009e41f4b71Sopenharmony_ci
7010e41f4b71Sopenharmony_ci### off('activeStateChange')<sup>10+</sup>
7011e41f4b71Sopenharmony_ci
7012e41f4b71Sopenharmony_cioff(type: 'activeStateChange', callback?: (isActive: boolean) => void)
7013e41f4b71Sopenharmony_ci
7014e41f4b71Sopenharmony_ci媒体控制器取消监听会话激活状态变化的事件。
7015e41f4b71Sopenharmony_ci
7016e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
7017e41f4b71Sopenharmony_ci
7018e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
7019e41f4b71Sopenharmony_ci
7020e41f4b71Sopenharmony_ci**参数:**
7021e41f4b71Sopenharmony_ci
7022e41f4b71Sopenharmony_ci| 参数名   | 类型                        | 必填 | 说明                                                      |
7023e41f4b71Sopenharmony_ci| -------- | --------------------------- | ---- | ----------------------------------------------------- |
7024e41f4b71Sopenharmony_ci| type     | string                      | 是   | 取消对应的监听事件,支持事件`'activeStateChange'`。      |
7025e41f4b71Sopenharmony_ci| callback | (isActive: boolean) => void | 否   | 回调函数。参数isActive表示会话是否被激活。true表示被激活,false表示禁用。<br>该参数为可选参数,若不填写该参数,则认为取消所有相关会话的事件监听。                   |
7026e41f4b71Sopenharmony_ci
7027e41f4b71Sopenharmony_ci**错误码:**
7028e41f4b71Sopenharmony_ci
7029e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
7030e41f4b71Sopenharmony_ci
7031e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
7032e41f4b71Sopenharmony_ci| -------- | ---------------- |
7033e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
7034e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
7035e41f4b71Sopenharmony_ci| 6600103  | The session controller does not exist. |
7036e41f4b71Sopenharmony_ci
7037e41f4b71Sopenharmony_ci**示例:**
7038e41f4b71Sopenharmony_ci
7039e41f4b71Sopenharmony_ci```ts
7040e41f4b71Sopenharmony_ciavsessionController.off('activeStateChange');
7041e41f4b71Sopenharmony_ci```
7042e41f4b71Sopenharmony_ci
7043e41f4b71Sopenharmony_ci### on('validCommandChange')<sup>10+</sup>
7044e41f4b71Sopenharmony_ci
7045e41f4b71Sopenharmony_cion(type: 'validCommandChange', callback: (commands: Array\<AVControlCommandType>) => void)
7046e41f4b71Sopenharmony_ci
7047e41f4b71Sopenharmony_ci会话支持的有效命令变化监听事件。
7048e41f4b71Sopenharmony_ci
7049e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
7050e41f4b71Sopenharmony_ci
7051e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
7052e41f4b71Sopenharmony_ci
7053e41f4b71Sopenharmony_ci**参数:**
7054e41f4b71Sopenharmony_ci
7055e41f4b71Sopenharmony_ci| 参数名   | 类型                                                         | 必填 | 说明                                                         |
7056e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
7057e41f4b71Sopenharmony_ci| type     | string                                                       | 是   | 事件回调类型,支持事件`'validCommandChange'`:当检测到会话的合法命令发生改变时,触发该事件。 |
7058e41f4b71Sopenharmony_ci| callback | (commands: Array<[AVControlCommandType](#avcontrolcommandtype10)\>) => void | 是   | 回调函数。参数commands是有效命令的集合。                     |
7059e41f4b71Sopenharmony_ci
7060e41f4b71Sopenharmony_ci**错误码:**
7061e41f4b71Sopenharmony_ci
7062e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
7063e41f4b71Sopenharmony_ci
7064e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
7065e41f4b71Sopenharmony_ci| -------- | ------------------------------ |
7066e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
7067e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
7068e41f4b71Sopenharmony_ci| 6600103  | The session controller does not exist. |
7069e41f4b71Sopenharmony_ci
7070e41f4b71Sopenharmony_ci**示例:**
7071e41f4b71Sopenharmony_ci
7072e41f4b71Sopenharmony_ci```ts
7073e41f4b71Sopenharmony_ciavsessionController.on('validCommandChange', (validCommands: avSession.AVControlCommandType[]) => {
7074e41f4b71Sopenharmony_ci  console.info(`validCommandChange : SUCCESS : size : ${validCommands.length}`);
7075e41f4b71Sopenharmony_ci  console.info(`validCommandChange : SUCCESS : validCommands : ${validCommands.values()}`);
7076e41f4b71Sopenharmony_ci});
7077e41f4b71Sopenharmony_ci```
7078e41f4b71Sopenharmony_ci
7079e41f4b71Sopenharmony_ci### off('validCommandChange')<sup>10+</sup>
7080e41f4b71Sopenharmony_ci
7081e41f4b71Sopenharmony_cioff(type: 'validCommandChange', callback?: (commands: Array\<AVControlCommandType>) => void)
7082e41f4b71Sopenharmony_ci
7083e41f4b71Sopenharmony_ci媒体控制器取消监听会话有效命令变化的事件。
7084e41f4b71Sopenharmony_ci
7085e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
7086e41f4b71Sopenharmony_ci
7087e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
7088e41f4b71Sopenharmony_ci
7089e41f4b71Sopenharmony_ci**参数:**
7090e41f4b71Sopenharmony_ci
7091e41f4b71Sopenharmony_ci| 参数名   | 类型                                                         | 必填 | 说明                                                        |
7092e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | ---- | -------------------------------------------------------- |
7093e41f4b71Sopenharmony_ci| type     | string                                                       | 是   | 取消对应的监听事件,支持事件`'validCommandChange'`。         |
7094e41f4b71Sopenharmony_ci| callback | (commands: Array<[AVControlCommandType](#avcontrolcommandtype10)\>) => void | 否   | 回调函数。参数commands是有效命令的集合。<br>该参数为可选参数,若不填写该参数,则认为取消所有相关会话的事件监听。          |
7095e41f4b71Sopenharmony_ci
7096e41f4b71Sopenharmony_ci**错误码:**
7097e41f4b71Sopenharmony_ci
7098e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
7099e41f4b71Sopenharmony_ci
7100e41f4b71Sopenharmony_ci| 错误码ID | 错误信息           |
7101e41f4b71Sopenharmony_ci| -------- | ---------------- |
7102e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
7103e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
7104e41f4b71Sopenharmony_ci| 6600103  | The session controller does not exist. |
7105e41f4b71Sopenharmony_ci
7106e41f4b71Sopenharmony_ci**示例:**
7107e41f4b71Sopenharmony_ci
7108e41f4b71Sopenharmony_ci```ts
7109e41f4b71Sopenharmony_ciavsessionController.off('validCommandChange');
7110e41f4b71Sopenharmony_ci```
7111e41f4b71Sopenharmony_ci
7112e41f4b71Sopenharmony_ci### on('outputDeviceChange')<sup>10+</sup>
7113e41f4b71Sopenharmony_ci
7114e41f4b71Sopenharmony_cion(type: 'outputDeviceChange', callback: (state: ConnectionState, device: OutputDeviceInfo) => void): void
7115e41f4b71Sopenharmony_ci
7116e41f4b71Sopenharmony_ci设置播放设备变化的监听事件。
7117e41f4b71Sopenharmony_ci
7118e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
7119e41f4b71Sopenharmony_ci
7120e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
7121e41f4b71Sopenharmony_ci
7122e41f4b71Sopenharmony_ci**参数:**
7123e41f4b71Sopenharmony_ci
7124e41f4b71Sopenharmony_ci| 参数名   | 类型                                                    | 必填 | 说明                                                         |
7125e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ |
7126e41f4b71Sopenharmony_ci| type     | string                                                  | 是   | 事件回调类型,支持事件为`'outputDeviceChange'`:当播放设备变化时,触发该事件)。 |
7127e41f4b71Sopenharmony_ci| callback | (state: [ConnectionState](#connectionstate10), device: [OutputDeviceInfo](#outputdeviceinfo10)) => void | 是   | 回调函数,参数device是设备相关信息。                         |
7128e41f4b71Sopenharmony_ci
7129e41f4b71Sopenharmony_ci**错误码:**
7130e41f4b71Sopenharmony_ci
7131e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
7132e41f4b71Sopenharmony_ci
7133e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
7134e41f4b71Sopenharmony_ci| -------- | ----------------------- |
7135e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
7136e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
7137e41f4b71Sopenharmony_ci| 6600103  | The session controller does not exist. |
7138e41f4b71Sopenharmony_ci
7139e41f4b71Sopenharmony_ci**示例:**
7140e41f4b71Sopenharmony_ci
7141e41f4b71Sopenharmony_ci```ts
7142e41f4b71Sopenharmony_ciavsessionController.on('outputDeviceChange', (state: avSession.ConnectionState, device: avSession.OutputDeviceInfo) => {
7143e41f4b71Sopenharmony_ci  console.info(`on outputDeviceChange state: ${state}, device : ${device}`);
7144e41f4b71Sopenharmony_ci});
7145e41f4b71Sopenharmony_ci```
7146e41f4b71Sopenharmony_ci
7147e41f4b71Sopenharmony_ci### off('outputDeviceChange')<sup>10+</sup>
7148e41f4b71Sopenharmony_ci
7149e41f4b71Sopenharmony_cioff(type: 'outputDeviceChange', callback?: (state: ConnectionState, device: OutputDeviceInfo) => void): void
7150e41f4b71Sopenharmony_ci
7151e41f4b71Sopenharmony_ci媒体控制器取消监听分布式设备变化的事件。
7152e41f4b71Sopenharmony_ci
7153e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
7154e41f4b71Sopenharmony_ci
7155e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
7156e41f4b71Sopenharmony_ci
7157e41f4b71Sopenharmony_ci**参数:**
7158e41f4b71Sopenharmony_ci
7159e41f4b71Sopenharmony_ci| 参数名   | 类型                                                    | 必填 | 说明                                                      |
7160e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------ |
7161e41f4b71Sopenharmony_ci| type     | string                                                  | 是   | 取消对应的监听事件,支持事件`'outputDeviceChange'`。      |
7162e41f4b71Sopenharmony_ci| callback | (state: [ConnectionState](#connectionstate10), device: [OutputDeviceInfo](#outputdeviceinfo10)) => void | 否   | 回调函数,参数device是设备相关信息。<br>该参数为可选参数,若不填写该参数,则认为取消所有相关会话的事件监听。                         |
7163e41f4b71Sopenharmony_ci
7164e41f4b71Sopenharmony_ci**错误码:**
7165e41f4b71Sopenharmony_ci
7166e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
7167e41f4b71Sopenharmony_ci
7168e41f4b71Sopenharmony_ci| 错误码ID  | 错误信息          |
7169e41f4b71Sopenharmony_ci| -------- | ---------------- |
7170e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
7171e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
7172e41f4b71Sopenharmony_ci| 6600103  | The session controller does not exist. |
7173e41f4b71Sopenharmony_ci
7174e41f4b71Sopenharmony_ci**示例:**
7175e41f4b71Sopenharmony_ci
7176e41f4b71Sopenharmony_ci```ts
7177e41f4b71Sopenharmony_ciavsessionController.off('outputDeviceChange');
7178e41f4b71Sopenharmony_ci```
7179e41f4b71Sopenharmony_ci
7180e41f4b71Sopenharmony_ci### on('sessionEvent')<sup>10+</sup>
7181e41f4b71Sopenharmony_ci
7182e41f4b71Sopenharmony_cion(type: 'sessionEvent', callback: (sessionEvent: string, args: {[key:string]: Object}) => void): void
7183e41f4b71Sopenharmony_ci
7184e41f4b71Sopenharmony_ci媒体控制器设置会话自定义事件变化的监听器。
7185e41f4b71Sopenharmony_ci
7186e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
7187e41f4b71Sopenharmony_ci
7188e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
7189e41f4b71Sopenharmony_ci
7190e41f4b71Sopenharmony_ci**参数:**
7191e41f4b71Sopenharmony_ci
7192e41f4b71Sopenharmony_ci| 参数名   | 类型                                                         | 必填 | 说明                                                         |
7193e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
7194e41f4b71Sopenharmony_ci| type     | string                                                       | 是   | 事件回调类型,支持事件`'sessionEvent'`:当会话事件变化时,触发该事件。 |
7195e41f4b71Sopenharmony_ci| callback | (sessionEvent: string, args: {[key:string]: object}) => void         | 是   | 回调函数,sessionEvent为变化的会话事件名,args为事件的参数。          |
7196e41f4b71Sopenharmony_ci
7197e41f4b71Sopenharmony_ci**错误码:**
7198e41f4b71Sopenharmony_ci
7199e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
7200e41f4b71Sopenharmony_ci
7201e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
7202e41f4b71Sopenharmony_ci| -------- | ------------------------------ |
7203e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
7204e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
7205e41f4b71Sopenharmony_ci| 6600103  | The session controller does not exist. |
7206e41f4b71Sopenharmony_ci
7207e41f4b71Sopenharmony_ci**示例:**
7208e41f4b71Sopenharmony_ci
7209e41f4b71Sopenharmony_ci```ts
7210e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
7211e41f4b71Sopenharmony_ci
7212e41f4b71Sopenharmony_cilet avSessionController: avSession.AVSessionController | undefined = undefined;
7213e41f4b71Sopenharmony_cilet currentAVSession: avSession.AVSession | undefined = undefined;
7214e41f4b71Sopenharmony_cilet tag = "createNewSession";
7215e41f4b71Sopenharmony_cilet context: Context = getContext(this);
7216e41f4b71Sopenharmony_ci
7217e41f4b71Sopenharmony_ciavSession.createAVSession(context, tag, "audio", (err: BusinessError, data: avSession.AVSession) => {
7218e41f4b71Sopenharmony_ci  if (err) {
7219e41f4b71Sopenharmony_ci    console.error(`CreateAVSession BusinessError: code: ${err.code}, message: ${err.message}`);
7220e41f4b71Sopenharmony_ci  } else {
7221e41f4b71Sopenharmony_ci    currentAVSession = data;
7222e41f4b71Sopenharmony_ci  }
7223e41f4b71Sopenharmony_ci});
7224e41f4b71Sopenharmony_ciif (currentAVSession !== undefined) {
7225e41f4b71Sopenharmony_ci  avSession.createController((currentAVSession as avSession.AVSession).sessionId).then((controller: avSession.AVSessionController) => {
7226e41f4b71Sopenharmony_ci    avSessionController = controller;
7227e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
7228e41f4b71Sopenharmony_ci    console.error(`CreateController BusinessError: code: ${err.code}, message: ${err.message}`);
7229e41f4b71Sopenharmony_ci  });
7230e41f4b71Sopenharmony_ci}
7231e41f4b71Sopenharmony_ci
7232e41f4b71Sopenharmony_ciif (avSessionController !== undefined) {
7233e41f4b71Sopenharmony_ci  (avSessionController as avSession.AVSessionController).on('sessionEvent', (sessionEvent, args) => {
7234e41f4b71Sopenharmony_ci    console.info(`OnSessionEvent, sessionEvent is ${sessionEvent}, args: ${JSON.stringify(args)}`);
7235e41f4b71Sopenharmony_ci  });
7236e41f4b71Sopenharmony_ci}
7237e41f4b71Sopenharmony_ci```
7238e41f4b71Sopenharmony_ci
7239e41f4b71Sopenharmony_ci### off('sessionEvent')<sup>10+</sup>
7240e41f4b71Sopenharmony_ci
7241e41f4b71Sopenharmony_cioff(type: 'sessionEvent', callback?: (sessionEvent: string, args: {[key:string]: Object}) => void): void
7242e41f4b71Sopenharmony_ci
7243e41f4b71Sopenharmony_ci媒体控制器取消监听会话事件的变化通知。
7244e41f4b71Sopenharmony_ci
7245e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
7246e41f4b71Sopenharmony_ci
7247e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
7248e41f4b71Sopenharmony_ci
7249e41f4b71Sopenharmony_ci**参数:**
7250e41f4b71Sopenharmony_ci
7251e41f4b71Sopenharmony_ci| 参数名   | 类型                                                         | 必填 | 说明                                                     |
7252e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | ---- | ----------------------------------------------------- |
7253e41f4b71Sopenharmony_ci| type     | string                                                       | 是   | 取消对应的监听事件,支持事件`'sessionEvent'`。    |
7254e41f4b71Sopenharmony_ci| callback | (sessionEvent: string, args: {[key:string]: Object}) => void         | 否   | 回调函数,参数sessionEvent是变化的事件名,args为事件的参数。<br>该参数为可选参数,若不填写该参数,则认为取消所有对sessionEvent事件的监听。                      |
7255e41f4b71Sopenharmony_ci
7256e41f4b71Sopenharmony_ci**错误码:**
7257e41f4b71Sopenharmony_ci
7258e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
7259e41f4b71Sopenharmony_ci
7260e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
7261e41f4b71Sopenharmony_ci| -------- | ---------------- |
7262e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
7263e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
7264e41f4b71Sopenharmony_ci| 6600103  | The session controller does not exist. |
7265e41f4b71Sopenharmony_ci
7266e41f4b71Sopenharmony_ci**示例:**
7267e41f4b71Sopenharmony_ci
7268e41f4b71Sopenharmony_ci```ts
7269e41f4b71Sopenharmony_ciavsessionController.off('sessionEvent');
7270e41f4b71Sopenharmony_ci```
7271e41f4b71Sopenharmony_ci
7272e41f4b71Sopenharmony_ci### on('queueItemsChange')<sup>10+</sup>
7273e41f4b71Sopenharmony_ci
7274e41f4b71Sopenharmony_cion(type: 'queueItemsChange', callback: (items: Array<[AVQueueItem](#avqueueitem10)\>) => void): void
7275e41f4b71Sopenharmony_ci
7276e41f4b71Sopenharmony_ci媒体控制器设置会话自定义播放列表变化的监听器。
7277e41f4b71Sopenharmony_ci
7278e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
7279e41f4b71Sopenharmony_ci
7280e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
7281e41f4b71Sopenharmony_ci
7282e41f4b71Sopenharmony_ci**参数:**
7283e41f4b71Sopenharmony_ci
7284e41f4b71Sopenharmony_ci| 参数名   | 类型                                                   | 必填 | 说明                                                                         |
7285e41f4b71Sopenharmony_ci| -------- | ----------------------------------------------------- | ---- | ---------------------------------------------------------------------------- |
7286e41f4b71Sopenharmony_ci| type     | string                                                | 是   | 事件回调类型,支持事件`'queueItemsChange'`:当session修改播放列表时,触发该事件。 |
7287e41f4b71Sopenharmony_ci| callback | (items: Array<[AVQueueItem](#avqueueitem10)\>) => void  | 是   | 回调函数,items为变化的播放列表。                            |
7288e41f4b71Sopenharmony_ci
7289e41f4b71Sopenharmony_ci**错误码:**
7290e41f4b71Sopenharmony_ci
7291e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
7292e41f4b71Sopenharmony_ci
7293e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
7294e41f4b71Sopenharmony_ci| -------- | ------------------------------ |
7295e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
7296e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
7297e41f4b71Sopenharmony_ci| 6600103  | The session controller does not exist. |
7298e41f4b71Sopenharmony_ci
7299e41f4b71Sopenharmony_ci**示例:**
7300e41f4b71Sopenharmony_ci
7301e41f4b71Sopenharmony_ci```ts
7302e41f4b71Sopenharmony_ciavsessionController.on('queueItemsChange', (items: avSession.AVQueueItem[]) => {
7303e41f4b71Sopenharmony_ci  console.info(`OnQueueItemsChange, items length is ${items.length}`);
7304e41f4b71Sopenharmony_ci});
7305e41f4b71Sopenharmony_ci```
7306e41f4b71Sopenharmony_ci
7307e41f4b71Sopenharmony_ci### off('queueItemsChange')<sup>10+</sup>
7308e41f4b71Sopenharmony_ci
7309e41f4b71Sopenharmony_cioff(type: 'queueItemsChange', callback?: (items: Array<[AVQueueItem](#avqueueitem10)\>) => void): void
7310e41f4b71Sopenharmony_ci
7311e41f4b71Sopenharmony_ci媒体控制器取消监听播放列表变化的事件。
7312e41f4b71Sopenharmony_ci
7313e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
7314e41f4b71Sopenharmony_ci
7315e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
7316e41f4b71Sopenharmony_ci
7317e41f4b71Sopenharmony_ci**参数:**
7318e41f4b71Sopenharmony_ci
7319e41f4b71Sopenharmony_ci| 参数名    | 类型                                                 | 必填 | 说明                                                                                                |
7320e41f4b71Sopenharmony_ci| -------- | ---------------------------------------------------- | ---- | --------------------------------------------------------------------------------------------------- |
7321e41f4b71Sopenharmony_ci| type     | string                                               | 是   | 取消对应的监听事件,支持事件`'queueItemsChange'`。                                                     |
7322e41f4b71Sopenharmony_ci| callback | (items: Array<[AVQueueItem](#avqueueitem10)\>) => void | 否   | 回调函数,参数items是变化的播放列表。<br>该参数为可选参数,若不填写该参数,则认为取消所有相关会话的事件监听。 |
7323e41f4b71Sopenharmony_ci
7324e41f4b71Sopenharmony_ci**错误码:**
7325e41f4b71Sopenharmony_ci
7326e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
7327e41f4b71Sopenharmony_ci
7328e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
7329e41f4b71Sopenharmony_ci| -------- | ---------------- |
7330e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
7331e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
7332e41f4b71Sopenharmony_ci| 6600103  | The session controller does not exist. |
7333e41f4b71Sopenharmony_ci
7334e41f4b71Sopenharmony_ci**示例:**
7335e41f4b71Sopenharmony_ci
7336e41f4b71Sopenharmony_ci```ts
7337e41f4b71Sopenharmony_ciavsessionController.off('queueItemsChange');
7338e41f4b71Sopenharmony_ci```
7339e41f4b71Sopenharmony_ci
7340e41f4b71Sopenharmony_ci### on('queueTitleChange')<sup>10+</sup>
7341e41f4b71Sopenharmony_ci
7342e41f4b71Sopenharmony_cion(type: 'queueTitleChange', callback: (title: string) => void): void
7343e41f4b71Sopenharmony_ci
7344e41f4b71Sopenharmony_ci媒体控制器设置会话自定义播放列表的名称变化的监听器。
7345e41f4b71Sopenharmony_ci
7346e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
7347e41f4b71Sopenharmony_ci
7348e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
7349e41f4b71Sopenharmony_ci
7350e41f4b71Sopenharmony_ci**参数:**
7351e41f4b71Sopenharmony_ci
7352e41f4b71Sopenharmony_ci| 参数名   | 类型                     | 必填 | 说明                                                                             |
7353e41f4b71Sopenharmony_ci| -------- | ----------------------- | ---- | ------------------------------------------------------------------------------- |
7354e41f4b71Sopenharmony_ci| type     | string                  | 是   | 事件回调类型,支持事件`'queueTitleChange'`:当session修改播放列表名称时,触发该事件。 |
7355e41f4b71Sopenharmony_ci| callback | (title: string) => void | 是   | 回调函数,title为变化的播放列表名称。                                |
7356e41f4b71Sopenharmony_ci
7357e41f4b71Sopenharmony_ci**错误码:**
7358e41f4b71Sopenharmony_ci
7359e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
7360e41f4b71Sopenharmony_ci
7361e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
7362e41f4b71Sopenharmony_ci| -------- | ------------------------------ |
7363e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
7364e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
7365e41f4b71Sopenharmony_ci| 6600103  | The session controller does not exist. |
7366e41f4b71Sopenharmony_ci
7367e41f4b71Sopenharmony_ci**示例:**
7368e41f4b71Sopenharmony_ci
7369e41f4b71Sopenharmony_ci```ts
7370e41f4b71Sopenharmony_ciavsessionController.on('queueTitleChange', (title: string) => {
7371e41f4b71Sopenharmony_ci  console.info(`queueTitleChange, title is ${title}`);
7372e41f4b71Sopenharmony_ci});
7373e41f4b71Sopenharmony_ci```
7374e41f4b71Sopenharmony_ci
7375e41f4b71Sopenharmony_ci### off('queueTitleChange')<sup>10+</sup>
7376e41f4b71Sopenharmony_ci
7377e41f4b71Sopenharmony_cioff(type: 'queueTitleChange', callback?: (title: string) => void): void
7378e41f4b71Sopenharmony_ci
7379e41f4b71Sopenharmony_ci媒体控制器取消监听播放列表名称变化的事件。
7380e41f4b71Sopenharmony_ci
7381e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
7382e41f4b71Sopenharmony_ci
7383e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
7384e41f4b71Sopenharmony_ci
7385e41f4b71Sopenharmony_ci**参数:**
7386e41f4b71Sopenharmony_ci
7387e41f4b71Sopenharmony_ci| 参数名    | 类型                    | 必填 | 说明                                                                                                    |
7388e41f4b71Sopenharmony_ci| -------- | ----------------------- | ---- | ------------------------------------------------------------------------------------------------------- |
7389e41f4b71Sopenharmony_ci| type     | string                  | 是   | 取消对应的监听事件,支持事件`'queueTitleChange'`。                                                         |
7390e41f4b71Sopenharmony_ci| callback | (title: string) => void | 否   | 回调函数,参数items是变化的播放列表名称。<br>该参数为可选参数,若不填写该参数,则认为取消所有相关会话的事件监听。 |
7391e41f4b71Sopenharmony_ci
7392e41f4b71Sopenharmony_ci**错误码:**
7393e41f4b71Sopenharmony_ci
7394e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
7395e41f4b71Sopenharmony_ci
7396e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
7397e41f4b71Sopenharmony_ci| -------- | ---------------- |
7398e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
7399e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
7400e41f4b71Sopenharmony_ci| 6600103  | The session controller does not exist. |
7401e41f4b71Sopenharmony_ci
7402e41f4b71Sopenharmony_ci**示例:**
7403e41f4b71Sopenharmony_ci
7404e41f4b71Sopenharmony_ci```ts
7405e41f4b71Sopenharmony_ciavsessionController.off('queueTitleChange');
7406e41f4b71Sopenharmony_ci```
7407e41f4b71Sopenharmony_ci
7408e41f4b71Sopenharmony_ci### on('extrasChange')<sup>10+</sup>
7409e41f4b71Sopenharmony_ci
7410e41f4b71Sopenharmony_cion(type: 'extrasChange', callback: (extras: {[key:string]: Object}) => void): void
7411e41f4b71Sopenharmony_ci
7412e41f4b71Sopenharmony_ci媒体控制器设置自定义媒体数据包事件变化的监听器。
7413e41f4b71Sopenharmony_ci
7414e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
7415e41f4b71Sopenharmony_ci
7416e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
7417e41f4b71Sopenharmony_ci
7418e41f4b71Sopenharmony_ci**参数:**
7419e41f4b71Sopenharmony_ci
7420e41f4b71Sopenharmony_ci| 参数名   | 类型                                                         | 必填 | 说明                                                         |
7421e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
7422e41f4b71Sopenharmony_ci| type     | string                                                       | 是   | 事件回调类型,支持事件`'extrasChange'`:当媒体提供方设置自定义媒体数据包时,触发该事件。 |
7423e41f4b71Sopenharmony_ci| callback | (extras: {[key:string]: object}) => void         | 是   | 回调函数,extras为媒体提供方新设置的自定义媒体数据包,该自定义媒体数据包与dispatchSessionEvent方法设置的数据包完全一致。          |
7424e41f4b71Sopenharmony_ci
7425e41f4b71Sopenharmony_ci**错误码:**
7426e41f4b71Sopenharmony_ci
7427e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
7428e41f4b71Sopenharmony_ci
7429e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
7430e41f4b71Sopenharmony_ci| -------- | ------------------------------ |
7431e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
7432e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
7433e41f4b71Sopenharmony_ci| 6600103  | The session controller does not exist. |
7434e41f4b71Sopenharmony_ci
7435e41f4b71Sopenharmony_ci**示例:**
7436e41f4b71Sopenharmony_ci
7437e41f4b71Sopenharmony_ci```ts
7438e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
7439e41f4b71Sopenharmony_ci
7440e41f4b71Sopenharmony_cilet avSessionController: avSession.AVSessionController | undefined = undefined;
7441e41f4b71Sopenharmony_cilet currentAVSession: avSession.AVSession | undefined = undefined;
7442e41f4b71Sopenharmony_cilet tag = "createNewSession";
7443e41f4b71Sopenharmony_cilet context: Context = getContext(this);
7444e41f4b71Sopenharmony_ci
7445e41f4b71Sopenharmony_ciavSession.createAVSession(context, tag, "audio", (err: BusinessError, data: avSession.AVSession) => {
7446e41f4b71Sopenharmony_ci  if (err) {
7447e41f4b71Sopenharmony_ci    console.error(`CreateAVSession BusinessError: code: ${err.code}, message: ${err.message}`);
7448e41f4b71Sopenharmony_ci  } else {
7449e41f4b71Sopenharmony_ci    currentAVSession = data;
7450e41f4b71Sopenharmony_ci  }
7451e41f4b71Sopenharmony_ci});
7452e41f4b71Sopenharmony_ciif (currentAVSession !== undefined) {
7453e41f4b71Sopenharmony_ci  avSession.createController((currentAVSession as avSession.AVSession).sessionId).then((controller: avSession.AVSessionController) => {
7454e41f4b71Sopenharmony_ci    avSessionController = controller;
7455e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
7456e41f4b71Sopenharmony_ci    console.error(`CreateController BusinessError: code: ${err.code}, message: ${err.message}`);
7457e41f4b71Sopenharmony_ci  });
7458e41f4b71Sopenharmony_ci}
7459e41f4b71Sopenharmony_ci
7460e41f4b71Sopenharmony_ciif (avSessionController !== undefined) {
7461e41f4b71Sopenharmony_ci  (avSessionController as avSession.AVSessionController).on('extrasChange', (extras) => {
7462e41f4b71Sopenharmony_ci    console.info(`Caught extrasChange event,the new extra is: ${JSON.stringify(extras)}`);
7463e41f4b71Sopenharmony_ci  });
7464e41f4b71Sopenharmony_ci}
7465e41f4b71Sopenharmony_ci```
7466e41f4b71Sopenharmony_ci
7467e41f4b71Sopenharmony_ci### off('extrasChange')<sup>10+</sup>
7468e41f4b71Sopenharmony_ci
7469e41f4b71Sopenharmony_cioff(type: 'extrasChange', callback?: (extras: {[key:string]: Object}) => void): void
7470e41f4b71Sopenharmony_ci
7471e41f4b71Sopenharmony_ci媒体控制器取消监听自定义媒体数据包变化事件。
7472e41f4b71Sopenharmony_ci
7473e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
7474e41f4b71Sopenharmony_ci
7475e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
7476e41f4b71Sopenharmony_ci
7477e41f4b71Sopenharmony_ci**参数:**
7478e41f4b71Sopenharmony_ci
7479e41f4b71Sopenharmony_ci| 参数名    | 类型                    | 必填 | 说明                                                                                                    |
7480e41f4b71Sopenharmony_ci| -------- | ----------------------- | ---- | ------------------------------------------------------------------------------------------------------- |
7481e41f4b71Sopenharmony_ci| type     | string                  | 是   | 取消对应的监听事件,支持事件`'extrasChange'`。                                                         |
7482e41f4b71Sopenharmony_ci| callback | ({[key:string]: Object}) => void | 否   | 注册监听事件时的回调函数。<br>该参数为可选参数,若不填写该参数,则认为取消会话所有与此事件相关的监听。 |
7483e41f4b71Sopenharmony_ci
7484e41f4b71Sopenharmony_ci**错误码:**
7485e41f4b71Sopenharmony_ci
7486e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
7487e41f4b71Sopenharmony_ci
7488e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
7489e41f4b71Sopenharmony_ci| -------- | ----------------                       |
7490e41f4b71Sopenharmony_ci| 401 |  parameter check failed. 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. |
7491e41f4b71Sopenharmony_ci| 6600101  | Session service exception.             |
7492e41f4b71Sopenharmony_ci| 6600103  | The session controller does not exist. |
7493e41f4b71Sopenharmony_ci
7494e41f4b71Sopenharmony_ci**示例:**
7495e41f4b71Sopenharmony_ci
7496e41f4b71Sopenharmony_ci```ts
7497e41f4b71Sopenharmony_ciavsessionController.off('extrasChange');
7498e41f4b71Sopenharmony_ci```
7499e41f4b71Sopenharmony_ci
7500e41f4b71Sopenharmony_ci### getAVPlaybackStateSync<sup>10+</sup>
7501e41f4b71Sopenharmony_ci
7502e41f4b71Sopenharmony_cigetAVPlaybackStateSync(): AVPlaybackState;
7503e41f4b71Sopenharmony_ci
7504e41f4b71Sopenharmony_ci使用同步方法获取当前会话的播放状态。
7505e41f4b71Sopenharmony_ci
7506e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
7507e41f4b71Sopenharmony_ci
7508e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
7509e41f4b71Sopenharmony_ci
7510e41f4b71Sopenharmony_ci**返回值:**
7511e41f4b71Sopenharmony_ci
7512e41f4b71Sopenharmony_ci| 类型                                                        | 说明                                                         |
7513e41f4b71Sopenharmony_ci| --------- | ------------------------------------------------------------ |
7514e41f4b71Sopenharmony_ci| [AVPlaybackState](#avplaybackstate10)  | 当前会话的播放状态。 |
7515e41f4b71Sopenharmony_ci
7516e41f4b71Sopenharmony_ci**错误码:**
7517e41f4b71Sopenharmony_ci
7518e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
7519e41f4b71Sopenharmony_ci
7520e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
7521e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
7522e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
7523e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
7524e41f4b71Sopenharmony_ci| 6600103  | The session controller does not exist. |
7525e41f4b71Sopenharmony_ci
7526e41f4b71Sopenharmony_ci**示例:**
7527e41f4b71Sopenharmony_ci
7528e41f4b71Sopenharmony_ci```ts
7529e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
7530e41f4b71Sopenharmony_ci
7531e41f4b71Sopenharmony_citry {
7532e41f4b71Sopenharmony_ci  let playbackState: avSession.AVPlaybackState = avsessionController.getAVPlaybackStateSync();
7533e41f4b71Sopenharmony_ci} catch (err) {
7534e41f4b71Sopenharmony_ci  let error = err as BusinessError;
7535e41f4b71Sopenharmony_ci  console.info(`getAVPlaybackStateSync error, error code: ${error.code}, error message: ${error.message}`);
7536e41f4b71Sopenharmony_ci}
7537e41f4b71Sopenharmony_ci```
7538e41f4b71Sopenharmony_ci
7539e41f4b71Sopenharmony_ci### getAVMetadataSync<sup>10+</sup>
7540e41f4b71Sopenharmony_ci
7541e41f4b71Sopenharmony_cigetAVMetadataSync(): AVMetadata
7542e41f4b71Sopenharmony_ci
7543e41f4b71Sopenharmony_ci使用同步方法获取会话元数据。
7544e41f4b71Sopenharmony_ci
7545e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
7546e41f4b71Sopenharmony_ci
7547e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
7548e41f4b71Sopenharmony_ci
7549e41f4b71Sopenharmony_ci**返回值:**
7550e41f4b71Sopenharmony_ci
7551e41f4b71Sopenharmony_ci| 类型                                | 说明                          |
7552e41f4b71Sopenharmony_ci| ----------------------------------- | ----------------------------- |
7553e41f4b71Sopenharmony_ci| [AVMetadata](#avmetadata10) | 会话元数据。 |
7554e41f4b71Sopenharmony_ci
7555e41f4b71Sopenharmony_ci**错误码:**
7556e41f4b71Sopenharmony_ci
7557e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
7558e41f4b71Sopenharmony_ci
7559e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
7560e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
7561e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
7562e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
7563e41f4b71Sopenharmony_ci| 6600103  | The session controller does not exist. |
7564e41f4b71Sopenharmony_ci
7565e41f4b71Sopenharmony_ci**示例:**
7566e41f4b71Sopenharmony_ci```ts
7567e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
7568e41f4b71Sopenharmony_ci
7569e41f4b71Sopenharmony_citry {
7570e41f4b71Sopenharmony_ci  let metaData: avSession.AVMetadata = avsessionController.getAVMetadataSync();
7571e41f4b71Sopenharmony_ci} catch (err) {
7572e41f4b71Sopenharmony_ci  let error = err as BusinessError;
7573e41f4b71Sopenharmony_ci  console.info(`getAVMetadataSync error, error code: ${error.code}, error message: ${error.message}`);
7574e41f4b71Sopenharmony_ci}
7575e41f4b71Sopenharmony_ci```
7576e41f4b71Sopenharmony_ci
7577e41f4b71Sopenharmony_ci### getAVCallState<sup>11+</sup>
7578e41f4b71Sopenharmony_ci
7579e41f4b71Sopenharmony_cigetAVCallState(): Promise\<AVCallState>
7580e41f4b71Sopenharmony_ci
7581e41f4b71Sopenharmony_ci获取通话状态数据。结果通过Promise异步回调方式返回。
7582e41f4b71Sopenharmony_ci
7583e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
7584e41f4b71Sopenharmony_ci
7585e41f4b71Sopenharmony_ci**返回值:**
7586e41f4b71Sopenharmony_ci
7587e41f4b71Sopenharmony_ci| 类型                                | 说明                          |
7588e41f4b71Sopenharmony_ci| ----------------------------------- | ----------------------------- |
7589e41f4b71Sopenharmony_ci| Promise<[AVCallState](#avcallstate11)\> | Promise对象,返回通话状态。 |
7590e41f4b71Sopenharmony_ci
7591e41f4b71Sopenharmony_ci**错误码:**
7592e41f4b71Sopenharmony_ci
7593e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
7594e41f4b71Sopenharmony_ci
7595e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
7596e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
7597e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
7598e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
7599e41f4b71Sopenharmony_ci| 6600103  | The session controller does not exist. |
7600e41f4b71Sopenharmony_ci
7601e41f4b71Sopenharmony_ci**示例:**
7602e41f4b71Sopenharmony_ci
7603e41f4b71Sopenharmony_ci```ts
7604e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
7605e41f4b71Sopenharmony_ci
7606e41f4b71Sopenharmony_ciavsessionController.getAVCallState().then((callstate: avSession.AVCallState) => {
7607e41f4b71Sopenharmony_ci  console.info(`getAVCallState : SUCCESS : state : ${callstate.state}`);
7608e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
7609e41f4b71Sopenharmony_ci  console.error(`getAVCallState BusinessError: code: ${err.code}, message: ${err.message}`);
7610e41f4b71Sopenharmony_ci});
7611e41f4b71Sopenharmony_ci```
7612e41f4b71Sopenharmony_ci
7613e41f4b71Sopenharmony_ci### getAVCallState<sup>11+</sup>
7614e41f4b71Sopenharmony_ci
7615e41f4b71Sopenharmony_cigetAVCallState(callback: AsyncCallback\<AVCallState>): void
7616e41f4b71Sopenharmony_ci
7617e41f4b71Sopenharmony_ci获取通话状态数据。结果通过callback异步回调方式返回。
7618e41f4b71Sopenharmony_ci
7619e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
7620e41f4b71Sopenharmony_ci
7621e41f4b71Sopenharmony_ci**参数:**
7622e41f4b71Sopenharmony_ci
7623e41f4b71Sopenharmony_ci| 参数名   | 类型                                      | 必填 | 说明                       |
7624e41f4b71Sopenharmony_ci| -------- | ----------------------------------------- | ---- | -------------------------- |
7625e41f4b71Sopenharmony_ci| callback | AsyncCallback<[AVCallState](#avcallstate11)\> | 是   | 回调函数,返回通话状态。 |
7626e41f4b71Sopenharmony_ci
7627e41f4b71Sopenharmony_ci**错误码:**
7628e41f4b71Sopenharmony_ci
7629e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
7630e41f4b71Sopenharmony_ci
7631e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
7632e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
7633e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
7634e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
7635e41f4b71Sopenharmony_ci| 6600103  | The session controller does not exist. |
7636e41f4b71Sopenharmony_ci
7637e41f4b71Sopenharmony_ci**示例:**
7638e41f4b71Sopenharmony_ci
7639e41f4b71Sopenharmony_ci```ts
7640e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
7641e41f4b71Sopenharmony_ci
7642e41f4b71Sopenharmony_ciavsessionController.getAVCallState((err: BusinessError, callstate: avSession.AVCallState) => {
7643e41f4b71Sopenharmony_ci  if (err) {
7644e41f4b71Sopenharmony_ci    console.error(`getAVCallState BusinessError: code: ${err.code}, message: ${err.message}`);
7645e41f4b71Sopenharmony_ci  } else {
7646e41f4b71Sopenharmony_ci    console.info(`getAVCallState : SUCCESS : state : ${callstate.state}`);
7647e41f4b71Sopenharmony_ci  }
7648e41f4b71Sopenharmony_ci});
7649e41f4b71Sopenharmony_ci```
7650e41f4b71Sopenharmony_ci
7651e41f4b71Sopenharmony_ci### getCallMetadata<sup>11+</sup>
7652e41f4b71Sopenharmony_ci
7653e41f4b71Sopenharmony_cigetCallMetadata(): Promise\<CallMetadata>
7654e41f4b71Sopenharmony_ci
7655e41f4b71Sopenharmony_ci获取通话会话的元数据。结果通过Promise异步回调方式返回。
7656e41f4b71Sopenharmony_ci
7657e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
7658e41f4b71Sopenharmony_ci
7659e41f4b71Sopenharmony_ci**返回值:**
7660e41f4b71Sopenharmony_ci
7661e41f4b71Sopenharmony_ci| 类型                                | 说明                          |
7662e41f4b71Sopenharmony_ci| ----------------------------------- | ----------------------------- |
7663e41f4b71Sopenharmony_ci| Promise<[CallMetadata](#callmetadata11)\> | Promise对象,返回会话元数据。 |
7664e41f4b71Sopenharmony_ci
7665e41f4b71Sopenharmony_ci**错误码:**
7666e41f4b71Sopenharmony_ci
7667e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
7668e41f4b71Sopenharmony_ci
7669e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
7670e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
7671e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
7672e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
7673e41f4b71Sopenharmony_ci| 6600103  | The session controller does not exist. |
7674e41f4b71Sopenharmony_ci
7675e41f4b71Sopenharmony_ci**示例:**
7676e41f4b71Sopenharmony_ci
7677e41f4b71Sopenharmony_ci```ts
7678e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
7679e41f4b71Sopenharmony_ci
7680e41f4b71Sopenharmony_ciavsessionController.getCallMetadata().then((calldata: avSession.CallMetadata) => {
7681e41f4b71Sopenharmony_ci  console.info(`getCallMetadata : SUCCESS : name : ${calldata.name}`);
7682e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
7683e41f4b71Sopenharmony_ci  console.error(`getCallMetadata BusinessError: code: ${err.code}, message: ${err.message}`);
7684e41f4b71Sopenharmony_ci});
7685e41f4b71Sopenharmony_ci```
7686e41f4b71Sopenharmony_ci
7687e41f4b71Sopenharmony_ci### getCallMetadata<sup>11+</sup>
7688e41f4b71Sopenharmony_ci
7689e41f4b71Sopenharmony_cigetCallMetadata(callback: AsyncCallback\<CallMetadata>): void
7690e41f4b71Sopenharmony_ci
7691e41f4b71Sopenharmony_ci获取通话会话的元数据。结果通过callback异步回调方式返回。
7692e41f4b71Sopenharmony_ci
7693e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
7694e41f4b71Sopenharmony_ci
7695e41f4b71Sopenharmony_ci**参数:**
7696e41f4b71Sopenharmony_ci
7697e41f4b71Sopenharmony_ci| 参数名   | 类型                                      | 必填 | 说明                       |
7698e41f4b71Sopenharmony_ci| -------- | ----------------------------------------- | ---- | -------------------------- |
7699e41f4b71Sopenharmony_ci| callback | AsyncCallback<[CallMetadata](#callmetadata11)\> | 是   | 回调函数,返回会话元数据。 |
7700e41f4b71Sopenharmony_ci
7701e41f4b71Sopenharmony_ci**错误码:**
7702e41f4b71Sopenharmony_ci
7703e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
7704e41f4b71Sopenharmony_ci
7705e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
7706e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
7707e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
7708e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
7709e41f4b71Sopenharmony_ci| 6600103  | The session controller does not exist. |
7710e41f4b71Sopenharmony_ci
7711e41f4b71Sopenharmony_ci**示例:**
7712e41f4b71Sopenharmony_ci
7713e41f4b71Sopenharmony_ci```ts
7714e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
7715e41f4b71Sopenharmony_ci
7716e41f4b71Sopenharmony_ciavsessionController.getCallMetadata((err: BusinessError, calldata: avSession.CallMetadata) => {
7717e41f4b71Sopenharmony_ci  if (err) {
7718e41f4b71Sopenharmony_ci    console.error(`getCallMetadata BusinessError: code: ${err.code}, message: ${err.message}`);
7719e41f4b71Sopenharmony_ci  } else {
7720e41f4b71Sopenharmony_ci    console.info(`getCallMetadata : SUCCESS : name : ${calldata.name}`);
7721e41f4b71Sopenharmony_ci  }
7722e41f4b71Sopenharmony_ci});
7723e41f4b71Sopenharmony_ci```
7724e41f4b71Sopenharmony_ci
7725e41f4b71Sopenharmony_ci### getAVQueueTitleSync<sup>10+</sup>
7726e41f4b71Sopenharmony_ci
7727e41f4b71Sopenharmony_cigetAVQueueTitleSync(): string
7728e41f4b71Sopenharmony_ci
7729e41f4b71Sopenharmony_ci使用同步方法获取当前会话播放列表的名称。
7730e41f4b71Sopenharmony_ci
7731e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
7732e41f4b71Sopenharmony_ci
7733e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
7734e41f4b71Sopenharmony_ci
7735e41f4b71Sopenharmony_ci**返回值:**
7736e41f4b71Sopenharmony_ci
7737e41f4b71Sopenharmony_ci| 类型             | 说明                           |
7738e41f4b71Sopenharmony_ci| ---------------- | ----------------------------- |
7739e41f4b71Sopenharmony_ci| string | 当前会话播放列表名称。 |
7740e41f4b71Sopenharmony_ci
7741e41f4b71Sopenharmony_ci**错误码:**
7742e41f4b71Sopenharmony_ci
7743e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
7744e41f4b71Sopenharmony_ci
7745e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
7746e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
7747e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
7748e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
7749e41f4b71Sopenharmony_ci| 6600103  | The session controller does not exist. |
7750e41f4b71Sopenharmony_ci
7751e41f4b71Sopenharmony_ci**示例:**
7752e41f4b71Sopenharmony_ci
7753e41f4b71Sopenharmony_ci```ts
7754e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
7755e41f4b71Sopenharmony_ci
7756e41f4b71Sopenharmony_citry {
7757e41f4b71Sopenharmony_ci  let currentQueueTitle: string = avsessionController.getAVQueueTitleSync();
7758e41f4b71Sopenharmony_ci} catch (err) {
7759e41f4b71Sopenharmony_ci  let error = err as BusinessError;
7760e41f4b71Sopenharmony_ci  console.error(`getAVQueueTitleSync error, error code: ${error.code}, error message: ${error.message}`);
7761e41f4b71Sopenharmony_ci}
7762e41f4b71Sopenharmony_ci```
7763e41f4b71Sopenharmony_ci
7764e41f4b71Sopenharmony_ci### getAVQueueItemsSync<sup>10+</sup>
7765e41f4b71Sopenharmony_ci
7766e41f4b71Sopenharmony_cigetAVQueueItemsSync(): Array\<AVQueueItem\>
7767e41f4b71Sopenharmony_ci
7768e41f4b71Sopenharmony_ci使用同步方法获取当前会话播放列表相关信息。
7769e41f4b71Sopenharmony_ci
7770e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
7771e41f4b71Sopenharmony_ci
7772e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
7773e41f4b71Sopenharmony_ci
7774e41f4b71Sopenharmony_ci**返回值:**
7775e41f4b71Sopenharmony_ci
7776e41f4b71Sopenharmony_ci| 类型                                          | 说明                           |
7777e41f4b71Sopenharmony_ci| --------------------------------------------- | ----------------------------- |
7778e41f4b71Sopenharmony_ci| Array<[AVQueueItem](#avqueueitem10)\> | 当前会话播放列表队列。 |
7779e41f4b71Sopenharmony_ci
7780e41f4b71Sopenharmony_ci**错误码:**
7781e41f4b71Sopenharmony_ci
7782e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
7783e41f4b71Sopenharmony_ci
7784e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
7785e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
7786e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
7787e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
7788e41f4b71Sopenharmony_ci| 6600103  | The session controller does not exist. |
7789e41f4b71Sopenharmony_ci
7790e41f4b71Sopenharmony_ci**示例:**
7791e41f4b71Sopenharmony_ci
7792e41f4b71Sopenharmony_ci```ts
7793e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
7794e41f4b71Sopenharmony_ci
7795e41f4b71Sopenharmony_citry {
7796e41f4b71Sopenharmony_ci  let currentQueueItems: Array<avSession.AVQueueItem> = avsessionController.getAVQueueItemsSync();
7797e41f4b71Sopenharmony_ci} catch (err) {
7798e41f4b71Sopenharmony_ci  let error = err as BusinessError;
7799e41f4b71Sopenharmony_ci  console.error(`getAVQueueItemsSync error, error code: ${error.code}, error message: ${error.message}`);
7800e41f4b71Sopenharmony_ci}
7801e41f4b71Sopenharmony_ci```
7802e41f4b71Sopenharmony_ci
7803e41f4b71Sopenharmony_ci### getOutputDeviceSync<sup>10+</sup>
7804e41f4b71Sopenharmony_ci
7805e41f4b71Sopenharmony_cigetOutputDeviceSync(): OutputDeviceInfo
7806e41f4b71Sopenharmony_ci
7807e41f4b71Sopenharmony_ci使用同步方法获取当前输出设备信息。
7808e41f4b71Sopenharmony_ci
7809e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
7810e41f4b71Sopenharmony_ci
7811e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
7812e41f4b71Sopenharmony_ci
7813e41f4b71Sopenharmony_ci**返回值:**
7814e41f4b71Sopenharmony_ci
7815e41f4b71Sopenharmony_ci| 类型                                            | 说明                              |
7816e41f4b71Sopenharmony_ci| ----------------------------------------------- | --------------------------------- |
7817e41f4b71Sopenharmony_ci| [OutputDeviceInfo](#outputdeviceinfo10) | 当前输出设备信息。 |
7818e41f4b71Sopenharmony_ci
7819e41f4b71Sopenharmony_ci**错误码:**
7820e41f4b71Sopenharmony_ci
7821e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
7822e41f4b71Sopenharmony_ci
7823e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
7824e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
7825e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
7826e41f4b71Sopenharmony_ci| 6600103  | The session controller does not exist. |
7827e41f4b71Sopenharmony_ci
7828e41f4b71Sopenharmony_ci**示例:**
7829e41f4b71Sopenharmony_ci
7830e41f4b71Sopenharmony_ci```ts
7831e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
7832e41f4b71Sopenharmony_ci
7833e41f4b71Sopenharmony_citry {
7834e41f4b71Sopenharmony_ci  let currentOutputDevice: avSession.OutputDeviceInfo = avsessionController.getOutputDeviceSync();
7835e41f4b71Sopenharmony_ci} catch (err) {
7836e41f4b71Sopenharmony_ci  let error = err as BusinessError;
7837e41f4b71Sopenharmony_ci  console.error(`getOutputDeviceSync error, error code: ${error.code}, error message: ${error.message}`);
7838e41f4b71Sopenharmony_ci}
7839e41f4b71Sopenharmony_ci```
7840e41f4b71Sopenharmony_ci
7841e41f4b71Sopenharmony_ci### isActiveSync<sup>10+</sup>
7842e41f4b71Sopenharmony_ci
7843e41f4b71Sopenharmony_ciisActiveSync(): boolean
7844e41f4b71Sopenharmony_ci
7845e41f4b71Sopenharmony_ci使用同步方法判断会话是否被激活。
7846e41f4b71Sopenharmony_ci
7847e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
7848e41f4b71Sopenharmony_ci
7849e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
7850e41f4b71Sopenharmony_ci
7851e41f4b71Sopenharmony_ci**返回值:**
7852e41f4b71Sopenharmony_ci
7853e41f4b71Sopenharmony_ci| 类型              | 说明                                                         |
7854e41f4b71Sopenharmony_ci| ----------------- | ------------------------------------------------------------ |
7855e41f4b71Sopenharmony_ci| boolean | 会话是否为激活状态,true表示被激活,false表示禁用。 |
7856e41f4b71Sopenharmony_ci
7857e41f4b71Sopenharmony_ci**错误码:**
7858e41f4b71Sopenharmony_ci
7859e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
7860e41f4b71Sopenharmony_ci
7861e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
7862e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
7863e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
7864e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
7865e41f4b71Sopenharmony_ci| 6600103  | The session controller does not exist. |
7866e41f4b71Sopenharmony_ci
7867e41f4b71Sopenharmony_ci**示例:**
7868e41f4b71Sopenharmony_ci
7869e41f4b71Sopenharmony_ci```ts
7870e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
7871e41f4b71Sopenharmony_ci
7872e41f4b71Sopenharmony_citry {
7873e41f4b71Sopenharmony_ci  let isActive: boolean = avsessionController.isActiveSync();
7874e41f4b71Sopenharmony_ci} catch (err) {
7875e41f4b71Sopenharmony_ci  let error = err as BusinessError;
7876e41f4b71Sopenharmony_ci  console.error(`isActiveSync error, error code: ${error.code}, error message: ${error.message}`);
7877e41f4b71Sopenharmony_ci}
7878e41f4b71Sopenharmony_ci```
7879e41f4b71Sopenharmony_ci
7880e41f4b71Sopenharmony_ci### getValidCommandsSync<sup>10+</sup>
7881e41f4b71Sopenharmony_ci
7882e41f4b71Sopenharmony_cigetValidCommandsSync(): Array\<AVControlCommandType\>
7883e41f4b71Sopenharmony_ci
7884e41f4b71Sopenharmony_ci使用同步方法获取会话支持的有效命令。
7885e41f4b71Sopenharmony_ci
7886e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
7887e41f4b71Sopenharmony_ci
7888e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
7889e41f4b71Sopenharmony_ci
7890e41f4b71Sopenharmony_ci**返回值:**
7891e41f4b71Sopenharmony_ci
7892e41f4b71Sopenharmony_ci| 类型                                                         | 说明                              |
7893e41f4b71Sopenharmony_ci| ------------------------------------------------------------ | --------------------------------- |
7894e41f4b71Sopenharmony_ci| Array<[AVControlCommandType](#avcontrolcommandtype10)\> | 会话支持的有效命令的集合。 |
7895e41f4b71Sopenharmony_ci
7896e41f4b71Sopenharmony_ci**错误码:**
7897e41f4b71Sopenharmony_ci
7898e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[媒体会话管理错误码](errorcode-avsession.md)。
7899e41f4b71Sopenharmony_ci
7900e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
7901e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- |
7902e41f4b71Sopenharmony_ci| 6600101  | Session service exception. |
7903e41f4b71Sopenharmony_ci| 6600102  | The session does not exist. |
7904e41f4b71Sopenharmony_ci| 6600103  | The session controller does not exist. |
7905e41f4b71Sopenharmony_ci
7906e41f4b71Sopenharmony_ci**示例:**
7907e41f4b71Sopenharmony_ci
7908e41f4b71Sopenharmony_ci```ts
7909e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
7910e41f4b71Sopenharmony_ci
7911e41f4b71Sopenharmony_citry {
7912e41f4b71Sopenharmony_ci  let validCommands: Array<avSession.AVControlCommandType> = avsessionController.getValidCommandsSync();
7913e41f4b71Sopenharmony_ci} catch (err) {
7914e41f4b71Sopenharmony_ci  let error = err as BusinessError;
7915e41f4b71Sopenharmony_ci  console.error(`getValidCommandsSync error, error code: ${error.code}, error message: ${error.message}`);
7916e41f4b71Sopenharmony_ci}
7917e41f4b71Sopenharmony_ci```
7918e41f4b71Sopenharmony_ci
7919e41f4b71Sopenharmony_ci## AVControlCommandType<sup>10+</sup>
7920e41f4b71Sopenharmony_ci
7921e41f4b71Sopenharmony_citype AVControlCommandType = 'play' | 'pause' | 'stop' | 'playNext' | 'playPrevious' | 'fastForward' | 'rewind' |
7922e41f4b71Sopenharmony_ci  'seek' | 'setSpeed' | 'setLoopMode' | 'toggleFavorite' | 'playFromAssetId' | 'answer' | 'hangUp' | 'toggleCallMute'
7923e41f4b71Sopenharmony_ci
7924e41f4b71Sopenharmony_ci会话可传递的命令。
7925e41f4b71Sopenharmony_ci
7926e41f4b71Sopenharmony_ci该类型可取的值为下表字符串的并集。
7927e41f4b71Sopenharmony_ci
7928e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
7929e41f4b71Sopenharmony_ci
7930e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
7931e41f4b71Sopenharmony_ci
7932e41f4b71Sopenharmony_ci| 类型             | 说明         |
7933e41f4b71Sopenharmony_ci| ---------------- | ------------ |
7934e41f4b71Sopenharmony_ci| 'play'           | 播放         |
7935e41f4b71Sopenharmony_ci| 'pause'          | 暂停         |
7936e41f4b71Sopenharmony_ci| 'stop'           | 停止         |
7937e41f4b71Sopenharmony_ci| 'playNext'       | 下一首       |
7938e41f4b71Sopenharmony_ci| 'playPrevious'   | 上一首       |
7939e41f4b71Sopenharmony_ci| 'fastForward'    | 快进         |
7940e41f4b71Sopenharmony_ci| 'rewind'         | 快退         |
7941e41f4b71Sopenharmony_ci| 'seek'           | 跳转某一节点 |
7942e41f4b71Sopenharmony_ci| 'setSpeed'       | 设置播放倍速 |
7943e41f4b71Sopenharmony_ci| 'setLoopMode'    | 设置循环模式 |
7944e41f4b71Sopenharmony_ci| 'toggleFavorite' | 是否收藏     |
7945e41f4b71Sopenharmony_ci| 'playFromAssetId'| 播放指定的assetid |
7946e41f4b71Sopenharmony_ci|'answer'          | 接听        |
7947e41f4b71Sopenharmony_ci| 'hangUp'         | 挂断        |
7948e41f4b71Sopenharmony_ci|'toggleCallMute'  | 设置通话静音状态 |
7949e41f4b71Sopenharmony_ci
7950e41f4b71Sopenharmony_ci## AVControlCommand<sup>10+</sup>
7951e41f4b71Sopenharmony_ci
7952e41f4b71Sopenharmony_ci会话接受的命令的对象描述。
7953e41f4b71Sopenharmony_ci
7954e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
7955e41f4b71Sopenharmony_ci
7956e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
7957e41f4b71Sopenharmony_ci
7958e41f4b71Sopenharmony_ci| 名称      | 类型                                              | 必填 | 说明           |
7959e41f4b71Sopenharmony_ci| --------- | ------------------------------------------------- | ---- | -------------- |
7960e41f4b71Sopenharmony_ci| command   | [AVControlCommandType](#avcontrolcommandtype10)     | 是   | 命令           |
7961e41f4b71Sopenharmony_ci| parameter | [LoopMode](#loopmode10) &#124; string &#124; number | 否   | 命令对应的参数 |
7962e41f4b71Sopenharmony_ci
7963e41f4b71Sopenharmony_ci## AVSessionErrorCode<sup>10+</sup>
7964e41f4b71Sopenharmony_ci
7965e41f4b71Sopenharmony_ci会话发生错误时的错误码。
7966e41f4b71Sopenharmony_ci
7967e41f4b71Sopenharmony_ci| 名称                                   | 值      | 说明                             |
7968e41f4b71Sopenharmony_ci| -------------------------------------- | ------- | ------------------------------- |
7969e41f4b71Sopenharmony_ci| ERR_CODE_SERVICE_EXCEPTION             | 6600101 | 会话服务端异常。 <br>**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。 <br>**系统能力:** SystemCapability.Multimedia.AVSession.Core|
7970e41f4b71Sopenharmony_ci| ERR_CODE_SESSION_NOT_EXIST             | 6600102 | 会话不存在。 <br>**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。 <br>**系统能力:** SystemCapability.Multimedia.AVSession.Core |
7971e41f4b71Sopenharmony_ci| ERR_CODE_CONTROLLER_NOT_EXIST          | 6600103 | 会话控制器不存在。 <br>**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。<br>**系统能力:** SystemCapability.Multimedia.AVSession.Core |
7972e41f4b71Sopenharmony_ci| ERR_CODE_REMOTE_CONNECTION_ERR         | 6600104 | 远端会话连接失败。 <br>**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。<br>**系统能力:** SystemCapability.Multimedia.AVSession.Core|
7973e41f4b71Sopenharmony_ci| ERR_CODE_COMMAND_INVALID               | 6600105 | 无效会话命令。<br>**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。 <br>**系统能力:** SystemCapability.Multimedia.AVSession.Core|
7974e41f4b71Sopenharmony_ci| ERR_CODE_SESSION_INACTIVE              | 6600106 | 会话未激活。 <br>**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。<br>**系统能力:** SystemCapability.Multimedia.AVSession.Core |
7975e41f4b71Sopenharmony_ci| ERR_CODE_MESSAGE_OVERLOAD              | 6600107 | 命令&消息过载。 <br>**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。<br>**系统能力:** SystemCapability.Multimedia.AVSession.Core |
7976e41f4b71Sopenharmony_ci| ERR_CODE_DEVICE_CONNECTION_FAILED      | 6600108 | 设备连接失败。 <br>**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。<br>**系统能力:** SystemCapability.Multimedia.AVSession.Core |
7977e41f4b71Sopenharmony_ci| ERR_CODE_REMOTE_CONNECTION_NOT_EXIST   | 6600109 | 远端会话不存在。 <br>**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。<br>**系统能力:** SystemCapability.Multimedia.AVSession.Core |
7978e41f4b71Sopenharmony_ci| ERR_CODE_CAST_CONTROL_UNSPECIFIED    | 6611000 | 未被定义的投播错误码。 <br>**原子化服务API:** 从API version 13开始,该接口支持在原子化服务中使用。<br>**系统能力:** SystemCapability.Multimedia.AVSession.AVCast|
7979e41f4b71Sopenharmony_ci| ERR_CODE_CAST_CONTROL_REMOTE_ERROR    | 6611001 | 远端播放器中发生不明错误。 <br>**原子化服务API:** 从API version 13开始,该接口支持在原子化服务中使用。<br>**系统能力:** SystemCapability.Multimedia.AVSession.AVCast|
7980e41f4b71Sopenharmony_ci| ERR_CODE_CAST_CONTROL_BEHIND_LIVE_WINDOW     | 6611002 | 播放出现延迟。 <br>**原子化服务API:** 从API version 13开始,该接口支持在原子化服务中使用。<br>**系统能力:** SystemCapability.Multimedia.AVSession.AVCast|
7981e41f4b71Sopenharmony_ci| ERR_CODE_CAST_CONTROL_TIMEOUT     | 6611003 | 投播控制进程超时。 <br>**原子化服务API:** 从API version 13开始,该接口支持在原子化服务中使用。<br>**系统能力:** SystemCapability.Multimedia.AVSession.AVCast|
7982e41f4b71Sopenharmony_ci| ERR_CODE_CAST_CONTROL_RUNTIME_CHECK_FAILED      | 6611004 | 运行时检查失败。 <br>**原子化服务API:** 从API version 13开始,该接口支持在原子化服务中使用。<br>**系统能力:** SystemCapability.Multimedia.AVSession.AVCast|
7983e41f4b71Sopenharmony_ci| ERR_CODE_CAST_CONTROL_PLAYER_NOT_WORKING      | 6611100 | 跨设备数据传输被锁定。 <br>**原子化服务API:** 从API version 13开始,该接口支持在原子化服务中使用。<br>**系统能力:** SystemCapability.Multimedia.AVSession.AVCast|
7984e41f4b71Sopenharmony_ci| ERR_CODE_CAST_CONTROL_SEEK_MODE_UNSUPPORTED      | 6611101 | 不支持指定的查找模式。 <br>**原子化服务API:** 从API version 13开始,该接口支持在原子化服务中使用。<br>**系统能力:** SystemCapability.Multimedia.AVSession.AVCast|
7985e41f4b71Sopenharmony_ci| ERR_CODE_CAST_CONTROL_ILLEGAL_SEEK_TARGET      | 6611102 | 要搜索的位置超出媒体的范围,或者不支持当前搜索模式。 <br>**原子化服务API:** 从API version 13开始,该接口支持在原子化服务中使用。<br>**系统能力:** SystemCapability.Multimedia.AVSession.AVCast|
7986e41f4b71Sopenharmony_ci| ERR_CODE_CAST_CONTROL_PLAY_MODE_UNSUPPORTED      | 6611103 |  不支持指定的播放模式。 <br>**原子化服务API:** 从API version 13开始,该接口支持在原子化服务中使用。<br>**系统能力:** SystemCapability.Multimedia.AVSession.AVCast|
7987e41f4b71Sopenharmony_ci| ERR_CODE_CAST_CONTROL_PLAY_SPEED_UNSUPPORTED      | 6611104 | 不支持指定的播放速度。 <br>**原子化服务API:** 从API version 13开始,该接口支持在原子化服务中使用。<br>**系统能力:** SystemCapability.Multimedia.AVSession.AVCast|
7988e41f4b71Sopenharmony_ci| ERR_CODE_CAST_CONTROL_DEVICE_MISSING      | 6611105 | 操作失败,因为媒体源设备或媒体接收器设备已被销毁。 <br>**原子化服务API:** 从API version 13开始,该接口支持在原子化服务中使用。<br>**系统能力:** SystemCapability.Multimedia.AVSession.AVCast|
7989e41f4b71Sopenharmony_ci| ERR_CODE_CAST_CONTROL_INVALID_PARAM       | 6611106 | 该参数无效。 <br>**原子化服务API:** 从API version 13开始,该接口支持在原子化服务中使用。<br>**系统能力:** SystemCapability.Multimedia.AVSession.AVCast|
7990e41f4b71Sopenharmony_ci| ERR_CODE_CAST_CONTROL_NO_MEMORY       | 6611107 | 内存分配失败。 <br>**原子化服务API:** 从API version 13开始,该接口支持在原子化服务中使用。<br>**系统能力:** SystemCapability.Multimedia.AVSession.AVCast|
7991e41f4b71Sopenharmony_ci| ERR_CODE_CAST_CONTROL_OPERATION_NOT_ALLOWED       | 6611108 | 不被允许的操作。<br>**原子化服务API:** 从API version 13开始,该接口支持在原子化服务中使用。<br>**系统能力:** SystemCapability.Multimedia.AVSession.AVCast|
7992e41f4b71Sopenharmony_ci| ERR_CODE_CAST_CONTROL_IO_UNSPECIFIED       | 6612000 | 未指定的输入/输出错误。 <br>**原子化服务API:** 从API version 13开始,该接口支持在原子化服务中使用。<br>**系统能力:** SystemCapability.Multimedia.AVSession.AVCast|
7993e41f4b71Sopenharmony_ci| ERR_CODE_CAST_CONTROL_IO_NETWORK_CONNECTION_FAILED       | 6612001 | 网络连接失败。 <br>**原子化服务API:** 从API version 13开始,该接口支持在原子化服务中使用。<br>**系统能力:** SystemCapability.Multimedia.AVSession.AVCast|
7994e41f4b71Sopenharmony_ci| ERR_CODE_CAST_CONTROL_IO_NETWORK_CONNECTION_TIMEOUT       | 6612002 | 网络连接超时。 <br>**原子化服务API:** 从API version 13开始,该接口支持在原子化服务中使用。<br>**系统能力:** SystemCapability.Multimedia.AVSession.AVCast|
7995e41f4b71Sopenharmony_ci| ERR_CODE_CAST_CONTROL_IO_INVALID_HTTP_CONTENT_TYPE       | 6612003 | 无效的"Content-Type"。 <br>**原子化服务API:** 从API version 13开始,该接口支持在原子化服务中使用。<br>**系统能力:** SystemCapability.Multimedia.AVSession.AVCast|
7996e41f4b71Sopenharmony_ci| ERR_CODE_CAST_CONTROL_IO_BAD_HTTP_STATUS        | 6612004 | HTTP服务器返回一个意外的HTTP响应状态码。 <br>**原子化服务API:** 从API version 13开始,该接口支持在原子化服务中使用。<br>**系统能力:** SystemCapability.Multimedia.AVSession.AVCast|
7997e41f4b71Sopenharmony_ci| ERR_CODE_CAST_CONTROL_IO_FILE_NOT_FOUND   | 6612005 | 文件不存在。 <br>**原子化服务API:** 从API version 13开始,该接口支持在原子化服务中使用。<br>**系统能力:** SystemCapability.Multimedia.AVSession.AVCast|
7998e41f4b71Sopenharmony_ci| ERR_CODE_CAST_CONTROL_IO_NO_PERMISSION    | 6612006 | 不允许执行输入/输出的IO操作。 <br>**原子化服务API:** 从API version 13开始,该接口支持在原子化服务中使用。<br>**系统能力:** SystemCapability.Multimedia.AVSession.AVCast|
7999e41f4b71Sopenharmony_ci| ERR_CODE_CAST_CONTROL_IO_CLEARTEXT_NOT_PERMITTED    | 6612007 | 应用的网络安全配置不允许访问明文HTTP流量。 <br>**原子化服务API:** 从API version 13开始,该接口支持在原子化服务中使用。<br>**系统能力:** SystemCapability.Multimedia.AVSession.AVCast|
8000e41f4b71Sopenharmony_ci| ERR_CODE_CAST_CONTROL_IO_READ_POSITION_OUT_OF_RANGE        | 6612008 | 从数据绑定中读取数据。 <br>**原子化服务API:** 从API version 13开始,该接口支持在原子化服务中使用。<br>**系统能力:** SystemCapability.Multimedia.AVSession.AVCast|
8001e41f4b71Sopenharmony_ci| ERR_CODE_CAST_CONTROL_IO_NO_CONTENTS     | 6612100 | 媒体中没有可播放的内容。 <br>**原子化服务API:** 从API version 13开始,该接口支持在原子化服务中使用。<br>**系统能力:** SystemCapability.Multimedia.AVSession.AVCast|
8002e41f4b71Sopenharmony_ci| ERR_CODE_CAST_CONTROL_IO_READ_ERROR        | 6612101 | 媒体无法读取。 <br>**原子化服务API:** 从API version 13开始,该接口支持在原子化服务中使用。<br>**系统能力:** SystemCapability.Multimedia.AVSession.AVCast|
8003e41f4b71Sopenharmony_ci| ERR_CODE_CAST_CONTROL_IO_CONTENT_BUSY         | 6612102 | 该资源正在使用中。 <br>**原子化服务API:** 从API version 13开始,该接口支持在原子化服务中使用。<br>**系统能力:** SystemCapability.Multimedia.AVSession.AVCast|
8004e41f4b71Sopenharmony_ci| ERR_CODE_CAST_CONTROL_IO_CONTENT_EXPIRED    | 6612103 | 输入/输出的IO请求内容已过期。 <br>**原子化服务API:** 从API version 13开始,该接口支持在原子化服务中使用。<br>**系统能力:** SystemCapability.Multimedia.AVSession.AVCast|
8005e41f4b71Sopenharmony_ci| ERR_CODE_CAST_CONTROL_IO_USE_FORBIDDEN    | 6612104 | 不允许播放请求内容。 <br>**原子化服务API:** 从API version 13开始,该接口支持在原子化服务中使用。<br>**系统能力:** SystemCapability.Multimedia.AVSession.AVCast|
8006e41f4b71Sopenharmony_ci| ERR_CODE_CAST_CONTROL_IO_NOT_VERIFIED     | 6612105 | 无法验证所允许的内容。 <br>**原子化服务API:** 从API version 13开始,该接口支持在原子化服务中使用。<br>**系统能力:** SystemCapability.Multimedia.AVSession.AVCast|
8007e41f4b71Sopenharmony_ci| ERR_CODE_CAST_CONTROL_IO_EXHAUSTED_ALLOWED_USES     | 6612106 | 此内容已达到允许的最大使用次数。 <br>**原子化服务API:** 从API version 13开始,该接口支持在原子化服务中使用。<br>**系统能力:** SystemCapability.Multimedia.AVSession.AVCast|
8008e41f4b71Sopenharmony_ci| ERR_CODE_CAST_CONTROL_IO_NETWORK_PACKET_SENDING_FAILED   | 6612107 | 从源设备发送数据包到接收设备时出现错误。 <br>**原子化服务API:** 从API version 13开始,该接口支持在原子化服务中使用。<br>**系统能力:** SystemCapability.Multimedia.AVSession.AVCast|
8009e41f4b71Sopenharmony_ci| ERR_CODE_CAST_CONTROL_PARSING_UNSPECIFIED    | 6613000 | 未指定的内容解析错误。 <br>**原子化服务API:** 从API version 13开始,该接口支持在原子化服务中使用。<br>**系统能力:** SystemCapability.Multimedia.AVSession.AVCast|
8010e41f4b71Sopenharmony_ci| ERR_CODE_CAST_CONTROL_PARSING_CONTAINER_MALFORMED    | 6613001 | 媒体容器比特流的格式解析错误。 <br>**原子化服务API:** 从API version 13开始,该接口支持在原子化服务中使用。<br>**系统能力:** SystemCapability.Multimedia.AVSession.AVCast|
8011e41f4b71Sopenharmony_ci| ERR_CODE_CAST_CONTROL_PARSING_MANIFEST_MALFORMED     | 6613002 | 媒体清单解析错误。 <br>**原子化服务API:** 从API version 13开始,该接口支持在原子化服务中使用。<br>**系统能力:** SystemCapability.Multimedia.AVSession.AVCast|
8012e41f4b71Sopenharmony_ci| ERR_CODE_CAST_CONTROL_PARSING_CONTAINER_UNSUPPORTED   | 6613003 | 文件的媒体容器格式/媒体容器特性不被支持。 <br>**原子化服务API:** 从API version 13开始,该接口支持在原子化服务中使用。<br>**系统能力:** SystemCapability.Multimedia.AVSession.AVCast|
8013e41f4b71Sopenharmony_ci| ERR_CODE_CAST_CONTROL_PARSING_MANIFEST_UNSUPPORTED      | 6613004 | 媒体清单中不支持的特性。 <br>**原子化服务API:** 从API version 13开始,该接口支持在原子化服务中使用。<br>**系统能力:** SystemCapability.Multimedia.AVSession.AVCast|
8014e41f4b71Sopenharmony_ci| ERR_CODE_CAST_CONTROL_DECODING_UNSPECIFIED     | 6614000 | 未指定的解码错误。 <br>**原子化服务API:** 从API version 13开始,该接口支持在原子化服务中使用。<br>**系统能力:** SystemCapability.Multimedia.AVSession.AVCast|
8015e41f4b71Sopenharmony_ci| ERR_CODE_CAST_CONTROL_DECODING_INIT_FAILED   | 6614001 | 解码器初始化失败。 <br>**原子化服务API:** 从API version 13开始,该接口支持在原子化服务中使用。<br>**系统能力:** SystemCapability.Multimedia.AVSession.AVCast|
8016e41f4b71Sopenharmony_ci| ERR_CODE_CAST_CONTROL_DECODING_QUERY_FAILED     | 6614002 | 解码器查询失败。 <br>**原子化服务API:** 从API version 13开始,该接口支持在原子化服务中使用。<br>**系统能力:** SystemCapability.Multimedia.AVSession.AVCast|
8017e41f4b71Sopenharmony_ci| ERR_CODE_CAST_CONTROL_DECODING_FAILED     | 6614003 | 媒体样本解码失败。 <br>**原子化服务API:** 从API version 13开始,该接口支持在原子化服务中使用。<br>**系统能力:** SystemCapability.Multimedia.AVSession.AVCast|
8018e41f4b71Sopenharmony_ci| ERR_CODE_CAST_CONTROL_DECODING_FORMAT_EXCEEDS_CAPABILITIES    | 6614004 | 设备的能力无法解码当前格式。<br>**原子化服务API:** 从API version 13开始,该接口支持在原子化服务中使用。<br>**系统能力:** SystemCapability.Multimedia.AVSession.AVCast|
8019e41f4b71Sopenharmony_ci| ERR_CODE_CAST_CONTROL_DECODING_FORMAT_UNSUPPORTED    | 6614005 | 不支持的解码格式。 <br>**原子化服务API:** 从API version 13开始,该接口支持在原子化服务中使用。<br>**系统能力:** SystemCapability.Multimedia.AVSession.AVCast|
8020e41f4b71Sopenharmony_ci| ERR_CODE_CAST_CONTROL_AUDIO_RENDERER_UNSPECIFIED       | 6615000 | 未指定的音频渲染器错误。 <br>**原子化服务API:** 从API version 13开始,该接口支持在原子化服务中使用。<br>**系统能力:** SystemCapability.Multimedia.AVSession.AVCast|
8021e41f4b71Sopenharmony_ci| ERR_CODE_CAST_CONTROL_AUDIO_RENDERER_INIT_FAILED      | 6615001 | 音频渲染器初始化失败。 <br>**原子化服务API:** 从API version 13开始,该接口支持在原子化服务中使用。<br>**系统能力:** SystemCapability.Multimedia.AVSession.AVCast|
8022e41f4b71Sopenharmony_ci| ERR_CODE_CAST_CONTROL_AUDIO_RENDERER_WRITE_FAILED    | 6615002 | 音频渲染器写入数据失败。 <br>**原子化服务API:** 从API version 13开始,该接口支持在原子化服务中使用。<br>**系统能力:** SystemCapability.Multimedia.AVSession.AVCast|
8023e41f4b71Sopenharmony_ci| ERR_CODE_CAST_CONTROL_DRM_UNSPECIFIED      | 6616000 | 未指定的DRM相关错误。 <br>**原子化服务API:** 从API version 13开始,该接口支持在原子化服务中使用。<br>**系统能力:** SystemCapability.Multimedia.AVSession.AVCast|
8024e41f4b71Sopenharmony_ci| ERR_CODE_CAST_CONTROL_DRM_SCHEME_UNSUPPORTED  | 6616001 | 设备不支持所选择的DRM保护方案。 <br>**原子化服务API:** 从API version 13开始,该接口支持在原子化服务中使用。<br>**系统能力:** SystemCapability.Multimedia.AVSession.AVCast|
8025e41f4b71Sopenharmony_ci| ERR_CODE_CAST_CONTROL_DRM_PROVISIONING_FAILED   | 6616002 | 设备配置失败。<br>**原子化服务API:** 从API version 13开始,该接口支持在原子化服务中使用。<br>**系统能力:** SystemCapability.Multimedia.AVSession.AVCast|
8026e41f4b71Sopenharmony_ci| ERR_CODE_CAST_CONTROL_DRM_CONTENT_ERROR  | 6616003 | 受DRM保护的内容无法播放。 <br>**原子化服务API:** 从API version 13开始,该接口支持在原子化服务中使用。<br>**系统能力:** SystemCapability.Multimedia.AVSession.AVCast|
8027e41f4b71Sopenharmony_ci| ERR_CODE_CAST_CONTROL_DRM_LICENSE_ACQUISITION_FAILED    | 6616004 | 获取许可证失败。 <br>**原子化服务API:** 从API version 13开始,该接口支持在原子化服务中使用。<br>**系统能力:** SystemCapability.Multimedia.AVSession.AVCast|
8028e41f4b71Sopenharmony_ci| ERR_CODE_CAST_CONTROL_DRM_DISALLOWED_OPERATION     | 6616005 | 许可证策略不允许该操作。 <br>**原子化服务API:** 从API version 13开始,该接口支持在原子化服务中使用。<br>**系统能力:** SystemCapability.Multimedia.AVSession.AVCast|
8029e41f4b71Sopenharmony_ci| ERR_CODE_CAST_CONTROL_DRM_SYSTEM_ERROR     | 6616006 | DRM系统中发生错误。 <br>**原子化服务API:** 从API version 13开始,该接口支持在原子化服务中使用。<br>**系统能力:** SystemCapability.Multimedia.AVSession.AVCast|
8030e41f4b71Sopenharmony_ci| ERR_CODE_CAST_CONTROL_DRM_DEVICE_REVOKED     | 6616007 | 设备已撤销DRM权限。 <br>**原子化服务API:** 从API version 13开始,该接口支持在原子化服务中使用。<br>**系统能力:** SystemCapability.Multimedia.AVSession.AVCast|
8031e41f4b71Sopenharmony_ci| ERR_CODE_CAST_CONTROL_DRM_LICENSE_EXPIRED   | 6616008 | 加载中的DRM许可证已过期。 <br>**原子化服务API:** 从API version 13开始,该接口支持在原子化服务中使用。<br>**系统能力:** SystemCapability.Multimedia.AVSession.AVCast|
8032e41f4b71Sopenharmony_ci| ERR_CODE_CAST_CONTROL_DRM_PROVIDE_KEY_RESPONSE_ERROR    | 6616100 | DRM处理密钥响应时发生错误。 <br>**原子化服务API:** 从API version 13开始,该接口支持在原子化服务中使用。<br>**系统能力:** SystemCapability.Multimedia.AVSession.AVCast|
8033e41f4b71Sopenharmony_ci
8034e41f4b71Sopenharmony_ci## SkipIntervals<sup>11+</sup>
8035e41f4b71Sopenharmony_ci
8036e41f4b71Sopenharmony_ci表示session支持的快进快退时间间隔的枚举。
8037e41f4b71Sopenharmony_ci
8038e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.AVSession.Core
8039e41f4b71Sopenharmony_ci
8040e41f4b71Sopenharmony_ci| 名称                   | 值 | 说明                     |
8041e41f4b71Sopenharmony_ci| ---------------------- | -- | ----------------------- |
8042e41f4b71Sopenharmony_ci| SECONDS_10             | 10 | 时间为10秒。             |
8043e41f4b71Sopenharmony_ci| SECONDS_15             | 15 | 时间为15秒。             |
8044e41f4b71Sopenharmony_ci| SECONDS_30             | 30 | 时间为30秒。             |
8045