Hello,
I am trying to record something, but I get an error in the setup with my AVAudioRecorder:
Cannot invoke initializer for type 'AVAudioRecorder' with an argument list of type '(url: NSURL, settings: [String : Any], error: inout NSError?)'
I'm not sure whats wrong here. Heres my code:
var soundRecorder = AVAudioRecorder()
var soundPlayer = AVAudioPlayer()
var fileName = "audioFile.m4a"
override func viewDidLoad() {
super.viewDidLoad()
/
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
/
}
func setupRecorder() {
var recordSettings = [ AVFormatIDKey : kAudioFormatAppleLossless,
AVEncoderAudioQualityKey : AVAudioQuality.max.rawValue,
AVEncoderBitRateKey: 320000,
AVNumberOfChannelsKey : 2,
AVSampleRateKey : 44100.0 ] as [String : Any]
var error : NSError?
soundRecorder = AVAudioRecorder(url: getFileURL(), settings: recordSettings, error: &error)
}
func getCacheDirectory() -> String{
let paths = NSSearchPathForDirectoriesInDomains(FileManager.SearchPathDirectory.documentDirectory, FileManager.SearchPathDomainMask.userDomainMask, true)
return paths[0]
}
func getFileURL() -> NSURL{
let path = getCacheDirectory().appending(fileName)
let filePath = NSURL(fileURLWithPath: path)
return filePath
}
THANKS FOR HELPING!