Andrii Yanechko
06/25/2023, 5:06 PMAVAudioRecorder
on the Kotlin side, maybe someone already faced that issue and was able to resolve it ?
Thanks! Details are in 🧵Andrii Yanechko
06/25/2023, 5:06 PMprivate fun createRecorder(url: NSURL, error: CPointer<ObjCObjectVar<NSError?>>?): AVAudioRecorder {
val settings = mapOf<Any?, Any?>(
AVFormatIDKey to kAudioFormatMPEG4AAC.toInt(),
AVSampleRateKey to 12000,
AVNumberOfChannelsKey to 1,
AVEncoderAudioQualityKey to AVAudioQualityHigh
)
Napier.d { "Url is $url, ${url.path}" }
return AVAudioRecorder(url, settings, error)
}
The URL I'm passing looks like: file:///Users/andriiyanechko/Library/Developer/CoreSimulator/Devices/B0099A9D-D13E-441F-85B4-51F4A7BDE4B1/data/Containers/Data/Application/E4EF69B8-5E54-42B3-9E92-1B843D684B08/Documents/8A79AA3F-B44E-4EDE-A6F8-5B58DC52CB72-AnimalNameRecording.m4a
I'm invoking that function from the Main thread and getting this error: Thread 1: EXC_BAD_ACCESS (code=1, address=0x50)
If I write same code but on the Swift it works and recording is getting started:
let url = getDocumentsDirectory().appendingPathComponent("\(UUID().uuidString)-recording.m4a")
print(url)
let audioFilename = url
let settings = [
AVFormatIDKey: Int(kAudioFormatMPEG4AAC),
AVSampleRateKey: 12000,
AVNumberOfChannelsKey: 1,
AVEncoderAudioQualityKey: AVAudioQuality.high.rawValue
]
do {
let audioRecorder = try AVAudioRecorder(url: audioFilename, settings: settings)
audioRecorder.delegate = self
audioRecorder.record()
print("Recording...")
} catch {
print("Error")
}
Andrii Yanechko
06/25/2023, 5:06 PMAndrii Yanechko
06/25/2023, 5:41 PM