diff --git a/README.en.md b/README.en.md index e6d391fb03fda1498cd68901f3e21cde1b6ea669..56685eaebf56e84ce66c42cfcf369877c740811c 100644 --- a/README.en.md +++ b/README.en.md @@ -16,10 +16,6 @@ The figure shows the effect on the tablet. ![](screenshots/device/pad.en.png) -### Permissions - -N/A - ### How to Use 1. Install and open an app on a mobile phone, foldable phone, or tablet. The responsive layout and adaptive layout are used to display different effects on the app pages over different devices. @@ -28,6 +24,10 @@ N/A 4. Tap the comment button on the page to go to the corresponding comment page. 5. Other buttons do not have actual tap events or functions. +### Permissions + +N/A + ### Constraints 1. The sample is only supported on Huawei phones with standard systems. diff --git a/README.md b/README.md index c72b577822035ddafe5213bffb5ddd69bca225f8..b6c4b87209d2bb09b685833dbe4bc225257be452 100644 --- a/README.md +++ b/README.md @@ -16,10 +16,6 @@ ![](screenshots/device/pad.png) -### 相关权限 - -不涉及 - ### 使用说明 1. 分别在手机、折叠屏、平板安装并打开应用,不同设备的应用页面通过响应式布局和自适应布局呈现不同的效果。 @@ -28,6 +24,10 @@ 4. 点击界面上评论按钮跳转到对应的评论页面。 5. 其他按钮无实际点击事件或功能。 +### 相关权限 + +不涉及 + ### 约束与限制 1. 本示例仅支持标准系统上运行,支持设备:华为手机。 diff --git a/common/mediaCommon/src/main/ets/utils/BackgroundUtil.ets b/common/mediaCommon/src/main/ets/utils/BackgroundUtil.ets index cff7b52a1945bc0c478a1ff94de9559a347fd614..1ac92b37f02f31b7492d9b4eedb320bb0a450f93 100644 --- a/common/mediaCommon/src/main/ets/utils/BackgroundUtil.ets +++ b/common/mediaCommon/src/main/ets/utils/BackgroundUtil.ets @@ -19,7 +19,6 @@ import { BusinessError } from '@kit.BasicServicesKit'; import { Logger } from './Logger'; export class BackgroundUtil { - /** * Start background task. * @@ -44,15 +43,17 @@ export class BackgroundUtil { wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj: Object) => { try { - backgroundTaskManager.startBackgroundRunning(context, - backgroundTaskManager.BackgroundMode.AUDIO_PLAYBACK, wantAgentObj).then(() => { - Logger.info('this avPlayer: ', 'startBackgroundRunning succeeded'); - }).catch((error: BusinessError) => { - Logger.error('this avPlayer: ', `startBackgroundRunning failed Cause: code ${error.code}`); - }); + if (canIUse('SystemCapability.ResourceSchedule.BackgroundTaskManager.Core')) { + backgroundTaskManager.startBackgroundRunning(context, + backgroundTaskManager.BackgroundMode.AUDIO_PLAYBACK, wantAgentObj).then(() => { + Logger.info('this avPlayer: ', 'startBackgroundRunning succeeded'); + }).catch((error: BusinessError) => { + Logger.error('this avPlayer: ', `startBackgroundRunning failed Cause: code ${error.code}`); + }); + } } catch (error) { - Logger.error('this avPlayer: ', `startBackgroundRunning failed. code ${(error as BusinessError).code} - message ${(error as BusinessError).message}`); + Logger.error('this avPlayer: ', + `startBackgroundRunning failed. code ${(error as BusinessError).code} message ${(error as BusinessError).message}`); } }); } @@ -63,15 +64,17 @@ export class BackgroundUtil { * @param context */ public static stopContinuousTask(context: common.UIAbilityContext): void { - try { - backgroundTaskManager.stopBackgroundRunning(context).then(() => { - Logger.info('this avPlayer: ', 'stopBackgroundRunning succeeded'); - }).catch((error: BusinessError) => { - Logger.error('this avPlayer: ', `stopBackgroundRunning failed Cause: code ${error.code}`); - }); - } catch (error) { - Logger.error('this avPlayer: ', `stopBackgroundRunning failed. code ${(error as BusinessError).code} - message ${(error as BusinessError).message}`); + if (canIUse('SystemCapability.ResourceSchedule.BackgroundTaskManager.Core')) { + try { + backgroundTaskManager.stopBackgroundRunning(context).then(() => { + Logger.info('this avPlayer: ', 'stopBackgroundRunning succeeded'); + }).catch((error: BusinessError) => { + Logger.error('this avPlayer: ', `stopBackgroundRunning failed Cause: code ${error.code}`); + }); + } catch (error) { + Logger.error('this avPlayer: ', + `stopBackgroundRunning failed. code ${(error as BusinessError).code} message ${(error as BusinessError).message}`); + } } } } \ No newline at end of file diff --git a/common/mediaCommon/src/main/module.json5 b/common/mediaCommon/src/main/module.json5 index fe39b67723ad4379bcb4012c940d079887cc721c..9a0b30951a8f4cbaadc1b45cab27b15b924fce78 100644 --- a/common/mediaCommon/src/main/module.json5 +++ b/common/mediaCommon/src/main/module.json5 @@ -6,6 +6,11 @@ "phone", "tablet", "2in1" + ], + "requestPermissions": [ + { + "name": "ohos.permission.KEEP_BACKGROUND_RUNNING" + } ] } } diff --git a/features/musicComment/src/main/ets/view/ListItemComponent.ets b/features/musicComment/src/main/ets/view/ListItemComponent.ets index 1bccba56634d3f203e797c8c6f009813da5b79ed..5bfc207ddc21d210401624c3efbb997f7e31e48e 100644 --- a/features/musicComment/src/main/ets/view/ListItemComponent.ets +++ b/features/musicComment/src/main/ets/view/ListItemComponent.ets @@ -19,7 +19,7 @@ import { CommonConstants } from '../constants/CommonConstants'; @Component export struct ListItemComponent { - private item: Comment = new Comment('', '', '', $r('app.media.ic_avatar12')); + public item: Comment = new Comment('', '', '', $r('app.media.ic_avatar12')); build() { Row() { diff --git a/features/musicList/src/main/ets/components/MusicControlComponent.ets b/features/musicList/src/main/ets/components/MusicControlComponent.ets index 1422d6a6eca652229b2ae4d28f4dee2c2b875473..e68a0ef83022911a18d05e14e221fb5e524c73b9 100644 --- a/features/musicList/src/main/ets/components/MusicControlComponent.ets +++ b/features/musicList/src/main/ets/components/MusicControlComponent.ets @@ -110,6 +110,7 @@ export struct MusicControlComponent { left: $r('app.float.margin_small'), right: $r('app.float.margin_small') }) + GridCol({ span: { md: BreakpointConstants.SPAN_SM } }) { @@ -157,6 +158,7 @@ export struct MusicControlComponent { bottom: $r('app.float.common_margin') }) } + GridCol({ span: { md: BreakpointConstants.SPAN_SM, lg: BreakpointConstants.SPAN_MD }, offset: { lg: BreakpointConstants.OFFSET_MD } @@ -242,7 +244,7 @@ export struct MusicControlComponent { */ getImageColor() { if (!this.context) { - return ; + return; } this.context.resourceManager.getMediaContent(this.songList[this.selectIndex].label) .then((value: Uint8Array) => { diff --git a/features/musicList/src/main/ets/lyric/LrcView.ets b/features/musicList/src/main/ets/lyric/LrcView.ets index 01063caf8f660b0d171a02135bc1976abc88a4ef..84e85529867ef8923d85cd17fb0d11874b28d4f9 100644 --- a/features/musicList/src/main/ets/lyric/LrcView.ets +++ b/features/musicList/src/main/ets/lyric/LrcView.ets @@ -75,7 +75,7 @@ export default struct shiLrcView { /** * Location of the lyrics. */ - private readonly lyricTopPosition: LyricTopPosition = LyricTopPosition.Top; + public readonly lyricTopPosition: LyricTopPosition = LyricTopPosition.Top; /** * Initial position of the first line of the lyrics.