Sunday, 25 September 2011

save audio record form mike to documents directory


i want record audio inside app using iphone mike when user taps button , when stop recording tapping same button saved in documents directory. think have pretty i'm not sure how save documents directory.

here code;


code:
 // set button -(ibaction)recordaudio:(id)sender;{     nslog(@"recordaudio");     recorder = nil;     if ( isnotrecording){        isnotrecording=no;         [record settitle:@"record greeting" forstate:uicontrolstatenormal];                  [recorder setdelegate:self];         [recorder preparetorecord];         [recorder record];         }      else{          isnotrecording = yes;         [record settitle:@"stop recording" forstate:uicontrolstatenormal];         [recorder stop];     } //i start audio session     avaudiosession *session = [avaudiosession sharedinstance];     [session setcategory:avaudiosessioncategoryrecord error:nil]; //i find path documents directory , name file after put textfield , append .aac     nsarray *documentpaths = nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes);      nsstring *documentsdirectory = [documentpaths objectatindex:0];     nsstring *fullpath = [documentsdirectory stringbyappendingpathcomponent:[[self imagenametextfield]text]];      fullpath = [fullpath stringbyappendingformat:@".aac"];   //set settings audio file     nsmutabledictionary *recordsettings = [[nsmutabledictionary alloc] initwithcapacity:10];         if(recordencoding==enc_aac){                  [recordsettings setobject:[nsnumber numberwithint:kaudioformatmpeg4aac]forkey:avformatidkey];         [recordsettings setobject:[nsnumber numberwithfloat:44100.0] forkey: avsampleratekey];         [recordsettings setobject:[nsnumber numberwithint:2] forkey:avnumberofchannelskey];         [recordsettings setobject:[nsnumber numberwithint:6400] forkey:avencoderbitratekey];         [recordsettings setobject:[nsnumber numberwithint:16] forkey:avlinearpcmbitdepthkey];         [recordsettings setobject:[nsnumber numberwithint: avaudioqualityhigh] forkey: avencoderaudioqualitykey];     }  //here's lost!    nsurl *url = [nsurl fileurlwithpath:fullpath];     nserror *error = nil;     recorder = [[ avaudiorecorder alloc] initwithurl:url settings:recordsettings error:&error];           }
can me out have looked on line there isn't can find, maybe i'm searching wrong.
 

save audio record mike documents directory

figured out. moved button actions below call of audio session , path , settings. fiddled settings audio.
 


Forums iPhone, iPad, and iPod Touch iOS Programming


  • iPhone
  • Mac OS & System Software
  • iPad
  • Apple Watch
  • Notebooks
  • iTunes
  • Apple ID
  • iCloud
  • Desktop Computers
  • Apple Music
  • Professional Applications
  • iPod
  • iWork
  • Apple TV
  • iLife
  • Wireless

No comments:

Post a Comment