Reputation: 1586
I wanted to record my Audio on Applewatch and send to my iPhone. I created a URL to store the file and everytime I try this on my simulator it is working fine but on real device nothing happes with this error
Error: Error Domain=com.apple.watchkit.errors Code=3 “(null)”
URL:
var dir = fileManager.containerURL(forSecurityApplicationGroupIdentifier: "group.com.companyname.projektname")
RECORD:
presentAudioRecorderController(withOutputURL: dir,preset:.narrowBandSpeech,
options: nil,
completion:.........
Upvotes: 0
Views: 449
Reputation: 146
On WatchOS 3 you also need to add a "Privacy - Microphone Usage Description" entry in the info.plist file of your iOS app (not the WatchKit app). Then on the iPhone you must agree with using the microphone.
I found this here: https://forums.developer.apple.com/thread/62612
Upvotes: 1
Reputation: 4379
Please try below code:
Define URL :
var saveUrl: NSURL?
let container =
fileManager.containerURLForSecurityApplicationGroupIdentifier(
"group.com.companyname.projektname")
let fileName = "audioFile.wav"
saveUrl = container?.URLByAppendingPathComponent(fileName)
Recording Code :
let duration = NSTimeInterval(10)
let recordOptions =
[WKAudioRecorderControllerOptionsMaximumDurationKey : duration]
presentAudioRecorderControllerWithOutputURL(saveUrl!,
preset: .NarrowBandSpeech,
options: recordOptions,
completion: { saved, error in
if let err = error {
print(err.description)
}
if saved {
self.playButton.setEnabled(true)
}
})
Hope this will help you...
Upvotes: 0