In watchOS 2, Apple has included a new feature to allow apps to record short audio files but, how can I call this new method in my existing WatchKit project?
- (void)presentAudioRecordingControllerWithOutputURL:(NSURL * nonnull)URL
preset:(WKAudioRecordingPreset)preset
maximumDuration:(NSTimeInterval)maximumDuration
actionTitle:(NSString * nullable)actionTitle
completion:(void (^ nonnull)(BOOL didSave,
NSError * nullable error))completion;
My problem is not how to called that method, is that Xcode compiler says that this function is not found. Do I have to include any additional Framework? Could it be because my WatchKit project was create with a previous version of WatchOS?
Thanks!
1) You need to create a file URL at which to store the recorded output.
You may specify the extensions .wav, .mp4, and .m4a.
2) Call the method as follows:
You can choose preset in addition to the above
In Swift:
You can play the recorded file as follows:
You can check the detail specification here.