增加对话自动开启录音 2637/target/2 2639/1 2639/head
authorxue <2144439972@qq.com>
Thu, 30 Oct 2025 05:49:34 +0000 (13:49 +0800)
committerxue <2144439972@qq.com>
Thu, 30 Oct 2025 05:49:34 +0000 (13:49 +0800)
code/sdk/application/wearable/ln/nativeapp/nativeui/include/uiservice/ui_service.h
code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdModel.h
code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdModel.cpp
code/sdk/application/wearable/ln/nativeapp/nativeui/uiservice/src/ui_service.cpp
code/sdk/zhihui/leiniao/imsl_ln/ln_api.c
code/sdk/zhihui/leiniao/ln_api_cpp/ln_api_interface.cpp
code/sdk/zhihui/leiniao/ln_api_cpp/ln_api_interface.h

index 4c3fb31..a7ce3d1 100644 (file)
@@ -68,6 +68,7 @@ typedef enum {
     HAND_DOWNLOAD_ETA_NOTIFY, // 下载ETA(剩余时间)通知,单位秒,-1表示未知
     HAND_AUDIO_PLAYBACK_START_NOTIFY, // 音频播放开始通知
     HAND_AUDIO_PLAYBACK_END_NOTIFY, // 音频播放结束通知
+    HAND_AUDIO_RECORDING_START_NOTIFY, // 录音开始通知
     HAND_AUDIO_RECORDING_END_NOTIFY, // 录音结束通知
     HAND_NPC_EMOTION_CHANGE_NOTIFY, // npc表情变化通知
     HAND_TIMELINE_STATUS_CHANGE_NOTIFY, // 时间线状态变化通知
index 30e1929..332d09f 100644 (file)
@@ -229,6 +229,8 @@ namespace OHOS
         // NPC表情变化处理函数
         void HandleNpcEmotionChange(const char* emotion);
         
+        // 录音开始处理函数
+        void HandleAudioRecordingStart();
         // 录音结束处理函数
         void HandleAudioRecordingEnd();
         
index 1d8212c..201ce33 100644 (file)
         }
     }
     
+    // 录音开始处理函数
+    void ThunderBirdModel::HandleAudioRecordingStart()
+    {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::HandleAudioRecordingStart: 录音开始");
+        
+        // 获取当前视图状态
+        ThunderBirdMainView *view = ThunderBirdMainView::GetInstance();
+        if (view) {
+            int16_t currentView = view->GetCurrentView();
+            int16_t currentSubView = view->GetCurrentSubView();
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::HandleAudioRecordingStart: currentView=%d, currentSubView=%d", currentView, currentSubView);
+            
+            // 如果当前在对话界面,且不在聆听状态,则跳转到聆听状态
+            if (currentView == THUNDERBIRD_DIALOGUEVIEW && 
+                currentSubView == ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_SPEAKING) {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "录音开始,跳转到聆听状态");
+                view->ChangeView(currentView, THUNDERBIRD_DIALOGUEVIEW, ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_LISTENING);
+                ThunderBirdDialogueView::GetInstance()->UpdateDialogueText("超认真聆听中");
+            }
+            // 如果当前在哄睡界面,且不在故事选择状态,则跳转到故事选择状态
+            else {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::HandleAudioRecordingStart: 不满足推送条件");
+            }
+        }
+    }
+    
     // 录音结束处理函数
     void ThunderBirdModel::HandleAudioRecordingEnd()
     {
index 201e412..5c1a04b 100644 (file)
@@ -104,6 +104,7 @@ static void HandDownloadProgressNotify(Request *request);
 static void HandDownloadEtaNotify(Request *request);
 static void HandAudioPlaybackStartNotify(Request *request);
 static void HandAudioPlaybackEndNotify(Request *request);
+static void HandAudioRecordingStartNotify(Request *request);
 static void HandAudioRecordingEndNotify(Request *request);
 static void HandNpcEmotionChangeNotify(Request *request);
 static void HandTimelineStatusChangeNotify(Request *request);
@@ -127,6 +128,7 @@ MsgHandlerEntry msgHandlers[] = {
     {HAND_DOWNLOAD_ETA_NOTIFY,HandDownloadEtaNotify},
     {HAND_AUDIO_PLAYBACK_START_NOTIFY,HandAudioPlaybackStartNotify},
     {HAND_AUDIO_PLAYBACK_END_NOTIFY,HandAudioPlaybackEndNotify},
+    {HAND_AUDIO_RECORDING_START_NOTIFY,HandAudioRecordingStartNotify},
     {HAND_AUDIO_RECORDING_END_NOTIFY,HandAudioRecordingEndNotify},
     {HAND_NPC_EMOTION_CHANGE_NOTIFY,HandNpcEmotionChangeNotify},
     {HAND_TIMELINE_STATUS_CHANGE_NOTIFY,HandTimelineStatusChangeNotify},
@@ -673,6 +675,13 @@ void HandAudioPlaybackEndNotify(Request *request)
         std::bind(&OHOS::ThunderBirdModel::HandleAudioPlaybackEnd,OHOS::ThunderBirdModel::GetInstance()));
 }
 
+// 录音开始通知
+void HandAudioRecordingStartNotify(Request *request)
+{
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_UI_SERVICE, "HandAudioRecordingStartNotify msg_id = %d", request->msgId);
+    GraphicService::GetInstance()->PostGraphicEvent(
+        std::bind(&OHOS::ThunderBirdModel::HandleAudioRecordingStart,OHOS::ThunderBirdModel::GetInstance()));
+}
 // 录音结束通知
 void HandAudioRecordingEndNotify(Request *request)
 {
index c4f586b..3160d13 100644 (file)
@@ -1012,6 +1012,11 @@ void ln_ws_process_message(const ws_data_msg_t *data_msg, ws_command_t type)
         push_audio_playback_start_notification();
         break;
     }
+    case WS_CMD_AUDIO_RECORDING_START:
+    {
+        push_audio_recording_start_notification();
+        break;
+    }
     case WS_CMD_AUDIO_RECORDING_END:
     {
         push_audio_recording_end_notification();
index cf8e931..727ee99 100644 (file)
@@ -272,6 +272,11 @@ void push_audio_playback_end_notification(void)
 {
     SendMsgToUIService(HAND_AUDIO_PLAYBACK_END_NOTIFY, 0, NULL, 0);
 }
+//通知录音开始
+void push_audio_recording_start_notification(void)
+{
+    SendMsgToUIService(HAND_AUDIO_RECORDING_START_NOTIFY, 0, NULL, 0);
+}
 //通知录音结束
 void push_audio_recording_end_notification(void)
 {
index 734d4a9..befc686 100644 (file)
@@ -103,6 +103,8 @@ void push_download_eta_notification(int seconds);
 //通知音频播放结束了
 void push_audio_playback_start_notification(void);
 void push_audio_playback_end_notification(void);
+//通知录音开始
+void push_audio_recording_start_notification(void);
 //通知录音结束
 void push_audio_recording_end_notification(void);
 //通知npc表情变化