音乐播放器声音调节优化
authorluozheng <1732036298@qq.com>
Sat, 10 Aug 2024 08:53:40 +0000 (16:53 +0800)
committerluozheng <1732036298@qq.com>
Sat, 10 Aug 2024 08:53:40 +0000 (16:53 +0800)
code/sdk/application/wearable/fd230app/nativeui/main/include/VolumeSettingPresenter.h
code/sdk/application/wearable/fd230app/nativeui/main/include/VolumeSettingView.h
code/sdk/application/wearable/fd230app/nativeui/main/src/VolumeSettingPresenter.cpp

index 063bf68..5bdd51a 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: luozheng 1732036298@qq.com
  * @Date: 2024-08-05 15:20:02
  * @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-08-06 16:30:51
+ * @LastEditTime: 2024-08-10 14:31:56
  * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/main/include/VolumeSettingPresenter.h
  */
 
@@ -24,8 +24,8 @@ namespace OHOS {
 #define VOLUME_VIEW "volumeview"
 
 typedef enum : uint16_t {
-    VOLUMEPHONE = 1,
-    VOLUMEPLAYERS = 3,
+    VOLUMEPHONE = 1,  //声音系数为:手机
+    VOLUMEPLAYERS = 3,//声音系数为音乐播放器
     VOLUMEPHONENOTIFY = 4,
 } VolumeFactor;
 
index bccd376..893074c 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: luozheng 1732036298@qq.com
  * @Date: 2024-08-05 15:20:02
  * @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-08-07 15:25:29
+ * @LastEditTime: 2024-08-10 14:29:29
  * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/main/include/VolumeSettingView.h
  */
 
@@ -26,7 +26,7 @@ class VolumeSettingView : public UIViewGroup {
 public:
     VolumeSettingView();
     ~VolumeSettingView();
-    int16_t sounding{0};
+    int16_t sounding{0}; //音量值
 
     UISlider *GetProgress(void);
     bool SetUpVolume(void);
index b19428c..022e16e 100644 (file)
@@ -18,6 +18,7 @@
 #include "notification_manager.h"
 #include "BluetoothHeadsetEvent.h"
 #include "bts_avrcp_controller.h"
+#include "ConfigModel.h"
 
 namespace OHOS {
 
@@ -119,10 +120,12 @@ void VolumeSliderEventListener::ChangeVolume(VolumeChangeStatus status)
 
     if (playerCoefficients == VOLUMEPLAYERS) {
         BtAndLocalVolumeSet(volumeSettingView->sounding);
+        ConfigModel::GetInstance()->SetSystemVolume(volumeSettingView->sounding);/*将设置的音量保存到系统音量*/
     }
     if (playerCoefficients == VOLUMEPHONE || playerCoefficients == VOLUMEPHONENOTIFY) {
         unsigned char volumeValue = (unsigned char) ((double) (volumeSettingView->sounding * CALL_VOLUME_MAX) / (VOLUME_MAX - VOLUME_MIN)); // 音量转换
         SetSpeakerVolume(volumeValue);
+        ConfigModel::GetInstance()->SetCallVolume(volumeSettingView->sounding);/*将设置的音量保存到通话音量*/
     }
 }
 
@@ -152,7 +155,7 @@ void VolumeSliderEventListener::SetPlayerCoefficients(int16_t value)
 void VolumeSliderEventListener::OnChange(int32_t value)
 {
     WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OnChange %d", value);
-    ChangeVolume(VOLUMEDRAG);
+    // ChangeVolume(VOLUMEDRAG);
 }
 
 bool VolumeSliderEventListener::OnDrag(UIView& view, const DragEvent& event)