objective c - Watchkit presentAudioRecordingControllerWithOutputURL completion block issue -


i'm trying satisfy arguments function below bring audio recorder. believe issue completion block. error given in debug :

presentaudiorecordingcontrollerwithoutputurl:preset:maximumduration:actiontitle:completion: requires non-null url , completion block

nsbundle* mybundle = [nsbundle mainbundle]; nsurl* recording = [mybundle urlforresource:@"recording" withextension:@"mp4"];  [self presentaudiorecordingcontrollerwithoutputurl:recording                                             preset:wkaudiorecordingpresetwidebandspeech                                    maximumduration:5000                                        actiontitle:@"recording"                                         completion:^(bool didsave, nserror *error) {                                             if (error != nil)                                             {                                                nslog(@"error: %@",error);                                             }                                             else if(didsave == yes)                                             {                                                 nslog(@"saved recording");                                             }                                         }]; 

i guess file url recording wrong. can't record "main bundle". nsurl object couldn not created , occurred non-null error.

for example, able record documents directory follows:

nsarray *filepaths = nssearchpathfordirectoriesindomains(nsdocumentdirectory,                                                          nsuserdomainmask,yes); nsstring *path = [[filepaths firstobject] stringbyappendingpathcomponent:@"recording.mp4"]; nsurl *fileurl = [nsurl fileurlwithpath:path];  [self presentaudiorecordingcontrollerwithoutputurl:fileurl                                             preset:wkaudiorecordingpresetwidebandspeech                                    maximumduration:5000                                        actiontitle:@"recording"                                         completion:^(bool didsave, nserror * __nullable error) {                                              nslog(@"didsave:%d, error:%@", didsave, error);                                         }]; 

Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -