Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6340063
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:46:01+00:00 2026-05-24T19:46:01+00:00

I am facing this problem: I record some audio using the iPhone microphone and

  • 0

I am facing this problem:

I record some audio using the iPhone microphone and upload it to my server. I record for say, 40 seconds and call the upload function after 41 seconds (timer). Now, the recorded file that is uploaded to the server is not the full file since the function

audioRecorderDidFinishRecording:  successfully:  

is not called before I call the upload function. Its called only after the upload function is called – no matter when I call the upload function – 10 seconds later or 100 seconds later.

In the upload function, I use ASIHTTPRequest and ASIFormDataRequest to upload the file.

Can anyone kindly tell me why this is happening ? Thanks.

Edit #1:
If the upload method is not called, the audioRecorderDidFinishRecording: successfully: method is never invoked. Pretty strange !

Edit #2:

Relevant methods:

(void) upload
{


NSString *urlString = @"<SOME_LINK>";
NSURL *url=[NSURL URLWithString:[urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];  
ASIFormDataRequest *request=[ASIFormDataRequest requestWithURL:url];

NSData *fileData=[NSData dataWithContentsOfURL:recordedTmpFile];
[request setData:fileData withFileName:[fileName copy] andContentType:@"audio/x-caf" forKey:@"userfile"];
[request setPostValue:[appDelegate getRandomXML] forKey:@"random"];
[request setRequestMethod:@"POST"];
[request setDelegate:self];



[request setShouldContinueWhenAppEntersBackground:YES];
[request startSynchronous];

}




- (void) record
{
NSMutableDictionary* recordSetting = [[NSMutableDictionary alloc] init];
[recordSetting setValue :[NSNumber numberWithInt:kAudioFormatAppleLossless] forKey:AVFormatIDKey];
[recordSetting setValue:[NSNumber numberWithFloat:44100.0] forKey:AVSampleRateKey]; 
[recordSetting setValue:[NSNumber numberWithInt: 2] forKey:AVNumberOfChannelsKey];

NSDateFormatter *formatter=[[NSDateFormatter alloc]init];
[formatter setDateFormat:@"hh:mm:ss"];
NSString *dateString=[formatter stringFromDate:[NSDate date]];

fileName=[@"recordTest" stringByAppendingFormat:@"%@.alac", dateString];

[formatter release];


NSString *documentDirectory=[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];

NSString *mediaPath=[documentDirectory stringByAppendingPathComponent:[fileName copy]];

NSString *mediaPathFinal=[NSString stringWithFormat:@"file://localhost%@",mediaPath];

recordedTmpFile = [NSURL URLWithString:[mediaPathFinal stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
recorder = [[ AVAudioRecorder alloc] initWithURL:recordedTmpFile settings:recordSetting error:&error];

recorder.delegate=self;


[recorder recordForDuration:(NSTimeInterval) ([[appDelegate getTimeToRecord] intValue]+1)];

}

- (void) audioRecorderDidFinishRecording:(AVAudioRecorder *) recorder  successfully:(BOOL)flag
{
NSLog(@"DONE");
}

- (void) audioRecorderEncodeErrorDidOccur:(AVAudioRecorder *) recorder error:(NSError *) error
{
NSLog(@"ERROR");
}


- (void) viewWillAppear:(BOOL)animated
{


AVAudioSession * audioSession = [AVAudioSession sharedInstance];
[audioSession setCategory:AVAudioSessionCategoryPlayAndRecord error: &error];

[audioSession setActive:YES error: &error];
[audioSession setDelegate:self];

[self record];
[NSTimer scheduledTimerWithTimeInterval:([[appDelegate getTimeToRecord] intValue]+1) target:self selector:@selector(upload) userInfo:nil repeats:NO];


}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T19:46:02+00:00Added an answer on May 24, 2026 at 7:46 pm

    You should call the -upload method inside audioRecorderDidFinishRecording:successfully: rather than in viewWillAppear:.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the AVAudioRecorder to grab audio from the microphone. The problem i'm facing
I'm facing a problem with IE6. I took the toggle function from this website
I'm facing this problem with Java. I want to get some HTML informations from
Hi I am facing this problem while building a source using ant Problem: failed
I´m facing this problem: I have a Button that works like a WrapPanel using
I am facing this problem. i tried to create a function that detect if
I'm facing this problem again and again, but can't find any solution (except mine,
I was facing this unique problem of generating a bit-mask based on the input
I am facing a problem while creating a static cursor in DB2. This is
We are facing a strange performance problem with SQL Server Express 2005 in a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.