Quellcode durchsuchen

Merge branch 'master' of https://git.ss5.xyz/onecold/TTMusic

onecold vor 4 Monaten
Ursprung
Commit
1461ff8225

+ 69 - 23
entry/src/main/ets/pages/NewIndex.ets

@@ -65,6 +65,11 @@ import { hdsEffect } from '@kit.UIDesignKit';
 import {
   resolveMiniPlayerMorphTarget,
 } from '../common/util/PlayerDismissHelper';
+import {
+  MiniPlayerOrbTapAction,
+  resolveMiniPlayerOrbTapAction,
+  shouldTriggerMiniPlayerOrbSingleTap
+} from '../common/util/MiniPlayerOrbTapHelper';
 
 // import { FFmpeg, FFProgressMessageParser } from '@sj/ffmpeg';
 
@@ -203,6 +208,8 @@ struct NewIndex {
   private miniPlayerModeAnimationTimer: number = -1;
   private miniPlayerModeSettleTimer: number = -1;
   private miniPlayerModeCompleteTimer: number = -1;
+  private miniPlayerOrbTapTimer: number = -1;
+  private lastMiniPlayerOrbTapAt: number = 0;
   private readonly miniPlayerMorphDuration: number = 240;
   private readonly miniPlayerDotDuration: number = 190;
   private readonly miniPlayerShakeFirstDuration: number = 110;
@@ -210,6 +217,7 @@ struct NewIndex {
   private readonly miniPlayerShakeSettleDuration: number = 170;
   private readonly miniPlayerModeDuration: number = 360;
   private readonly miniPlayerModeBounceDuration: number = 220;
+  private readonly miniPlayerOrbDoubleTapWindowMs: number = 240;
   private isMiniPlayerModeTransitioning: boolean = false;
   //当胶囊按钮的选择发生变化时调用此函数
   tabSelectedIndexesChanged() {
@@ -541,28 +549,27 @@ struct NewIndex {
     this.currentSongListName = ''
     this.modeType = 0
     this.tabSelectedIndexes = [0]
-    setTimeout(()=>{
-      if(this.defalut_home_type==1){
-        this.mType = 0
-        this.modeType = 1
-      }else if(this.defalut_home_type==2){//如果是网盘的话
-        this.tabSelectedIndexes = [2]
-        if (configuredAccount) {
-          this.selectedAccount = configuredAccount
-        }
-        this.mType = this.isRemoteMusicAccount(configuredAccount) ? 7 : 6
-      }else if(this.defalut_home_type==3){
-        this.mType = 0
-        this.modeType = 2
-      }else if(this.defalut_home_type==4){
-        this.mType = 0
-        this.modeType = 3
-      }else if(this.defalut_home_type==5){
-        this.enterFindPage()
-      } else {
-        this.mType = 0
+    this.mType = 0
+
+    if(this.defalut_home_type==1){
+      this.mType = 0
+      this.modeType = 1
+    }else if(this.defalut_home_type==2){//如果是网盘的话
+      this.tabSelectedIndexes = [2]
+      if (configuredAccount) {
+        this.selectedAccount = configuredAccount
       }
-    },150)
+      this.mType = this.isRemoteMusicAccount(configuredAccount) ? 7 : 6
+    }else if(this.defalut_home_type==3){
+      this.mType = 0
+      this.modeType = 2
+    }else if(this.defalut_home_type==4){
+      this.mType = 0
+      this.modeType = 3
+    }else if(this.defalut_home_type==5){
+      this.enterFindPage()
+    }
+
 
   }
 
@@ -642,9 +649,48 @@ struct NewIndex {
       clearTimeout(this.miniPlayerModeCompleteTimer)
       this.miniPlayerModeCompleteTimer = -1
     }
+    this.clearMiniPlayerOrbTapTimer()
     this.isMiniPlayerModeTransitioning = false
   }
 
+  private clearMiniPlayerOrbTapTimer(): void {
+    if (this.miniPlayerOrbTapTimer >= 0) {
+      clearTimeout(this.miniPlayerOrbTapTimer)
+      this.miniPlayerOrbTapTimer = -1
+    }
+    this.lastMiniPlayerOrbTapAt = 0
+  }
+
+  private scheduleMiniPlayerOrbSingleTap(triggerAt: number): void {
+    this.clearMiniPlayerOrbTapTimer()
+    this.lastMiniPlayerOrbTapAt = triggerAt
+    this.miniPlayerOrbTapTimer = setTimeout(() => {
+      this.miniPlayerOrbTapTimer = -1
+      if (!shouldTriggerMiniPlayerOrbSingleTap(this.lastMiniPlayerOrbTapAt, Date.now(),
+        this.miniPlayerOrbDoubleTapWindowMs)) {
+        return
+      }
+      this.lastMiniPlayerOrbTapAt = 0
+      this.expandMiniPlayerFromOrb()
+    }, this.miniPlayerOrbDoubleTapWindowMs)
+  }
+
+  private handleMiniPlayerOrbTap(): void {
+    const now = Date.now()
+    const action = resolveMiniPlayerOrbTapAction(
+      this.miniPlayerOrbTapTimer >= 0,
+      this.lastMiniPlayerOrbTapAt,
+      now,
+      this.miniPlayerOrbDoubleTapWindowMs
+    )
+    if (action === MiniPlayerOrbTapAction.TRIGGER_DOUBLE_TAP) {
+      this.clearMiniPlayerOrbTapTimer()
+      this.setShowPlayTrue()
+      return
+    }
+    this.scheduleMiniPlayerOrbSingleTap(now)
+  }
+
   // 窗口尺寸、断点或显示设备切换时,重新同步播放条表面尺寸。
   // 这样从手机态切到 HiCar 横屏后,surface 会立即按当前显示环境重新拉伸。
   private onMiniPlayerLayoutContextChange(): void {
@@ -982,7 +1028,7 @@ struct NewIndex {
       }
       .width('100%')
       .height('100%')
-      .visibility(this.mType === 0 || this.isShowPlay ? Visibility.Visible : Visibility.None)
+      .visibility(this.mType === 0 || this.isShowPlay ? Visibility.Visible : Visibility.Hidden)
       .zIndex(this.isShowPlay ? 100 : 0)
       // 本地音乐内容区
       if(this.mType === 1 ){
@@ -1234,7 +1280,7 @@ struct NewIndex {
       .scale({ x: this.miniPlayerOrbScale, y: this.miniPlayerOrbScale, centerX: '50%', centerY: '50%' })
       .translate({ x: this.miniPlayerOrbTranslateX })
       .onClick((): void => {
-        this.expandMiniPlayerFromOrb()
+        this.handleMiniPlayerOrbTap()
       })
   }
 

+ 3 - 0
entry/src/main/ets/view/FindView.ets

@@ -2663,6 +2663,7 @@ export struct FindView {
         textColor: $r('app.color.text_color'),
         buttonColor: this.getCardBackgroundColor()
       })
+        .opacity(0.8)
         .layoutWeight(1)
         .onClick(() => {
           void this.handleActionButtonTap('top')
@@ -2675,6 +2676,7 @@ export struct FindView {
         textColor: $r('app.color.text_color'),
         buttonColor: this.getCardBackgroundColor()
       })
+        .opacity(0.8)
         .layoutWeight(1)
         .onClick(() => {
           void this.handleActionButtonTap('local-random')
@@ -2687,6 +2689,7 @@ export struct FindView {
         textColor: $r('app.color.text_color'),
         buttonColor: this.getCardBackgroundColor()
       })
+        .opacity(0.8)
         .layoutWeight(1)
         .onClick(() => {
           void this.handleActionButtonTap('cloud-random')

+ 22 - 12
entry/src/main/ets/view/LocalMusic.ets

@@ -137,7 +137,12 @@ import {
   WebDavMetadataUpdatePayload,
   isDaoLiYuType
 } from '../common/util/RemotePlayerUtil';
-import { PlaylistPlayRequest, consumePendingPlaylistPlay, clearPendingPlaylistPlay } from '../common/util/PlaylistPlayRequestStore';
+import {
+  PlaylistPlayRequest,
+  consumePendingPlaylistPlay,
+  clearPendingPlaylistPlay,
+  setPlaylistPlayConsumerReady
+} from '../common/util/PlaylistPlayRequestStore';
 
 import { HSBColorPicker, HSBColorPickerLayout } from '@keke/color-picker'
 import app from '@system.app';
@@ -1093,6 +1098,7 @@ export struct LocalMusic {
 
       Logger.error('heanup eventPlaylistPlay: 接收到无效的数据结构')
     });
+    setPlaylistPlayConsumerReady(true);
     Promise.resolve().then(async (): Promise<void> => {
       const pendingPlaylistRequest = consumePendingPlaylistPlay();
       if (!pendingPlaylistRequest) {
@@ -1651,16 +1657,16 @@ export struct LocalMusic {
   makeWorker() {
     setTimeout(() => {
       if (PreferencesUtil.getBooleanSync('isFirstApp', true)) {
-        // ToastUtil.showToast('请到文件扫描页面导入音乐!')
+        ToastUtil.showToast('请到文件扫描页面导入音乐!')
         //发送worker通知扫描文件入库,用户反馈4000多首用这个方法扫描会闪退。
-        workerInstance.postMessage({
-          code: 1,
-          data1: this.context,
-          data2: this.rootPath,
-          data3: this.lockPath,
-          data4: PreferencesUtil.getStringSync('COVER_API', ''),
-          data5: PreferencesUtil.getBooleanSync('autoParseMusicName', true),
-        });
+        // workerInstance.postMessage({
+        //   code: 1,
+        //   data1: this.context,
+        //   data2: this.rootPath,
+        //   data3: this.lockPath,
+        //   data4: PreferencesUtil.getStringSync('COVER_API', ''),
+        //   data5: PreferencesUtil.getBooleanSync('autoParseMusicName', true),
+        // });
         PreferencesUtil.putSync('isFirstApp', false)
       } else {
 
@@ -2282,6 +2288,7 @@ export struct LocalMusic {
     this.knockController?.immersiveDisableListening();
     this.curIndex = 0
     this.isAppForeground = false;
+    setPlaylistPlayConsumerReady(false);
     emitter.off(EventConstants.EVENT_AUDIO_OPEN);
     emitter.off(EventConstants.EVENT_SCAN_UPDATE);
     emitter.off(EventConstants.EVENT_SWIPE_BACK_UPDATE);
@@ -8096,7 +8103,9 @@ export struct LocalMusic {
           // this.showCueSheet = !this.showCueSheet
           return
         }
+        console.info('kkMusic doPlay this.CONTROL_PlayStatus ='+this.CONTROL_PlayStatus )
         if (this.CONTROL_PlayStatus !== PlayStatus.INIT) {
+          console.info('kkMusic doPlay stop =' )
           this.stop();
         }
 
@@ -19267,19 +19276,20 @@ export struct LocalMusic {
 
   private stop() {
     this.audioInterruptResumePending = false;
+    this.savePlaybackPosition();
     this.clearInitialSeekGuardTimer();
     this.waitInitialSeekBeforeStart = false;
     this.pendingMemorySeekPosition = 0;
     this.isPlayerLoading = false;
-    this.savePlaybackPosition();
+
     this.CONTROL_PlayStatus = PlayStatus.INIT;
     this.mIjkMediaPlayer.stop();
     this.mIjkMediaPlayer.release();
+    console.info('kkMusic stop  ..this.CONTROL_PlayStatus '+this.CONTROL_PlayStatus  )
     this.stopProgressTask();
     this.updateSessionPlayState(false)
     this.playChange()
     this.watchStatus();
-
   }
 
   //保持记忆播放功能