diff --git a/code/SystemFeature/Media/AVSession/MediaController/README.md b/code/SystemFeature/Media/AVSession/MediaController/README.md index 43a2d9aa24622e640f41d0c5bdea4cf2fa06b161..260944b82024ac28b726385c582490a0216f1197 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 12540426a4404e14cf2e02400c14395898ae6be4..071d3718f7000cffa8593c06cfc07671469aecc1 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 38630473c6c85cb8fd72b1e0f58fafd04f61696b..2cb0174a663eb7d33923eeb6aec08dce126b2910 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": [