我们可以在快速游乐场使用AVAudiorecorder吗?

Fer*_*sAS 8 avaudiorecorder ios swift

我想在将它放入我的应用程序之前在游乐场中对代码进行原型设计.我们可以使用快速游乐场录制音频吗?

非常感谢,

Feras A.

以下是我目前的尝试,但audioFile没有任何长度,属性或数据: -

import UIKit
import AVFoundation

var soundRecorder: AVAudioRecorder!
let documentsDirectory = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0]
let OutputFilePath = documentsDirectory.appendingPathComponent("out.wav")

//set the settings for recorder
var recordSettings = [
    AVFormatIDKey: kAudioFormatAppleLossless,
    AVEncoderAudioQualityKey : AVAudioQuality.max.rawValue,
    AVEncoderBitRateKey : 320000,
    AVNumberOfChannelsKey: 2,
    AVSampleRateKey : 44100.0
] as [String : Any]

try soundRecorder = AVAudioRecorder(url: OutputFilePath, settings: recordSettings)
soundRecorder.record(forDuration: 10)
let audioFile = try AVAudioFile(forReading: OutputFilePath)
Run Code Online (Sandbox Code Playgroud)

moe*_*far 1

我认为这是不可能的。由于没有设备可以录制音频,但我认为您可以连接外部设备并将其用作模拟器