Browse Source

优化按钮和等待sheng yin

weicu
liwei1dao 1 year ago
parent
commit
90605fb6df
  1. 2
      lib/modules/agent/views/agent_view.dart
  2. 8
      local_plugins/agent_service/ios/agent_service/Sources/agent_service/AgentServiceImpl.swift

2
lib/modules/agent/views/agent_view.dart

@ -4,6 +4,7 @@ import 'dart:math';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_intro/flutter_intro.dart'; import 'package:flutter_intro/flutter_intro.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:haptic_feedback/haptic_feedback.dart';
import '../../../core/widgets/intro_overlay_builder.dart'; import '../../../core/widgets/intro_overlay_builder.dart';
import '../controllers/agent_controller.dart'; import '../controllers/agent_controller.dart';
import '../controllers/message_action_controller.dart'; import '../controllers/message_action_controller.dart';
@ -616,6 +617,7 @@ class _AgentViewState extends State<AgentView> with WidgetsBindingObserver {
_holdTimer = Timer( _holdTimer = Timer(
const Duration(milliseconds: 100), const Duration(milliseconds: 100),
() { () {
Haptics.vibrate(HapticsType.success);
controller.startPushToTalk(); controller.startPushToTalk();
// if (activeSpeaker == 0) { // if (activeSpeaker == 0) {
// if (speakerId == 1) { // if (speakerId == 1) {

8
local_plugins/agent_service/ios/agent_service/Sources/agent_service/AgentServiceImpl.swift

@ -1523,7 +1523,7 @@ class AudioPlayer {
stopAwaitSound() stopAwaitSound()
// 播放等待音效 // 播放等待音效
playLoopSound(named: "await", fileType: "mp3", player: &awaitPlayer) playLoopSound(named: "await", fileType: "mp3", player: &awaitPlayer,volume:0.2)
// 启动超时定时器 // 启动超时定时器
startAwaitTimeout() startAwaitTimeout()
@ -1564,7 +1564,7 @@ class AudioPlayer {
os_log("未找到音频文件: %{public}@.%{public}@ in bundle %{public}@", log: logger, type: .error, named, fileType, resourcesBundle.bundlePath) os_log("未找到音频文件: %{public}@.%{public}@ in bundle %{public}@", log: logger, type: .error, named, fileType, resourcesBundle.bundlePath)
} }
private func playLoopSound(named: String, fileType: String = "mp3", player: inout AVAudioPlayer?) { private func playLoopSound(named: String, fileType: String = "mp3", player: inout AVAudioPlayer?, volume: Float = 1.0) {
// 停止当前播放的循环音频 // 停止当前播放的循环音频
player?.stop() player?.stop()
player = nil player = nil
@ -1572,6 +1572,10 @@ class AudioPlayer {
if let path = resourcesBundle.path(forResource: named, ofType: fileType) { if let path = resourcesBundle.path(forResource: named, ofType: fileType) {
let url = URL(fileURLWithPath: path) let url = URL(fileURLWithPath: path)
safePlayLoopAudio(url: url, player: &player) safePlayLoopAudio(url: url, player: &player)
// 在创建播放器之后设置音量
player?.volume = volume
return return
} }

Loading…
Cancel
Save