ios - 请求访问麦克风的简单播放
问题描述
我的应用程序中有一个声音剪辑。现在,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()
}
解决方案
推荐阅读
- c# - Oracle 12c 等效于 C# Encoding.ASCII.GetBytes
- javascript - 即使已经定义了变量,所需的代码也无法找到它们
- python - 在 AppEngine 中使用烧瓶 babel 时出错
- javascript - 如何在函数中包装 Ajax 权限检查?
- laravel - 保存文件 PDF Pimaco
- mysql - mysql,从一个表2中删除表1中找到的记录
- python - Python同款网卡游戏
- ruby - 尝试使用 Ruby 创建包含时间/日期值的字符串
- c++ - 如何使用字符串文字作为宏参数?
- angular - Angular:单击独立页面上的锚标记元素