ios - Using AVAudioRecorder and AvAudioPlayer simultaneously -
i need have have audio (a lecture etc.) recording on iphone , directly playing through headphones. i have code works - of time! i set avaudiosession [[avaudiosession sharedinstance] setcategory:avaudiosessioncategoryplayandrecord error:nil]; i set player , recorder, both pointing same url. audiorecorder = [[avaudiorecorder alloc] initwithurl:soundfileurl settings:recordsettings error:&error]; //set audio playing audioplayer = [[avaudioplayer alloc] initwithcontentsofurl:soundfileurl error:&error]; i prepare play , record [audiorecorder preparetorecord]; [audioplayer preparetoplay]; everything proceeds while. suddenly, player stops, , current time goes zero. it doesn't getting dealloc'ed, since can proceed play recorded sound fine start position. stopping occurs seemingly randomly, @ different times each time. anyone have suggestions problem or how debug? thank...