Sfoglia il codice sorgente

在首页初始化时读取媒体库缓存数据前50条缓存

onecold 10 mesi fa
parent
commit
fa9665a0db

+ 11 - 0
entry/src/main/ets/pages/AboutPage.ets

@@ -204,6 +204,17 @@ export struct AboutPage{
               Utility.gotoMarket(getContext(this) as common.UIAbilityContext, 'com.xgplayer.ttmusic.tags')
             })
 
+          Button('视频播放器', { type: ButtonType.Capsule, stateEffect: false })
+            .width(this.currentBreakpoint !== BreakpointTypeEnum.SM?'25%':'60%')
+            .height(55)
+            .margin({top:10,bottom:10})
+            .clickEffect({level:ClickEffectLevel.LIGHT, scale: 0.7})
+            .stateEffect(true)
+            .backgroundColor(this.themeColor)
+            .onClick(()=>{
+              Utility.gotoMarket(getContext(this) as common.UIAbilityContext, 'com.kuaiyao.kdb.hm')
+            })
+
           Button('粉丝QQ群', { type: ButtonType.Capsule, stateEffect: false })
             .width(this.currentBreakpoint !== BreakpointTypeEnum.SM?'25%':'60%')
             .height(55)

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

@@ -499,9 +499,21 @@ export struct LocalMusic {
     })
     this.packName = AppUtil.getBundleName()
     this.loadCacheFromStorage(); // 加载缓存
+    // 在首页初始化时读取媒体库缓存数据
+    let cachedListStr:string = PreferencesUtil.getStringSync('mediaKuList',  '[]');
+    let cachedList = JSON.parse(cachedListStr) as Array<VideoItem>;
+    if(ArrayUtil.isNotEmpty(cachedList)){
+      this.mediaKuList = cachedList
+      if(this.modeType==1){
+        this.updateListData(this.mediaKuList)
+      }
+    }
 
     this.mkDownLoadDir()
 
+
+
+
     let eventMusic: emitter.InnerEvent = { eventId: 2 }
     // 监听广播事件(打开其他应用处理)
     emitter.on(eventMusic, (eventData: emitter.EventData) => {
@@ -777,6 +789,14 @@ export struct LocalMusic {
             this.updateListData(this.mediaKuList)
           }
           PreferencesUtil.putSync('mediaKuCount', this.mediaKuList.length)
+          // 处理媒体库前50条记录,列表长度并存储到PreferencesUtil
+          if (ArrayUtil.isNotEmpty(this.mediaKuList)&&this.mediaKuList.length  > 50) {
+            // 只保存前50条记录到缓存中
+            let truncatedList = this.mediaKuList.slice(0,  50);
+            PreferencesUtil.putSync('mediaKuList',  JSON.stringify(truncatedList));
+          } else {
+            PreferencesUtil.putSync('mediaKuList',  JSON.stringify(this.mediaKuList));
+          }
           break;
         case 103: //收到查询艺术家列表
           this.artistMap = e.data.data1;
@@ -2491,6 +2511,7 @@ export struct LocalMusic {
           Text(item.name.startsWith('.') ? item.name.replace(/\./g, '') : item.name)
             .fontSize(this.twoFingerType == 1 ? 12 : this.twoFingerType == 2 ? 15 : 18)
             .maxLines(1)// .width('88%')
+            .textOverflow({ overflow: this.isLongNameRoLL?TextOverflow.MARQUEE:TextOverflow.Ellipsis })//超长滚动
             .animation({
               duration: 555,
               curve: 'ease-in-out',
@@ -10887,14 +10908,14 @@ export struct LocalMusic {
         if (position >= duration - this.jumpEndTime * 1000) {
           if(this.playType == 1){//跳过尾部如果是单曲循环就选择单曲循环
             this.CONTROL_PlayStatus = PlayStatus.INIT
-            that.startPlayOrResumePlay();
+            this.startPlayOrResumePlay();
           }else if (this.playType == 2) { //2:正常播放,单曲播完
 
-            that.showRePlay();
-            that.currentTime = that.stringForTime(this.mIjkMediaPlayer.getDuration());
-            that.progressValue = this.PROGRESS_MAX_VALUE;
-            that.slideEnable = false;
-            that.stop();
+            this.showRePlay();
+            this.currentTime = this.stringForTime(this.mIjkMediaPlayer.getDuration());
+            this.progressValue = this.PROGRESS_MAX_VALUE;
+            this.slideEnable = false;
+            this.stop();
             // ToastUtil.showToast('开始重新播放')
           }else{
             this.playNext()

+ 14 - 3
entry/src/main/ets/view/TagsContentCover.ets

@@ -2,7 +2,7 @@ import { common, ConfigurationConstant } from '@kit.AbilityKit';
 import { CommonConstants } from '../common/constants/CommonConstants';
 import { VideoItem } from '../viewmodel/VideoItem';
 import { LazyDataSource } from '../common/util/LazyDataSource';
-import { LogUtil, PreferencesUtil, StrUtil, ToastUtil } from '@pura/harmony-utils';
+import { AppUtil, LogUtil, PreferencesUtil, StrUtil, ToastUtil } from '@pura/harmony-utils';
 import fs from '@ohos.file.fs';
 import { changeMusicCover, findLocalCoverImage, getApiLyric, repairAudioMetadata,
   searchCover,
@@ -21,6 +21,7 @@ export struct TagsContentCover {
   @State isLyric:boolean = true
   @State isCover:boolean = true
   @Link isShowDrawer: boolean;
+  @State bundleName: string = ''
   @State dataSource: LazyDataSource<VideoItem> = new LazyDataSource([])
   @Prop selectedFiles: Array<VideoItem>
   @StorageProp('topRectHeight') topRectHeight: number = 0;
@@ -47,6 +48,7 @@ export struct TagsContentCover {
   }
 
   async aboutToAppear() {
+    this.bundleName = AppUtil.getBundleName()
     // 确保 selectedFiles 有默认值后再初始化 dataSource
     if (this.selectedFiles && this.selectedFiles.length > 0) {
       this.dataSource = new LazyDataSource(this.selectedFiles)
@@ -236,7 +238,7 @@ export struct TagsContentCover {
       autoCancel: false,
       backCancel: true,
       contentBuilder: () => {
-        this.customVipBuilder("该功能需开通会员,非常感谢您的支持!")
+        this.customVipBuilder("该功能限时免费,麻烦到市场给个五星好评。非常感谢您的支持!")
       },
       buttons: [],
     })
@@ -260,6 +262,11 @@ export struct TagsContentCover {
           .margin({ left: 6 })
           .onClick(() => {
             DialogHelper.closeDialog('vip');
+            Utility.gotoMarket(getContext(this) as common.UIAbilityContext, this.bundleName)
+            setTimeout(()=>{
+              PreferencesUtil.putSync('IS_HAO_PING',true)
+            },10000)
+
           })
       }
     }
@@ -287,7 +294,11 @@ export struct TagsContentCover {
       ToastUtil.showToast('请到设置界面配置歌词Api')
       return
     }
-    if (!Utility.isNoble()) {
+    // if (!Utility.isNoble()) {
+    //   this.showVipDialog();
+    //   return;
+    // }
+    if (!PreferencesUtil.getBooleanSync('IS_HAO_PING', false)) {
       this.showVipDialog();
       return;
     }