From 892dea426198ed5d050e193b4da39d89837c144e Mon Sep 17 00:00:00 2001 From: MTing Date: Fri, 19 Sep 2025 11:00:02 +0800 Subject: [PATCH] init voice for face detect --- .../com/ouxuan/oxface/OXFaceOnlineActivity.java | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/app/src/main/java/com/ouxuan/oxface/OXFaceOnlineActivity.java b/app/src/main/java/com/ouxuan/oxface/OXFaceOnlineActivity.java index 0cce82d..2e41183 100644 --- a/app/src/main/java/com/ouxuan/oxface/OXFaceOnlineActivity.java +++ b/app/src/main/java/com/ouxuan/oxface/OXFaceOnlineActivity.java @@ -58,6 +58,10 @@ import com.ouxuan.oxface.abgate.GateUnavailableDialog; import com.ouxuan.oxface.abgate.ABGateManager; import com.ouxuan.oxface.device.GateABController; +// 添加语音模块导入 +import com.ouxuan.oxface.device.voice.VoicePlayerManager; +import com.ouxuan.oxface.device.voice.VoiceType; + import java.util.List; /** @@ -205,6 +209,9 @@ public class OXFaceOnlineActivity extends BaseActivity implements View.OnClickLi private ABGateManager abGateManager; private boolean isGateCheckEnabled = false; // AB门检测是否开启 + // 新增语音播放管理器 + private VoicePlayerManager voicePlayerManager; + // 方案二:添加状态标识控制订单选择页面的显示,避免重复弹出 private static boolean isOrderSelectionActivityShowing = false; // 订单选择页面是否正在显示 private static boolean isOrderVerificationResultActivityShowing = false; // 订单核销结果页面是否正在显示 @@ -235,6 +242,9 @@ public class OXFaceOnlineActivity extends BaseActivity implements View.OnClickLi // 初始化解锁密码弹窗 initUnlockPasswordDialog(); + // 初始化语音播放管理器 + initVoicePlayerManager(); + initView(); // 初始化网络状态指示器 @@ -261,6 +271,8 @@ public class OXFaceOnlineActivity extends BaseActivity implements View.OnClickLi // 启动内存优化周期性任务 startMemoryOptimizationTask(); + + // 更新小程序码 android.util.Log.d(TAG, "准备调用updateMiniQrcode方法"); updateMiniQrcode(); @@ -1566,6 +1578,13 @@ public class OXFaceOnlineActivity extends BaseActivity implements View.OnClickLi protected void onDestroy() { super.onDestroy(); + // 释放语音播放器资源 + if (voicePlayerManager != null) { + voicePlayerManager.release(); + voicePlayerManager = null; + LogManager.logInfo(TAG, "语音播放器资源已释放"); + } + // 销毁网络状态指示器 if (networkStatusIndicator != null) { networkStatusIndicator.destroy(); @@ -2581,12 +2600,31 @@ public class OXFaceOnlineActivity extends BaseActivity implements View.OnClickLi } /** + * 初始化语音播放管理器 + */ + private void initVoicePlayerManager() { + try { + voicePlayerManager = VoicePlayerManager.getInstance(); + voicePlayerManager.initialize(this); + + LogManager.logInfo(TAG, "语音播放管理器初始化完成"); + } catch (Exception e) { + LogManager.logError(TAG, "语音播放管理器初始化失败", e); + } + } + + /** * 查验订单列表 * 根据modeType和verifyCode等参数获取相应的数据查询参数并发送网络请求 */ private void getCheckOrder() { LogManager.logInfo(TAG, "开始查验订单列表,modeType: " + modeType); + // 播放正在进行人脸识别语音 + if (voicePlayerManager != null) { + voicePlayerManager.playVoice(VoiceType.FACE_RECOGNITION); + } + // 人脸验证模式下不需要暂停摄像头,保持视频流继续运行 if (modeType != OrderVerificationManager.TYPE_FACE_VERIFICATION) { // 非人脸验证模式(验证码、扫码等)才暂停摄像头