Forráskód Böngészése

增加设置的音量优化

onecold 11 hónapja
szülő
commit
636770f7de

+ 34 - 0
entry/src/main/ets/pages/SettingPage.ets

@@ -110,6 +110,7 @@ export struct SettingPage {
   @State isSameTimePlay: boolean = false //是否和其他app同时播放
   @State isCoverRectangle: boolean = false
   @State isSavePlayMode: boolean = true
+  @State volumeSmall: boolean = false
   @State isCoverTop: boolean = true
   @State isCoverTopBig: boolean = false//顶部大封面部分手机显示会和播放控制页重叠
   @State isSwipe: boolean = false //listItem的左滑开关
@@ -238,6 +239,7 @@ export struct SettingPage {
     this.isSwipe = PreferencesUtil.getBooleanSync(SettingPage.IS_SWIPE, true)
     this.is_auto_hide_progress = PreferencesUtil.getBooleanSync(SettingPage.IS_AUTO_HIDE_PROGRESS, false)
     this.openSkipSongAnimate = PreferencesUtil.getBooleanSync(SettingPage.OPEN_SKIPSONG_ANIMATE, true)
+    this.volumeSmall = PreferencesUtil.getBooleanSync('volumeSmall', false)
     // 只用 themeMode 控制主题
     this.themeMode = PreferencesUtil.getNumberSync(SettingPage.THEME_MODE, 0)
     this.applyThemeMode(this.themeMode)
@@ -1177,6 +1179,38 @@ export struct SettingPage {
             .height(55)
             .clickEffect({ level: ClickEffectLevel.HEAVY })
 
+            Line().width('100%').height(0.3).backgroundColor($r('app.color.index_tab_unselected_font_color'))
+            // 保存播放模式
+            Row() {
+              SymbolGlyph($r('sys.symbol.speaker'))
+                .fontSize(20)
+                .fontColor([this.themeColor])
+                .alignSelf(ItemAlign.Center)
+                .margin({ left: 15 })
+              Text('音量优化')
+                .margin({ left: 8 })
+                .fontSize(15)
+                .fontColor(Color.Gray)
+                .fontWeight(480)
+                .layoutWeight(1)
+              Toggle({ type: ToggleType.Switch, isOn: this.volumeSmall })
+                .selectedColor(this.themeColor)
+                .clickEffect({level:ClickEffectLevel.LIGHT, scale: 0.5})
+                .switchPointColor(Color.White)
+                .margin({ right: 18 })
+                .onChange((checked: boolean) => {
+                  this.volumeSmall = checked;
+                  if(this.volumeSmall){
+                    ToastUtil.showToast('打开音量优化会比平时音量声音低些')
+                  }
+                  PreferencesUtil.put('volumeSmall', this.volumeSmall)
+                })
+                .width(50)
+                .height(30);
+            }
+            .height(55)
+            .clickEffect({ level: ClickEffectLevel.HEAVY })
+
             Line().width('100%').height(0.3).backgroundColor($r('app.color.index_tab_unselected_font_color'))
             // 保存播放模式
             Row() {

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

@@ -628,6 +628,12 @@ export struct LocalMusic {
     this.volume = PreferencesUtil.getNumberSync('DefalutVolume', this.volume)
     this.isSwipe = PreferencesUtil.getBooleanSync(SettingPage.IS_SWIPE, false)
     this.openSkipSongAnimate = PreferencesUtil.getBooleanSync(SettingPage.OPEN_SKIPSONG_ANIMATE, true)
+    this.volumeSmall = PreferencesUtil.getBooleanSync('volumeSmall', false)
+    if(this.volumeSmall){
+      this.volume = 0.5
+    }else{
+      this.volume = 1
+    }
     //如果是hicar连接状态,这些都是false
     if(this.isHiCar()){
       this.isShowTitleBar = false//不显示导航栏
@@ -3868,6 +3874,7 @@ export struct LocalMusic {
               .onClick(() => {
                 this.isMultiSelect =  !this.isMultiSelect
                 this.longItemFilePath = ''
+                this.selectedFiles.push(item)
               })
             MenuItem({
               symbolStartIcon: new SymbolGlyphModifier($r('sys.symbol.rename')),
@@ -4772,11 +4779,7 @@ export struct LocalMusic {
         this.yearStr,this.genreStr,this.trackStr,this.albumArtistStr,this.composerStr, this.lyricistStr,this.commentStr,this.discStr,
         (success: boolean, error?: string) => {
           // this.isShowEdit = false
-          if(this.isGridMusic){
-            this.longItemFilePath =''
-          }else{
-            this.isShowEdit = false
-          }
+
           if (success) {
             console.log(" onecold 编辑信息成功,数据库已同步");
             ToastUtil.showToast('内嵌音乐标签成功')
@@ -4812,7 +4815,9 @@ export struct LocalMusic {
       ToastUtil.showToast('内嵌音乐标签失败')
       console.log('onecold 内嵌音乐标签失败');
     }
-
+    this.longItemFilePath = ''
+    this.tempLyricContent = ''
+    this.isShowEdit = false
 
 
 
@@ -6691,7 +6696,8 @@ export struct LocalMusic {
   private positionX: number = PlayConstants.POSITION_X;
   private positionY: number = PlayConstants.POSITION_Y;
   private windowClass: window.Window = globalThis.windowClass
-  @State volume: number = 0.3;
+  @State volume: number = 0.5;
+  @State volumeSmall: boolean = false
   @State volumeShow: boolean = PlayConstants.VOLUME_SHOW;
   @State bright: number = PlayConstants.BRIGHT;
   @State brightShow: boolean = PlayConstants.BRIGHT_SHOW;
@@ -10156,11 +10162,16 @@ export struct LocalMusic {
     //初始化配置
     this.mIjkMediaPlayer.native_setup();
     // 初始化配置后需要重新设置音频流音量,否则音量为默认值1.0 针对dsf格式设置最大值1.0
-    if(this.videoUrl.toLowerCase().endsWith('.dsf')){
-      this.mIjkMediaPlayer.setVolume('1', '1');
+    if(this.volumeSmall){
+      if(this.videoUrl.toLowerCase().endsWith('.dsf')){
+        this.mIjkMediaPlayer.setVolume('1', '1');
+      }else{
+        this.mIjkMediaPlayer.setVolume(this.volume.toString(), this.volume.toString());
+      }
     }else{
       this.mIjkMediaPlayer.setVolume(this.volume.toString(), this.volume.toString());
     }
+
     //设置视频源
     this.mIjkMediaPlayer.setDataSource(url);
     //设置视频源http请求头