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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T20:38:28+00:00 2026-06-02T20:38:28+00:00

I set up an AVAudioRecorder instance the following way when my view loads: AVAudioSession

  • 0

I set up an AVAudioRecorder instance the following way when my view loads:

AVAudioSession *audioSession = [AVAudioSession sharedInstance];
audioSession.delegate = self;
[audioSession setActive:YES error:nil];
[audioSession setCategory:AVAudioSessionCategoryRecord error:nil];

NSString *tempDir = NSTemporaryDirectory();
NSString *soundFilePath = [tempDir stringByAppendingPathComponent:@"sound.m4a"];

NSURL *soundFileURL = [NSURL fileURLWithPath:soundFilePath];
NSLog(@"%@", soundFileURL);

NSDictionary *recordSettings = [NSDictionary dictionaryWithObjectsAndKeys:
                                [NSNumber numberWithInt:kAudioFormatMPEG4AAC], AVFormatIDKey,
                                [NSNumber numberWithInt:AVAudioQualityMin], AVEncoderAudioQualityKey,
                                [NSNumber numberWithInt:16], AVEncoderBitRateKey,
                                [NSNumber numberWithInt: 1], AVNumberOfChannelsKey,
                                [NSNumber numberWithFloat:8000.0], AVSampleRateKey,
                                [NSNumber numberWithInt:8], AVLinearPCMBitDepthKey,
                                nil];

NSError *error = nil;

self.recorder = [[AVAudioRecorder alloc]
                 initWithURL:soundFileURL
                 settings:recordSettings
                 error:&error];
self.recorder.delegate = self;

if (error) {
    NSLog(@"error: %@", [error localizedDescription]);
} else {
    [self.recorder prepareToRecord];
}

Then, when the user presses the record button I do:

- (IBAction)record:(id)sender {
    if (!self.isRecording) {
        self.isRecording = YES;
        [self.recorder record];
        self.recordButton.enabled = NO;
    }
}

Then to stop the recording/playback:

- (IBAction)stop:(id)sender {
    if (self.isRecording) {
        [self.recorder stop];
        self.recordButton.enabled = YES;
        self.isRecording = NO;
    }

    if (self.isPlaying) {
        [self.player stop];
        self.isPlaying = NO;
        self.playButton.enabled = YES;
    }
}

After, I want to be able to playback what was recorded, so I do the following:

- (IBAction)play:(id)sender {
    NSError *error = nil;
    self.player = [[AVAudioPlayer alloc] initWithContentsOfURL:self.recorder.url error:&error];
    self.player.delegate = self;

    if (error) {
        NSLog(@"%@", error.localizedDescription);
    } else {
        self.isPlaying = YES;
        [self.player play];
        self.playButton.enabled = NO;
    }
}

But when I go and play the file is get OSStatus error -43 file not found.

This is all running on the device btw, on the simulator y an error when trying to instantiate the recorder or player, and from I’ve seen it’s a simulator issue.

EDIT 1: I solved the OSStatus error -43 part it has something to do with the encoding format, I commented out the format and it recorded and played the file properly, but I need to record in a compressed format. Does anyone know the settings for this?

EDIT 2: I managed to find settings that worked for compressed AAC audio. A 2min audio file comes out to 256KB, I updated my code to reflect the current state. Thanks to all of those who answered for your help.

  • 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-02T20:38:29+00:00Added an answer on June 2, 2026 at 8:38 pm

    I’m gonna take a wild stab at this since no-one else has answered (EDIT: now there is) (I don’t have much experience with Audio in iOS) but…

    Try changing

    [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryRecord error:nil];
    

    to

    [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord error:nil];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER VIEW [dbo].[viewProductExportUpdated2] AS SELECT dbo.ProductCategories.ProductCategoryID
Set oXMLHttp=Server.CreateObject(MSXML2.XMLHTTP) On Error Resume Next oXMLHttp.open GET, http://xxxxxx.com,False oXMLHttp.setRequestHeader Content-Type, application/x-www-form-urlencoded oXMLHttp.send() x
set visible = true then message box show it is false delegate void LoadLastDeptSettingDelegate(String
Set<Type> union = new HashSet<Type>(s1); union.addAll(s2); AND Set <Type> union = new HashSet<Type>(); union.addAll(s1);
Set content of table ... ViewState[Table1] = Table1; // When remove this line, table
Set rs = conn.Execute(Statement) //rs has 6 fields I want to add the current
set dateformat dmy select isdate('31/1/2012') I thought by going into Change the format of
SET @v1 := SELECT COUNT(*) FROM user_rating; SELECT @v1 When I execute this query
I set up multiple NSUserDefaults in my app that work for the most part.
I set the font-family in the jquery.jwysiwyg.js (line-# 497 where < body > is

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.