简单播放请求访问麦克风

时间:2018-12-04 15:44:52

标签: ios swift avfoundation playback

我的应用中有一个声音剪辑。现在,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()
}

0 个答案:

没有答案