Browse Source

针对hicar进行播放器页面调整

onecold 1 năm trước cách đây
mục cha
commit
1cb27e3bba
1 tập tin đã thay đổi với 47 bổ sung11 xóa
  1. 47 11
      entry/src/main/ets/view/LocalMusic.ets

+ 47 - 11
entry/src/main/ets/view/LocalMusic.ets

@@ -607,8 +607,11 @@ export struct LocalMusic {
     //如果是hicar连接状态,这些都是false
     if(this.isHiCarStatus){
       this.isShowTitleBar = false//不显示导航栏
-      this.isShowHeader = false//二级菜单不显示头部
-      this.isGridMusic= false//用list不用网格
+      if(this.isHiCarSmall()){
+        this.isShowHeader = false//二级菜单不显示头部
+        this.isGridMusic= false//用list不用网格
+      }
+      this.isShowPlayPageBack = true //播放页返回键要显示,方便驾驶员操作
     }
     if (this.isSavePlayMode) {
       this.playType = PreferencesUtil.getNumberSync('musicPlayType', 0)
@@ -5647,7 +5650,8 @@ export struct LocalMusic {
     // LogUtil.info('twocold this.currentWidthBreakpoint = '+this.currentWidthBreakpoint)
     LogUtil.info('hicar isPhoneLan width= ' + this.windowWidth);
     LogUtil.info('hicar isPhoneLan height= ' + this.windowHeight);
-    LogUtil.info(`Heanup Window size: ${this.windowWidth}x${this.windowHeight}, isHiCar: ${this.isHiCar()}`);
+    LogUtil.info(`twocold  hicarWindow size: ${this.windowWidth}x${this.windowHeight}, isHiCar: ${this.isHiCar()}`);
+    LogUtil.info(`twocold  hicar Window size: ${this.windowWidth}x${this.windowHeight}, isHiCarSmall: ${this.isHiCarSmall()}`);
     if (this.isHiCar()) {
       return false
     }
@@ -5670,6 +5674,34 @@ export struct LocalMusic {
   }
 
   //是不是hicar的屏幕分辨率
+  isHiCarSmall() {
+    if(this.windowWidth>2400&&this.windowHeight>=1300)//大屏幕可以Grid
+      return false
+    if(this.windowWidth>1800&&this.windowHeight>=1200)//大屏幕可以Grid
+      return false
+
+
+    const hiCarAspectRatios: HiCarAspectRatio[] = [
+      { ratio: 800 / 480, name: "800x480" },
+      { ratio: 1280 / 720, name: "1280x720" },
+    ];
+    const currentRatio: number = this.windowWidth / this.windowHeight;
+    const RATIO_TOLERANCE: number = 0.18; // 宽高比容差
+    LogUtil.info('twocold currentRatio = ' + currentRatio)
+
+    for (const hiCarRatio of hiCarAspectRatios) {
+      LogUtil.info('twocold hiCarRatio= ' + hiCarRatio.ratio)
+      LogUtil.info('twocold Math.abs(currentRatio - hiCarRatio.ratio)= ' + Math.abs(currentRatio - hiCarRatio.ratio))
+      if (Math.abs(currentRatio - hiCarRatio.ratio) <= RATIO_TOLERANCE) {
+        // LogUtil.info(`HiCar detected: ${hiCarRatio.name}, actual: ${this.windowWidth}x${this.windowHeight}`);
+        return true&&this.isHiCarStatus;
+      }
+    }
+
+    return false;
+  }
+
+
   isHiCar() {
 
     const hiCarAspectRatios: HiCarAspectRatio[] = [
@@ -5681,23 +5713,27 @@ export struct LocalMusic {
       { ratio: 1920 / 1080, name: "1920x1080" }
     ];
     const currentRatio: number = this.windowWidth / this.windowHeight;
-    const RATIO_TOLERANCE: number = 0.1; // 宽高比容差
+    const RATIO_TOLERANCE: number = 0.18; // 宽高比容差
+    LogUtil.info('twocold currentRatio = ' + currentRatio)
 
     for (const hiCarRatio of hiCarAspectRatios) {
+      LogUtil.info('twocold hiCarRatio= ' + hiCarRatio.ratio)
+      LogUtil.info('twocold Math.abs(currentRatio - hiCarRatio.ratio)= ' + Math.abs(currentRatio - hiCarRatio.ratio))
       if (Math.abs(currentRatio - hiCarRatio.ratio) <= RATIO_TOLERANCE) {
-        LogUtil.info(`HiCar detected: ${hiCarRatio.name}, actual: ${this.windowWidth}x${this.windowHeight}`);
-        return true;
+        // LogUtil.info(`HiCar detected: ${hiCarRatio.name}, actual: ${this.windowWidth}x${this.windowHeight}`);
+        return true&&this.isHiCarStatus;
       }
     }
 
     return false;
   }
 
+
   //是不是正常的手机竖屏
   isPhonePortrait() {
-    LogUtil.info('twocold this.currentHeightBreakpoint = ' + this.currentHeightBreakpoint)
-    LogUtil.info('twocold this.currentWidthBreakpoint = ' + this.currentWidthBreakpoint)
-    LogUtil.info('Heanup 当前设备类型:' + DeviceUtil.getDeviceType())
+    // LogUtil.info('twocold this.currentHeightBreakpoint = ' + this.currentHeightBreakpoint)
+    // LogUtil.info('twocold this.currentWidthBreakpoint = ' + this.currentWidthBreakpoint)
+    // LogUtil.info('Heanup 当前设备类型:' + DeviceUtil.getDeviceType())
     if (DeviceUtil.getDeviceType() === resourceManager.DeviceType.DEVICE_TYPE_PHONE
       && this.currentHeightBreakpoint == HeightBreakpoint.HEIGHT_LG
       && this.currentWidthBreakpoint == WidthBreakpoint.WIDTH_SM) { //如果是手机横屏,返回false
@@ -6638,7 +6674,7 @@ export struct LocalMusic {
 
 
     }
-    .position({ bottom: this.isCoverOpacity() ? 55 : 100 }) // 将  固定在底部
+    .position({ bottom: this.isHiCarSmall()?50:(this.isCoverOpacity() ? 55 : 100) }) // 将  固定在底部
 
   }
 
@@ -6970,7 +7006,7 @@ export struct LocalMusic {
             this.musicNameInfo(false)
           } else {
             Image(StrUtil.isEmpty(this.cover) ? this.imageLabel : this.cover)
-              .height(this.isCoverOpacity() ? 250 : this.isCoverRectangle ? 320 : 162)
+              .height(this.isHiCarSmall()?220:(this.isCoverOpacity() ? 250 : this.isCoverRectangle ? 320 : 162))
               .objectFit(this.isCoverRectangle ? ImageFit.Contain : ImageFit.Auto)
               .alt(this.imageLabel)
               .margin({ right: 20, left: 20 })