Ver Fonte

播放页的背景流光hdsEffect的添加

onecold há 9 meses atrás
pai
commit
2a26d41c8e
1 ficheiros alterados com 27 adições e 9 exclusões
  1. 27 9
      entry/src/main/ets/view/LocalMusic.ets

+ 27 - 9
entry/src/main/ets/view/LocalMusic.ets

@@ -110,6 +110,7 @@ import { MergeAudio } from './MergeAudio';
 import { AIVoiceSeparation } from './AIVoiceSeparation';
 import { WebDavUrlUtil } from '../common/util/WebDavUrlUtil';
 import {
+  hdsEffect,
   HdsVisualComponent,
   HdsSceneController,
   HdsSceneType,
@@ -233,6 +234,7 @@ const ITEM_HEIGHT_BIG: number = 78; // 列表项大高度
 @Preview
 @Component
 export struct LocalMusic {
+  //背景两侧流光控制器
   @State sceneBgController: HdsSceneController|undefined = deviceInfo.sdkApiVersion>=20
     &&canIUse("SystemCapability.UIDesign.HDSComponent.Core")?
     new HdsSceneController()
@@ -249,6 +251,10 @@ export struct LocalMusic {
         color: Color.Green
       }
     }) : undefined;
+  //背景流光控制器
+  @State bgController: hdsEffect.ShaderEffectController|undefined = deviceInfo.sdkApiVersion>=20
+      &&canIUse("SystemCapability.UIDesign.HDSComponent.Core")?
+    new hdsEffect.ShaderEffectController():undefined;
 
   @State showAddSheet:boolean = false
   searchController: SearchController = new SearchController()
@@ -8011,6 +8017,22 @@ export struct LocalMusic {
     Column() {
       this.IjkMusicPlayerView()
     }
+    .visualEffect(deviceInfo.sdkApiVersion>=20&&this.bgController?
+      new hdsEffect.HdsEffectBuilder()
+      .shaderEffect({
+        effectType: hdsEffect.EffectType.UV_BACKGROUND_FLOW_LIGHT,
+        animation: {
+          duration: 10000,
+          iterations: -1,
+          autoPlay: true,
+          onFinish: ()=> {
+            console.info('Succeeded in finishing');
+          }
+        },
+        controller: this.bgController,
+      })
+      .buildEffect():null)
+
     .height('100%')
     .width('100%')
     .onDisAppear(() => {
@@ -8250,7 +8272,8 @@ export struct LocalMusic {
   IjkMusicPlayerView() {
 
     Stack() {
-        if(canIUse("SystemCapability.UIDesign.HDSComponent.Core")&&deviceInfo.sdkApiVersion>=20&&this.sceneBgController){
+        if(canIUse("SystemCapability.UIDesign.HDSComponent.Core")
+          &&deviceInfo.sdkApiVersion>=20&&this.sceneBgController){
           HdsVisualComponent()
             .scene(HdsSceneType.DUAL_EDGE_FLOW_LIGHT_WITH_BACKGROUND_MASK, this.sceneBgController, () => {
               console.info('Succeeded in finishing');
@@ -8375,11 +8398,9 @@ export struct LocalMusic {
       .margin({ bottom: 8 })
 
     }
-    .backgroundImage(StrUtil.isEmpty(this.cover) ? this.imageLabel : this.cover)
-    // .backgroundImage(this.isPuraWP() && this.currentSwiperIndex === 0 ?
-    //   (StrUtil.isEmpty(this.cover) ? this.imageLabel : this.cover) : this.imageLabelBg)
-    .backgroundImageSize(this.isPuraWP() ? { width: '100%' } : { height: '150%', width: '100%' })
-    // .backgroundImagePosition(Alignment.Center)
+    .backgroundImage(!this.isMusicBGCover?undefined:
+      StrUtil.isEmpty(this.cover) ? this.imageLabel : this.cover)
+    .backgroundImageSize(this.isPuraWP()||!this.isMusicBGCover ? { width: '100%' } : { height: '150%', width: '100%' })
     .animation({
       duration: 666,
       curve: 'ease-in-out' // 可选动画曲线
@@ -8387,12 +8408,9 @@ export struct LocalMusic {
     .backgroundBlurStyle(this.isPuraWP() && this.currentSwiperIndex === 0 ? BlurStyle.NONE :
     BlurStyle.BACKGROUND_ULTRA_THICK)
     .hitTestBehavior(HitTestMode.Transparent)
-    // .transition(TransitionEffect.asymmetric(TransitionEffect.scale({ x: 1.2, y: 1.2 }).animation({ duration: 500 }),
-    //   TransitionEffect.scale({ x: 0, y: 0 })  ))
     .backgroundBrightness({ rate: this.isPuraWP() ? 0.1 : 0, lightUpDegree: -0.1 })
     .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP, SafeAreaEdge.BOTTOM])
     .onClick(() => {
-      // this.startAutoHide()
       if(this.isHiCar())
         return
       if(this.is_auto_hide_progress){