|
|
|
@ -1523,7 +1523,7 @@ class AudioPlayer { |
|
|
|
stopAwaitSound() |
|
|
|
|
|
|
|
// 播放等待音效 |
|
|
|
playLoopSound(named: "await", fileType: "mp3", player: &awaitPlayer) |
|
|
|
playLoopSound(named: "await", fileType: "mp3", player: &awaitPlayer,volume:0.2) |
|
|
|
|
|
|
|
// 启动超时定时器 |
|
|
|
startAwaitTimeout() |
|
|
|
@ -1564,7 +1564,7 @@ class AudioPlayer { |
|
|
|
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 = nil |
|
|
|
@ -1572,6 +1572,10 @@ class AudioPlayer { |
|
|
|
if let path = resourcesBundle.path(forResource: named, ofType: fileType) { |
|
|
|
let url = URL(fileURLWithPath: path) |
|
|
|
safePlayLoopAudio(url: url, player: &player) |
|
|
|
|
|
|
|
// 在创建播放器之后设置音量 |
|
|
|
player?.volume = volume |
|
|
|
|
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
|