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 8847833
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:17:07+00:00 2026-06-14T12:17:07+00:00

I face issue with AvAudioRecorder, create corrupted file on random check. It create file

  • 0

I face issue with AvAudioRecorder, create corrupted file on random check.

It create file with length 24kb, which is not occurred all time, but randomly found file is corrupted.

I also checked below link for references, as i have similar issue, but it does not worked for me.

AVAudioRecorder Record method returns NO at random times

Seemingly random file corruption using AVAudioRecorder (Sometimes the file can't be played back) – iOS

below is complete functionality code.

-(IBAction)btnRecordClick:(id)sender
{
    [PlayingTimer invalidate];
    PlayingTimer = nil;

    if(isPaused==NO)
    {
        AVAudioSession *audioSession = [AVAudioSession sharedInstance];
        NSError *err = nil;
        [audioSession setCategory :AVAudioSessionCategoryPlayAndRecord error:&err];

        if(err)
        {
            // NSLog(@"audioSession: %@ %d %@", [err domain], [err code], [[err userInfo] description]);
            return;
        }

        [audioSession setActive:YES error:&err];
        err = nil;

        if(err)
        {
            // NSLog(@"audioSession: %@ %d %@", [err domain], [err code], [[err userInfo] description]);
            return;
        }

        //*******Working well with .wav,.caf and .mp4 files *****************
        recordSetting = [[NSMutableDictionary alloc] init];

        //this is for .wav and .caf file
        //this is for .mp4 file for iPhone 3GS/iPhone 4
        [recordSetting setValue: [NSNumber numberWithInt:kAudioFormatMPEG4AAC] forKey:AVFormatIDKey];
        [recordSetting setValue: [NSNumber numberWithFloat:44100.0] forKey:AVSampleRateKey];
        [recordSetting setValue: [NSNumber numberWithInt: 2] forKey:AVNumberOfChannelsKey];
        [recordSetting setValue:[NSNumber numberWithInt:16] forKey:AVLinearPCMBitDepthKey];
        [recordSetting setValue:[NSNumber numberWithBool:NO] forKey:AVLinearPCMIsBigEndianKey];
        [recordSetting setValue:[NSNumber numberWithBool:NO] forKey:AVLinearPCMIsFloatKey];

        self.strMessage = @"";
        self.strMessageType = [NSString stringWithFormat:@"Audio Message"];
        self.strFileName = [NSString stringWithFormat:@"%@.mp4", [_globalmodel stringUniqueID]];
        // NSLog(@"FileName :%@",self.strFileName);

        self.strUniqueRef = [NSString stringWithFormat:@"%@",[_globalmodel stringUniqueID]];

        NSString *soundPath;//=[NSString alloc];
        soundPath = [NSString stringWithFormat:@"%@/%@", DOCUMENTS_FOLDER,self.strFileName] ;
        NSURL *url1 = [NSURL fileURLWithPath:soundPath];

        // NSLog(@"Recording Path:%@",url1);
        err = nil;
        recorder = [[ AVAudioRecorder alloc] initWithURL:url1 settings:recordSetting error:&err];

        if(!recorder)
        {
            // NSLog(@"recorder: %@ %d %@", [err domain], [err code], [[err userInfo] description]);
            UIAlertView *alert =[[UIAlertView alloc] initWithTitle: @"My Easy Media"
                                                           message: @"The Recording format is not supported on your device!"
                                                          delegate: nil
                                                 cancelButtonTitle:@"OK"
                                                 otherButtonTitles:nil];
            [alert show];
            [alert release];

            return;
        }

        //prepare to record
        [recorder setDelegate:self];
        [recorder prepareToRecord];
        recorder.meteringEnabled = YES;
        BOOL audioHWAvailable = audioSession.inputIsAvailable;

        if (! audioHWAvailable)
        {
            UIAlertView *cantRecordAlert = [[UIAlertView alloc] initWithTitle: @"Warning"
                                                                      message: @"Audio input hardware not available"
                                                                     delegate: nil
                                                            cancelButtonTitle:@"OK"
                                                            otherButtonTitles:nil];
            [cantRecordAlert show];
            [cantRecordAlert release];

            return;
        }

        // start recording
        [recorder record];
        _isRecordingStarted = YES;

        // SET TIMER // START TIMER
        timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(EndRecording:) userInfo:nil repeats:YES];

        // END TO SETTING TIMER
        timerDisplayRight.hidden = NO;
        timerDisplayLeft.hidden = NO;
        timerDisplayRight.text = [NSString stringWithFormat:@"%02d:%02d", intMimute,-- intSecond]; 
        timerDisplayLeft.text = [NSString stringWithFormat:@"00:00"];
        progressView.progress = 0.0;
    }
    else
    {
        isPaused=NO;
        [recorder record];   
        _isRecordingStarted = YES;
        [btnReview setEnabled:NO];

        timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(EndRecording:) userInfo:nil repeats:YES];
        timerDisplayRight.hidden = NO;
        timerDisplayLeft.hidden = NO;
    }

    timerDisplayRight.text = [NSString stringWithFormat:@"%02d:%02d", intMimute,-- intSecond];
}


-(IBAction)btnPauseClick:(id)sender
{
    // NSLog(@"Pause Button of ActionSheet Clicked");
    [timer invalidate];
    timer = nil;
    isPaused=YES;
    [recorder pause];

    [btnPause setEnabled:NO];
    [btnRecord setEnabled:YES];
    [btnStop setEnabled:YES];
}


-(IBAction)btnStopClick:(id)sender
{
    // NSLog(@"Stop Button of ActionSheet Clicked");
    [recorder stop];

    progressView.progress = 1.0;
    // NSLog(@"Total Recording Secomd : %d", totalRecordingSecond);
    finalRecordingSecond = totalRecordingSecond;

    [btnStop setEnabled:NO];
    [btnReview setEnabled:YES];
    [btnRecord setEnabled:YES];
    [btnPause setEnabled:NO];

    timerDisplayRight.text = [NSString stringWithFormat:@"%02d:%02d", (totalRecordingSecond/60), (totalRecordingSecond % 60) ];
    timerDisplayLeft.text = [NSString stringWithFormat:@"00:00"];

    [timer invalidate];
    timer = nil;

    // REINITIALIZE TIMER VARIABLES...
    intMimute =  5;
    intTotalTime = (60 * intMimute);   
    intSecond = intTotalTime / intMimute;
    intMimute--;       

    // REINITIALIZE TIMER VARIABLES...       
    _isRecordingStarted = NO;
}

Please help. Once I start recording and after near about 10 to 15 second, tap on stop.

  • 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-06-14T12:17:08+00:00Added an answer on June 14, 2026 at 12:17 pm

    I think it happen when any run any process in background in separate thread, same time when recording.

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

Sidebar

Related Questions

Currently I face the following issue - I create a custom ListView ( 1
I have run into an issue in which IE does not open up the
When I try to bottom-align text in a DIV element, I face the issue
@font-face is kind of confusing as all the browsers cannot decide on a single
I face issue parsing xhtml with DOCTYPE declaration using DOM parser. Error: java.io.IOException: Server
this get ever more complicated :) now i face another issue in last question
I know this is a very basic question - but I did not face
the issue I face seems to have no solution and to be downright impossible
I am using WCF Async methods. I face issue when I try to return
We must face serious issue while prepraing my project and working on code in

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.