diff --git a/MediaService/src/main/ets/utils/BackgroundUtil.ets b/MediaService/src/main/ets/utils/BackgroundUtil.ets index 1d36cca8e50bef6025bdcb567a73d2899097706d..7bd8f0eef551fe0fb6dd7229f7805bd25e1eb8ff 100644 --- a/MediaService/src/main/ets/utils/BackgroundUtil.ets +++ b/MediaService/src/main/ets/utils/BackgroundUtil.ets @@ -45,12 +45,15 @@ export class BackgroundUtil { wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj: Object) => { try { - backgroundTaskManager.startBackgroundRunning(context, - backgroundTaskManager.BackgroundMode.AUDIO_PLAYBACK, wantAgentObj).then(() => { - Logger.info('this audioRenderer: ', 'startBackgroundRunning succeeded'); - }).catch((error: BusinessError) => { - Logger.error(TAG, `startBackgroundRunning failed. code: ${error.code}, message: ${error.message}`); - }); + if (canIUse('SystemCapability.ResourceSchedule.BackgroundTaskManager.Core') && + canIUse('SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask')) { + backgroundTaskManager.startBackgroundRunning(context, + backgroundTaskManager.BackgroundMode.AUDIO_PLAYBACK, wantAgentObj).then(() => { + Logger.info('this audioRenderer: ', 'startBackgroundRunning succeeded'); + }).catch((error: BusinessError) => { + Logger.error(TAG, `startBackgroundRunning failed. code: ${error.code}, message: ${error.message}`); + }); + } } catch (err) { Logger.error(TAG, `startBackgroundRunning failed. code: ${err.code}, message: ${err.message}`); } @@ -64,11 +67,14 @@ export class BackgroundUtil { */ public static stopContinuousTask(context: common.UIAbilityContext): void { try { - backgroundTaskManager.stopBackgroundRunning(context).then(() => { - Logger.info(TAG, 'stopBackgroundRunning succeeded'); - }).catch((error: BusinessError) => { - Logger.error(TAG, `stopBackgroundRunning failed. code: ${error.code}, message: ${error.message}`); - }); + if (canIUse('SystemCapability.ResourceSchedule.BackgroundTaskManager.Core') && + canIUse('SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask')) { + backgroundTaskManager.stopBackgroundRunning(context).then(() => { + Logger.info(TAG, 'stopBackgroundRunning succeeded'); + }).catch((error: BusinessError) => { + Logger.error(TAG, `stopBackgroundRunning failed. code: ${error.code}, message: ${error.message}`); + }); + } } catch (err) { Logger.error(TAG, `stopBackgroundRunning failed. code: ${err.code}, message: ${err.message}`); } diff --git a/entry/src/main/ets/components/MusicInfoComponent.ets b/entry/src/main/ets/components/MusicInfoComponent.ets index df81b145267136cfade5969529ecade4e3c299cd..3dbe0c8fab7f36d18b4acdee480207168191cd44 100644 --- a/entry/src/main/ets/components/MusicInfoComponent.ets +++ b/entry/src/main/ets/components/MusicInfoComponent.ets @@ -62,7 +62,7 @@ export struct MusicInfoComponent { CoverInfo() { Row() { Image(this.songList[this.selectIndex].label) - .width((deviceInfo.productSeries === 'VDE' && display.getFoldStatus() === 1) ? + .width((deviceInfo.productSeries === 'VDE' && this.getFoldStatus() === 1) ? StyleConstants.EIGHT_SIX_WIDTH : StyleConstants.FULL_WIDTH) .aspectRatio(1) .borderRadius($r('app.float.cover_radius_label')) @@ -72,7 +72,7 @@ export struct MusicInfoComponent { offsetX: 0, offsetY: 8 }) - .margin((deviceInfo.productSeries === 'VDE' && display.getFoldStatus() === 1) ? + .margin((deviceInfo.productSeries === 'VDE' && this.getFoldStatus() === 1) ? $r('app.float.cover_image_margin') : $r('app.float.lyric_margin_right_sm')) } } @@ -100,4 +100,11 @@ export struct MusicInfoComponent { } .margin({ top: $r('app.float.music_info_margin_top') }) } + + getFoldStatus(): number { + if (canIUse('SystemCapability.Window.SessionManager')) { + return display.getFoldStatus(); + } + return 0; + } } \ No newline at end of file diff --git a/entry/src/main/ets/components/PlayerInfoComponent.ets b/entry/src/main/ets/components/PlayerInfoComponent.ets index 3ff0cf6a9cf7d7e1af7a062c90084e660bf1d1a3..188de6bd8e18fa90a014bb4f445624ccb9b3aacb 100644 --- a/entry/src/main/ets/components/PlayerInfoComponent.ets +++ b/entry/src/main/ets/components/PlayerInfoComponent.ets @@ -188,7 +188,7 @@ export struct PlayerInfoComponent { Swiper() { MusicInfoComponent() .margin({ - top: (deviceInfo.productSeries === 'VDE' && display.getFoldStatus() === 1) ? + top: (deviceInfo.productSeries === 'VDE' && this.getFoldStatus() === 1) ? $r('app.float.control_width') : $r('app.float.music_component_top'), bottom: $r('app.float.music_component_bottom') }) @@ -285,4 +285,11 @@ export struct PlayerInfoComponent { Logger.error(TAG, `getImageColor failed. Code:${error.code}, message:${error.message}`); }) } + + getFoldStatus(): number { + if (canIUse('SystemCapability.Window.SessionManager')) { + return display.getFoldStatus(); + } + return 0; + } } \ No newline at end of file diff --git a/entry/src/main/ets/lyric/LrcView.ets b/entry/src/main/ets/lyric/LrcView.ets index 9326b1eeb5db57bca7d220e4ba3453da69ae88cf..ae084d75dea4014aef6599bdf5d8287ef82b697e 100644 --- a/entry/src/main/ets/lyric/LrcView.ets +++ b/entry/src/main/ets/lyric/LrcView.ets @@ -78,7 +78,7 @@ export default struct shiLrcView { /** * Location of the lyrics. */ - private readonly lyricTopPosition: LyricTopPosition = LyricTopPosition.Top; + readonly lyricTopPosition: LyricTopPosition = LyricTopPosition.Top; /** * Initial position of the first line of the lyrics. */