فهرست منبع

调整播放器

chendeben 1 سال پیش
والد
کامیت
fe31f140f2
2فایلهای تغییر یافته به همراه25 افزوده شده و 14 حذف شده
  1. 6 2
      entry/src/main/ets/entryability/EntryAbility.ets
  2. 19 12
      entry/src/main/ets/view/LocalMusic.ets

+ 6 - 2
entry/src/main/ets/entryability/EntryAbility.ets

@@ -39,7 +39,7 @@ export default class EntryAbility extends UIAbility {
     // UI上下文对象,用于获取窗口信息
     private uiContext?: UIContext;
     // private awareness: smartMobilityCommon.SmartMobilityAwareness = smartMobilityCommon.getSmartMobilityAwareness();
-    private awareness: smartMobilityCommon.SmartMobilityAwareness|undefined = canIUse("SystemCapability.SmartOptimizer.SmartMobility")?smartMobilityCommon.getSmartMobilityAwareness():undefined;
+    private awareness: smartMobilityCommon.SmartMobilityAwareness|undefined = canIUse("SystemCapability.CarService.DistributedEngine")?smartMobilityCommon.getSmartMobilityAwareness():undefined;
 
     /**
      * 窗口尺寸变化回调函数
@@ -278,9 +278,13 @@ export default class EntryAbility extends UIAbility {
 
 
     getHiCarStatus(){
+        if (!this.awareness){
+            this.awareness=canIUse("SystemCapability.CarService.DistributedEngine")?smartMobilityCommon.getSmartMobilityAwareness():undefined;
+        }
+        console.log('enter getHiCarStatus,awareness:'+JSON.stringify(this.awareness));
         if(this.awareness){
             // this.awareness = smartMobilityCommon.getSmartMobilityAwareness();
-
+            console.log('enter awareness');
             // 业务类型
             let types: smartMobilityCommon.SmartMobilityType[] = [smartMobilityCommon.SmartMobilityType.HICAR];
             // 获取出行业务连接状态

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

@@ -6015,6 +6015,10 @@ export struct LocalMusic {
   }
 
   //是否是Pura X外屏,或者小屏幕,手机横屏
+  /**
+   * 是否是Pura X外屏,或者小屏幕,手机横屏
+   * @returns
+   */
   isCoverOpacity() {
     if (this.isPuraWP()) {
       return true
@@ -6042,6 +6046,9 @@ export struct LocalMusic {
     LogUtil.info('hicar isPhoneLan height= ' + this.windowHeight);
     LogUtil.info(`twocold  hicarWindow size: ${this.windowWidth}x${this.windowHeight}, this.isHiCarStatus: ${this.isHiCarStatus}`);
     LogUtil.info(`twocold  hicar Window size: ${this.windowWidth}x${this.windowHeight}, isHiCarSmall: ${this.isHiCarSmall()}`);
+    if (this.isHiCarKuanBianPing()) {
+      return true
+    }
     if (this.isHiCar()) {
       return false
     }
@@ -6064,14 +6071,14 @@ export struct LocalMusic {
     ];
     const currentRatio: number = this.windowWidth / this.windowHeight;
     const RATIO_TOLERANCE: number = 0.18; // 宽高比容差
-    LogUtil.info('twocold currentRatio = ' + currentRatio)
+    LogUtil.info('twocold isHiCarKuanBianPing 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))
+      LogUtil.info('twocold isHiCarKuanBianPing hiCarRatio= ' + hiCarRatio.ratio)
+      LogUtil.info('twocold isHiCarKuanBianPing 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.isHiCar();
+        return true;
       }
     }
 
@@ -6088,18 +6095,18 @@ export struct LocalMusic {
     const hiCarAspectRatios: HiCarAspectRatio[] = [
       { ratio: 800 / 480, name: "800x480" },
       { ratio: 1280 / 720, name: "1280x720" },
-      { ratio: 1920 / 720, name: "1920x720" },
     ];
     const currentRatio: number = this.windowWidth / this.windowHeight;
     const RATIO_TOLERANCE: number = 0.18; // 宽高比容差
-    LogUtil.info('twocold currentRatio = ' + currentRatio)
+    LogUtil.info('twocold isHiCarSmall 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))
+      LogUtil.info('twocold isHiCarSmall hiCarRatio= ' + hiCarRatio.ratio)
+      LogUtil.info('twocold isHiCarSmall Math.abs(currentRatio - hiCarRatio.ratio)= ' + Math.abs(currentRatio - hiCarRatio.ratio))
+      LogUtil.info('twocold isHiCarSmall isHiCarStatus= ' + this.isHiCarStatus);
       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 this.isHiCarStatus;
       }
     }
 
@@ -7237,7 +7244,7 @@ export struct LocalMusic {
             })
 
         }
-        .padding({ right: 7,left:28 })
+        .padding({ right: 7,left:14 })
         Row(){
           Text(this.currentTime)
             .fontSize(10)
@@ -7249,7 +7256,7 @@ export struct LocalMusic {
             .fontColor(Color.White)
         }
         .justifyContent(FlexAlign.Start)
-        .padding({ right: 18,left:35 })
+        .padding({ right: 18,left:36 })
       }
 
 
@@ -7603,7 +7610,7 @@ export struct LocalMusic {
             this.musicNameInfo(false)
           } else {
             Image(StrUtil.isEmpty(this.cover) ? this.imageLabel : this.cover)
-              .height(this.isHiCarSmall()?(this.isHiCarKuanBianPing()?140:220):(this.isCoverOpacity() ? 250 : this.isCoverRectangle ? 320 : 162))
+              .height(this.isHiCarSmall()?(this.isHiCarKuanBianPing()?140:px2vp(this.windowHeight)*0.38):(this.isCoverOpacity() ? 250 : this.isCoverRectangle ? 320 : 162))
               .objectFit(this.isCoverRectangle ? ImageFit.Contain : ImageFit.Auto)
               .alt(this.imageLabel)
               .margin({ right: 20, left: 20 })