Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do we stop and save a recording when an interruption occurs while recording audio using AVAudioRecorder while animating the navigation bar?
    primarykey
    data
    text
    <p>I'm animating the navigation bar using a timer when recording starts and stopping it when the recording stops (to make it similar to the Voice Memos app).</p> <p>Here is the code</p> <pre><code>//do nav bar animation _navigationImageCount = 0; self.navigationBarTimer = [NSTimer scheduledTimerWithTimeInterval:(2.0 / 28.0) target:self selector:@selector(changeNavigationBarImage:) userInfo:nil repeats:YES]; - (void)changeNavigationBarImage:(NSTimer *)timer { NSMutableArray *navigationBarImages = [NSMutableArray arrayWithArray:@[@"nav_bar_01.png", @"nav_bar_02.png", @"nav_bar_03.png", @"nav_bar_04.png", @"nav_bar_05.png", @"nav_bar_06.png", @"nav_bar_07.png", @"nav_bar_08.png", @"nav_bar_09.png", @"nav_bar_10.png", @"nav_bar_11.png", @"nav_bar_12.png", @"nav_bar_13.png", @"nav_bar_14.png"]]; [navigationBarImages addObjectsFromArray:[[navigationBarImages reverseObjectEnumerator] allObjects]]; NSInteger imageIndex = _navigationImageCount % 28; [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:navigationBarImages[imageIndex]] forBarMetrics:UIBarMetricsDefault]; _navigationImageCount++; } - (void)audioRecorderBeginInterruption:(AVAudioRecorder *)recorder { [recorder stop]; [self.recordingTimer invalidate]; //timer used to update the UI [self.navigationBarTimer invalidate]; } </code></pre> <p>I am saving the recording to a file to a directory named "MyRecordings" under the Library directory and if print the contents of that directory it shows the file, however when I try to print the duration it gives 0.</p> <p>If I try to play the file at that url it gives error code 1685348671 (file invalid).</p> <p>How can the save the first part of the recording be saved properly?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload