From 43952222d8a0d5e1d57cee2c7bb98f94e5c2a348 Mon Sep 17 00:00:00 2001 From: yuandongping Date: Tue, 20 May 2025 16:25:36 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E5=85=85=E7=BC=BA=E5=A4=B1=E6=9D=83?= =?UTF-8?q?=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yuandongping --- .../Media/AVSession/MediaController/README.md | 20 +++++++++++++++++++ .../entry/src/main/module.json5 | 10 ++++++---- .../entry/src/ohosTest/module.json5 | 6 +++--- 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/code/SystemFeature/Media/AVSession/MediaController/README.md b/code/SystemFeature/Media/AVSession/MediaController/README.md index 43a2d9aa24..260944b820 100644 --- a/code/SystemFeature/Media/AVSession/MediaController/README.md +++ b/code/SystemFeature/Media/AVSession/MediaController/README.md @@ -16,6 +16,8 @@ #### 使用说明(需与媒体提供方一起使用) +> 本示例在运行前,需预先在本机命令行中执行"hdc shell setenforce 0"命令,才可保证示例功能正常。 + 1. 打开媒体控制方示例应用,可以看到音乐应用的历史记录。 2. 点击播放按钮,应用的播放状态发生变化。 3. 点击暂停按钮,应用的播放状态开始变化。 @@ -158,6 +160,24 @@ entry/src/main/ets/ } ``` +#### 媒体资源管理相关权限 + +如果需要获取当前设备正在播放的媒体资源,并对其进行管理,需要申请媒体资源管理权限[ohos.permission.MANAGE_MEDIA_RESOURCES](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md#ohospermissionmanage_media_resources) + +请在需要获取Bundle信息权限的Ability的`module.json5`中添加以下配置: + +```json5 +{ + "module": { + "requestPermissions": [ + { + "name": "ohos.permission.MANAGE_MEDIA_RESOURCES" + } + ] + } +} +``` + ### 依赖 此示例仅展示媒体控制方的相关功能,如果需要媒体会话提供的完整的自定义信息交互功能,请将本示例与[媒体提供方示例](https://gitee.com/openharmony/applications_app_samples/tree/master/code/BasicFeature/Media/AVSession/MediaProvider)共同使用。 diff --git a/code/SystemFeature/Media/AVSession/MediaController/entry/src/main/module.json5 b/code/SystemFeature/Media/AVSession/MediaController/entry/src/main/module.json5 index 12540426a4..071d3718f7 100644 --- a/code/SystemFeature/Media/AVSession/MediaController/entry/src/main/module.json5 +++ b/code/SystemFeature/Media/AVSession/MediaController/entry/src/main/module.json5 @@ -1,5 +1,5 @@ /* -* Copyright (C) 2023 Huawei Device Co., Ltd. +* Copyright (C) 2023-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -26,17 +26,16 @@ "deliveryWithInstall": true, "installationFree": false, "pages": "$profile:main_pages", - "uiSyntax": "ets", "abilities": [ { "name": "EntryAbility", - "srcEntrance": "./ets/MainAbility/MainAbility.ets", + "srcEntry": "./ets/MainAbility/MainAbility.ets", "description": "$string:EntryAbility_desc", "icon": "$media:icon", "label": "$string:EntryAbility_label", "startWindowIcon": "$media:icon", "startWindowBackground": "$color:start_window_background", - "visible": true, + "exported": true, "skills": [ { "entities": [ @@ -61,6 +60,9 @@ }, { "name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" + }, + { + "name": "ohos.permission.MANAGE_MEDIA_RESOURCES" } ] } diff --git a/code/SystemFeature/Media/AVSession/MediaController/entry/src/ohosTest/module.json5 b/code/SystemFeature/Media/AVSession/MediaController/entry/src/ohosTest/module.json5 index 38630473c6..2cb0174a66 100644 --- a/code/SystemFeature/Media/AVSession/MediaController/entry/src/ohosTest/module.json5 +++ b/code/SystemFeature/Media/AVSession/MediaController/entry/src/ohosTest/module.json5 @@ -1,5 +1,5 @@ /* -* Copyright (C) 2023 Huawei Device Co., Ltd. +* Copyright (C) 2023-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -29,11 +29,11 @@ "abilities": [ { "name": "TestAbility", - "srcEntrance": "./ets/testability/TestAbility.ets", + "srcEntry": "./ets/testability/TestAbility.ets", "description": "$string:TestAbility_desc", "icon": "$media:icon", "label": "$string:TestAbility_label", - "visible": true, + "exported": true, "startWindowIcon": "$media:icon", "startWindowBackground": "$color:start_window_background", "skills": [ -- Gitee