static void HandDownloadSuccessNotify(Request *request);
static void HandDownloadFailNotify(Request *request);
static void HandDownloadProgressNotify(Request *request);
++static void HandAudioPlaybackStartNotify(Request *request);
static void HandAudioPlaybackEndNotify(Request *request);
+ static void HandNpcEmotionChangeNotify(Request *request);
// 消息处理程序项数组(每个消息类型对应一个处理函数,函数名以 Handle 开头)
MsgHandlerEntry msgHandlers[] = {
{HANDLE_JUMP_OTA_VIEW, HandleJumpOtaView},
{HAND_DOWNLOAD_SUCCESS_NOTIFY,HandDownloadSuccessNotify},
{HAND_DOWNLOAD_FAIL_NOTIFY,HandDownloadFailNotify},
{HAND_DOWNLOAD_PROGRESS_NOTIFY,HandDownloadProgressNotify},
++ {HAND_AUDIO_PLAYBACK_START_NOTIFY,HandAudioPlaybackStartNotify},
{HAND_AUDIO_PLAYBACK_END_NOTIFY,HandAudioPlaybackEndNotify},
+ {HAND_NPC_EMOTION_CHANGE_NOTIFY,HandNpcEmotionChangeNotify},
};
/* -------------------------------------------------------------------------- */
void ScreenTurnOn(int32_t timeout)
GraphicService::GetInstance()->PostGraphicEvent(
std::bind(&OHOS::OtaModel::HandleDownloadFail,OHOS::OtaModel::GetInstance(), type));
}
++// 音频播放开始通知
++void HandAudioPlaybackStartNotify(Request *request)
++{
++ WEARABLE_LOGE(WEARABLE_LOG_MODULE_UI_SERVICE, "HandAudioPlaybackStartNotify msg_id = %d", request->msgId);
++ GraphicService::GetInstance()->PostGraphicEvent(
++ std::bind(&OHOS::ThunderBirdModel::HandleAudioPlaybackStart,OHOS::ThunderBirdModel::GetInstance()));
++}
++
// 音频播放结束通知
void HandAudioPlaybackEndNotify(Request *request)
{
GraphicService::GetInstance()->PostGraphicEvent(
std::bind(&OHOS::ThunderBirdModel::HandleAudioPlaybackEnd,OHOS::ThunderBirdModel::GetInstance()));
}
+ // 通知npc表情变化
+ void HandNpcEmotionChangeNotify(Request *request)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_UI_SERVICE, "HandNpcEmotionChangeNotify msg_id = %d", request->msgId);
+ std::string emotion(static_cast<char*>(request->data), request->len);
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_UI_SERVICE, "HandNpcEmotionChangeNotify emotion = %s", emotion.c_str());
++ GraphicService::GetInstance()->PostGraphicEvent(
++ std::bind(&OHOS::ThunderBirdModel::HandleNpcEmotionChange,OHOS::ThunderBirdModel::GetInstance(),emotion.c_str()));
+ }
/* -------------------------------------------------------------------------- */
#ifdef __cplusplus
}
LN_WS_DEBUG("Default: Processing Audio Playback End event\n");
break;
case WS_CMD_SENTENCE_PLAYBACK_COMPLETE:
++ //推送文本到UI
++ push_audio_playback_start_notification();
LN_WS_DEBUG("Default: Processing Sentence Playback Complete event\n");
break;
case WS_CMD_AUDIO_RECORDING_START:
static bool check_playback_completion_by_duration(void)
{
uint32_t oldest_audio_duration_ms = get_oldest_valid_audio_duration();
--
++ oldest_audio_duration_ms-=200;
if (oldest_audio_duration_ms == 0) {
return false; // 没有有效的音频时长数据
}
// 触发单句语音播放完成事件
if (g_ws_message_callback != NULL) {
++ push_audio_playback_start_notification();
g_ws_message_callback(NULL, WS_CMD_SENTENCE_PLAYBACK_COMPLETE);
}