From dcd68c2af80736da0b68c5021bfe84432f8ff80e Mon Sep 17 00:00:00 2001 From: 15945162479 <15945162479@qq.com> Date: Sat, 13 Dec 2025 14:46:13 +0800 Subject: [PATCH] Add File --- src/elderly/components/AvatarStage.tsx | 52 ++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 src/elderly/components/AvatarStage.tsx diff --git a/src/elderly/components/AvatarStage.tsx b/src/elderly/components/AvatarStage.tsx new file mode 100644 index 0000000..dd559bf --- /dev/null +++ b/src/elderly/components/AvatarStage.tsx @@ -0,0 +1,52 @@ +import React, { useState } from 'react'; +import { XmovAvatar } from './XmovAvatar'; + +interface AvatarStageProps { + isActive?: boolean; + websocketUrl?: string; + onSDKStatusChange?: (status: 'loading' | 'ready' | 'error' | 'config-missing') => void; + onWSStatusChange?: (status: 'disconnected' | 'connecting' | 'connected') => void; + onLogMessage?: (message: string) => void; +} + +/** + * 数字人画面组件 - 承载 xmovsdk 渲染流 + * 占据主要屏幕空间,支持 9:16 竖屏 + * 连接到 WebSocket (10002端口) 接收消息驱动数字人说话 + */ +export const AvatarStage: React.FC = ({ + isActive = false, + websocketUrl = 'ws://127.0.0.1:10002', + onSDKStatusChange, + onWSStatusChange, + onLogMessage, +}) => { + const [isSpeaking, setIsSpeaking] = useState(false); + + const handleSDKReady = () => { + console.log('[AvatarStage] 数字人SDK就绪'); + }; + + const handleSDKError = (error: any) => { + console.error('[AvatarStage] 数字人SDK错误:', error); + }; + + const handleSpeaking = (speaking: boolean) => { + setIsSpeaking(speaking); + }; + + return ( +
+ +
+ ); +};