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!

  1. i set avaudiosession

    [[avaudiosession sharedinstance] setcategory:avaudiosessioncategoryplayandrecord error:nil];

  2. 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];

  3. 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?

thanks in advance!

to summarize following ramble: in experience, avaudioplayer play long long file had data, when initialized.

i'm struggling same thing; wonder if ever found solution. i'm working on similar project (i want able record, , playback small delay, while recording).

i start creating avaudiorecorder, works fine. start avaudioplayer initwithcontentsofurl, pointing same file.

what have found if there were, say, 3 seconds of sound (via .duration property) in file when player starts, stop after 3 seconds, if avaudiorecorder has continued after that.

i've attempted work around creating second player once first nears end of initial duration of recording, results in small dropout of audio can seem rid myself of.

if tell avaudioplayer keep reading file!


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -