我的应用中有一个声音剪辑。现在,iOS正在请求访问麦克风。简单播放是否需要?这是代码段:
func _playSound() {
do {
if let fileURL = Bundle.main.path(forResource: "clip", ofType: "aiff") {
_clip = try AVAudioPlayer(contentsOf: URL(fileURLWithPath: fileURL))
_clip?.volume = 0.3
} else {
print("ERROR: No file with specified name exists in _playSound()")
}
} catch let error {
print("ERROR: AVAudioPlayer(contentsOf: _) threw an error in _playSound(); Message: \(error.localizedDescription)")
}
_clip?.play()
}