1.添加APP在调节系统音量时候若当前界面在音乐的的声音调节视图则ui同步显示设置的音量值。
authorluozheng <1732036298@qq.com>
Wed, 18 Sep 2024 12:39:01 +0000 (20:39 +0800)
committerluozheng <1732036298@qq.com>
Wed, 18 Sep 2024 12:39:01 +0000 (20:39 +0800)
2.解决音乐从本地音乐切换到手机音乐在切换到本地音乐切换不回来bug

code/sdk/application/wearable/fd230app/nativeui/phoneservice/src/PhoneService.cpp
code/sdk/application/wearable/fd230app/nativeui/player/include/PlayersView.h
code/sdk/application/wearable/fd230app/nativeui/player/src/MusicPlayerSourceView.cpp
code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersModel.cpp
code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersView.cpp
code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationModel.cpp

index 834f284..87fbc47 100644 (file)
@@ -1884,34 +1884,34 @@ unsigned char GetCallCurrVolume(void)
 {
     if(OHOS::CallerLogModel::GetInstance()->GetCallSource() == OHOS::CallerLogModel::CallSourceCat1)
     {
-         int32_t volume = PhoneCAT1AudioGetVolume();
-        int32_t minVolume = PhoneAudioGetCAT1MinVolume();
-        int32_t maxVolume = PhoneAudioGetCAT1MAXVolume();
-        // unsigned char hfpVolume = (unsigned char)((volume * CALL_VOLUME_MAX) / (maxVolume - minVolume)); // 转换
-        unsigned char hfpVolume = volume;
+        // int32_t volume = PhoneCAT1AudioGetVolume();
+        // int32_t minVolume = PhoneAudioGetCAT1MinVolume();
+        // int32_t maxVolume = PhoneAudioGetCAT1MAXVolume();
+        // // unsigned char hfpVolume = (unsigned char)((volume * CALL_VOLUME_MAX) / (maxVolume - minVolume)); // 转换
 
 
-        if (volume != 0 && hfpVolume == 0) {
-            hfpVolume = 1;
-        }
-        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[GetCallCurrVolume] volume:%d, minVolume:%d, maxVolume:%d, hfpVolume:%d",
-            volume, minVolume, maxVolume, hfpVolume);
-        return hfpVolume;
+        // if (volume != 0 && hfpVolume == 0) {
+        //     hfpVolume = 1;
+        // }
+        // WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[GetCallCurrVolume] volume:%d, minVolume:%d, maxVolume:%d, hfpVolume:%d",
+        //     volume, minVolume, maxVolume, hfpVolume);
+        // return hfpVolume;
+        return PhoneCAT1AudioGetVolume();
     }
     else
     {
-        int32_t volume = PhoneAudioGetVolume();
-        int32_t minVolume = PhoneAudioGetMinVolume();
-        int32_t maxVolume = PhoneAudioGetMaxVolume();
-        // unsigned char hfpVolume = (unsigned char)((volume * CALL_VOLUME_MAX) / (maxVolume - minVolume)); // 转换
-        unsigned char hfpVolume = volume;
-
-        if (volume != 0 && hfpVolume == 0) {
-            hfpVolume = 1;
-        }
-        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[GetCallCurrVolume] volume:%d, minVolume:%d, maxVolume:%d, hfpVolume:%d",
-            volume, minVolume, maxVolume, hfpVolume);
-        return hfpVolume;
+        // int32_t volume = PhoneAudioGetVolume();
+        // int32_t minVolume = PhoneAudioGetMinVolume();
+        // int32_t maxVolume = PhoneAudioGetMaxVolume();
+        // // unsigned char hfpVolume = (unsigned char)((volume * CALL_VOLUME_MAX) / (maxVolume - minVolume)); // 转换
+
+        // // if (volume != 0 && hfpVolume == 0) {
+        // //     hfpVolume = 1;
+        // // }
+        // WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[GetCallCurrVolume] volume:%d, minVolume:%d, maxVolume:%d, hfpVolume:%d",
+        //     volume, minVolume, maxVolume, hfpVolume);
+        // return hfpVolume;
+        return PhoneAudioGetVolume();
 
     }
 
index 5e1304d..16ea701 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: luozheng 1732036298@qq.com\r
  * @Date: 2024-08-05 15:20:03\r
  * @LastEditors: luozheng 1732036298@qq.com\r
- * @LastEditTime: 2024-08-20 17:39:13\r
+ * @LastEditTime: 2024-09-18 19:13:53\r
  * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/player/include/PlayersView.h\r
  */\r
 \r
@@ -102,6 +102,8 @@ namespace OHOS
         void UpdatePlayerView(void);\r
         void UpdateMusicListStatus(void);\r
         void OnClickBackKeyToMainMusicPlayerView(void);\r
+        void StopCurPlayingMusic();\r
+        void UpdateVolumeValue(void);\r
 \r
         VolumeSettingView *GetVolumeSettingView();\r
         PlayerListDelSongView *GetPlayerListDelSongView();\r
index 97472c9..90fb346 100644 (file)
@@ -65,6 +65,7 @@ namespace OHOS
             {\r
                 PlayersModel::GetInstance()->SetMusicSource(true);\r
                 UpdateBluetoothHeadSetViewIsVisible();\r
+                playersView->StopCurPlayingMusic();\r
                 // 1.a2dp未连接,向手机发起a2dp连接\r
                 // 如果蓝牙没连接直接是跳转到蓝牙连接失败视图,连接了就有一个主动去连手机的a2dp过程,5秒超市\r
                 // if (!phonebluetoothcon)\r
index 9a99086..0cb06b5 100644 (file)
@@ -843,11 +843,7 @@ bool PlayersModel::GetCurrentMusicIsPlaying(void)
         else {
             if(g_PlayerTimes < 2) /*3秒切换时间*/
             {
-                bool a2dp = uapi_a2dp_snk_get_device_connect_state();// 获取a2dp连接状态
-                if(!a2dp)
-                {
-                    playersView->ChangeView(PlayersView::MUISC_CONNECTING, PlayersView::MUSIC_SOURCE_VIEW);
-                }
+                playersView->ChangeView(PlayersView::MUISC_CONNECTING, PlayersView::MUSIC_SOURCE_VIEW);
             }
         }
         return;
index 96a33f9..d6cea87 100644 (file)
@@ -14,6 +14,7 @@
 #include "main/include/MainViewSample.h"\r
 #include "wearable_log.h"\r
 #include "settings/include/SettingModel.h"\r
+#include <custom_utils.h>\r
 namespace OHOS\r
 {\r
     static PlayersView *g_pPlayersView = nullptr;\r
@@ -838,6 +839,27 @@ namespace OHOS
         }\r
     }\r
 \r
+    // 停止当前正在播放的音乐\r
+    void PlayersView::StopCurPlayingMusic()\r
+    {\r
+        uint8_t state = GetPlayerButtonState();\r
+        if (state == UICheckBox::UICheckBoxState::SELECTED)\r
+        {\r
+            PlayersModel::GetInstance()->PlayerStop();\r
+            PlayersModel::GetInstance()->ClearActivateAudioInterrupt();\r
+        }\r
+    }\r
+\r
+    //更新音乐播放器的声音进度条\r
+    void PlayersView::UpdateVolumeValue(void)\r
+    {\r
+        if (volumeSettingView != nullptr && volumeSettingView->GetProgress() != nullptr)\r
+        {\r
+            int val = uapi_systemVolumeGet();\r
+            volumeSettingView->GetProgress()->SetValue(val);\r
+        }\r
+    }\r
+\r
     /// @brief 设置音乐播放按钮是否可点击\r
     /// @param musicSourceType 音乐来源类型 false:手表音乐 true 手机音乐\r
     /// @param phoneMusicConnectStatus 手机音乐连接状态\r
@@ -852,19 +874,13 @@ namespace OHOS
             play_or_pause_Button->SetTouchable(touchableState);\r
             preMusicButton->SetTouchable(touchableState);\r
             nextMusicButton->SetTouchable(touchableState);\r
-            soundButton->SetTouchable(touchableState);\r
+            // soundButton->SetTouchable(touchableState);\r
             playerModelButton->SetTouchable(touchableState); // 如果音乐来源为手机音乐,播放顺序按钮就不可用\r
             /* -------------------------------------------------------------------------- */\r
             if (musicSourceType) // 如果切換到手机音乐,且当前在放歌,就停止音乐\r
             {\r
-                /*暂停音乐*/\r
-                uint8_t state = GetPlayerButtonState();\r
-                int32_t playerState; /*获取Player的状态*/\r
-                if (state == UICheckBox::UICheckBoxState::SELECTED)\r
-                {\r
-                    PlayersModel::GetInstance()->PlayerStop();\r
-                    PlayersModel::GetInstance()->ClearActivateAudioInterrupt();\r
-                }\r
+                /*停止音乐*/\r
+                StopCurPlayingMusic();\r
             }\r
             /* -------------------------------------------------------------------------- */\r
             PreLoadPlayerModeImageRes();\r
index 8d00b8e..d7e65e4 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: luozheng 1732036298@qq.com
  * @Date: 2024-02-23 09:17:00
  * @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-06-19 17:47:54
+ * @LastEditTime: 2024-09-18 19:34:06
  * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationModel.cpp
  */
 #include "soundandvibration/include/SoundAndVibrationModel.h"
@@ -12,6 +12,7 @@
 #include "soundandvibration/include/CallVolumeView.h"
 #include "wearable_log.h"
 #include "ConfigModel.h"
+#include "player/include/PlayersView.h"
 namespace OHOS
 {
 
@@ -29,14 +30,16 @@ namespace OHOS
     bool SoundAndVibrationModel::UpdateSystemVolume(void)
     {
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationModel::UpdateSystemVolume");
-        SystemVolumeView *p_SystemVolumeView = SystemVolumeView::GetInstance();
-        if (p_SystemVolumeView == nullptr)
+        if (SystemVolumeView::GetInstance())
         {
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemVolumeView::GetInstance fail!!");
-            return false;
+            SystemVolumeView::GetInstance()->UpdateSystemVolumeSliderValue();
         }
-        p_SystemVolumeView->UpdateSystemVolumeSliderValue();
 
+        //同步显示音乐的声音进度条
+        if(PlayersView::GetInstance())
+        {
+           PlayersView::GetInstance()->UpdateVolumeValue();
+        }
         return true;
     }