diff --git a/zh-cn/application-dev/media/using-avsession-controller.md b/zh-cn/application-dev/media/using-avsession-controller.md index 50004d1485123d129288763cc43dbb4bd9e0d491..9842ff1d21cfba07a39278c158e0ca731beb4afc 100644 --- a/zh-cn/application-dev/media/using-avsession-controller.md +++ b/zh-cn/application-dev/media/using-avsession-controller.md @@ -32,6 +32,7 @@ OpenHarmony系统预置的播控中心,作为媒体会话控制方与音视频 | sendSystemAVKeyEvent(event: KeyEvent, callback: AsyncCallback<void>): void | 向置顶会话发送按键命令。 | | sendControlCommand(command: AVControlCommand, callback: AsyncCallback<void>): void | 通过会话对应的AVSessionController向会话发送播控命令。 | | sendSystemControlCommand(command: AVControlCommand, callback: AsyncCallback<void>): void | 向置顶会话发送播控命令。 | +| getHistoricalSessionDescriptors(maxSize: number, callback: AsyncCallback\>>): void10+ | 获取历史会话的描述符。 | ### 通过AVSessionController对象调用的接口 @@ -80,6 +81,19 @@ OpenHarmony系统预置的播控中心,作为媒体会话控制方与音视频 console.error(`Failed to get all session descriptors. Code: ${err.code}, message: ${err.message}`); }); + // 获取历史会话的描述符 + avSession.getHistoricalSessionDescriptors().then((descriptors) => { + console.info(`getHistoricalSessionDescriptors : SUCCESS : descriptors.length : ${descriptors.length}`); + if (descriptors.length > 0){ + console.info(`getHistoricalSessionDescriptors : SUCCESS : descriptors[0].isActive : ${descriptors[0].isActive}`); + console.info(`getHistoricalSessionDescriptors : SUCCESS : descriptors[0].type : ${descriptors[0].type}`); + console.info(`getHistoricalSessionDescriptors : SUCCESS : descriptors[0].sessionTag : ${descriptors[0].sessionTag}`); + console.info(`getHistoricalSessionDescriptors : SUCCESS : descriptors[0].sessionId : ${descriptors[0].sessionId}`); + console.info(`getHistoricalSessionDescriptors : SUCCESS : descriptors[0].elementName.bundleName : ${descriptors[0].elementName.bundleName}`); + } + }).catch((err) => { + console.error(`Failed to get historical session descriptors, error code: ${err.code}, error message: ${err.message}`); + }); ``` 2. 监听AVSession会话状态及AVSession服务状态事件。 diff --git a/zh-cn/application-dev/media/using-avsession-developer.md b/zh-cn/application-dev/media/using-avsession-developer.md index 43725a745b7b52e4c87b66267665b857104b3565..865417c9a28f6526934a4c7d4702db452f78fd51 100644 --- a/zh-cn/application-dev/media/using-avsession-developer.md +++ b/zh-cn/application-dev/media/using-avsession-developer.md @@ -90,6 +90,46 @@ console.info(`SetAVPlaybackState successfully`); } }); + // 设置一个播放列表 + let queueItemDescription_1 = { + mediaId: '001', + title: 'music_name', + subtitle: 'music_sub_name', + description: 'music_description', + icon: PIXELMAP_OBJECT, + iconUri: 'http://www.xxx.com', + extras: {'extras':'any'} + }; + let queueItem_1 = { + itemId: 1, + description: queueItemDescription_1 + }; + let queueItemDescription_2 = { + mediaId: '002', + title: 'music_name', + subtitle: 'music_sub_name', + description: 'music_description', + icon: PIXELMAP_OBJECT, + iconUri: 'http://www.xxx.com', + extras: {'extras':'any'} + }; + let queueItem_2 = { + itemId: 2, + description: queueItemDescription_2 + }; + let queueItemsArray = [queueItem_1, queueItem_2]; + session.setAVQueueItems(queueItemsArray).then(() => { + console.info(`SetAVQueueItems successfully`); + }).catch((err) => { + console.error(`Failed to set AVQueueItem, error code: ${err.code}, error message: ${err.message}`); + }); + // 设置媒体播放列表名称 + let queueTitle = 'QUEUE_TITLE'; + session.setAVQueueTitle(queueTitle).then(() => { + console.info(`SetAVQueueTitle successfully`); + }).catch((err) => { + console.info(`Failed to set AVQueueTitle, error code: ${err.code}, error message: ${err.message}`); + }); } ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-avsession.md b/zh-cn/application-dev/reference/apis/js-apis-avsession.md index 7b1b3f501ac63e4845cd68a56b61cee11147f06b..bbb0e021ea3f51f2ef7d8ef45fba93a459d5ef59 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-avsession.md +++ b/zh-cn/application-dev/reference/apis/js-apis-avsession.md @@ -1133,7 +1133,7 @@ let queueItemDescription_2 = { subtitle: 'music_sub_name', description: 'music_description', icon: PIXELMAP_OBJECT, - iconUri: 'http://www.icon.uri.com', + iconUri: 'http://www.xxx.com', extras: {'extras':'any'} }; let queueItem_2 = {