question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to stopAndUnloadAsync a recording that just got started

See original GitHub issue

Reproducible Demo

https://snack.expo.io/rJ6j67G6f

After calling await recording.startAsync(), it needs at least ~300ms before recording.stopAndUnloadAsync() can be called, otherwise it’ll fail and subsequent startAsync calls will result in

error: Only one Recording object can be prepared at a given time.

Tested on Android.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:16
  • Comments:15 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
Arykcommented, Oct 21, 2020

For anyone who needs this fix on managed until the SDK 40 release comes out…

          try {
            await recordRef.current.stopAndUnloadAsync();
          } catch (e) {
            if (e.message.includes("Stop encountered an error: recording not stopped")) {
              await ExponentAV.unloadAudioRecorder();
              await recordRef.current._cleanupForUnloadedRecorder({durationMillis: 0} as any);
            } else {
              await handleError(e, {userMessage: "An error occurred stopping the recording."});
            }
          } finally {
            recordRef.current = undefined;
            timerStop();
            success = true;
          }
2reactions
cwilbycommented, Feb 28, 2020

I had this issue after getting overly ES6.

const { recording: { stopAndUnloadAsync } } = this;

await stopAndUnloadAsync(); // causes error

vs

await this.recording.stopAndUnloadAsync();

This allows stopAndUnloadAsync to correctly evaluate this._canRecord.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Expo-av audio recording - Stack Overflow
Save this question. Show activity on this post. I'm trying to record audio with expo-audio but it's showing an error when I start...
Read more >
Audio - Expo Documentation
Creates and loads a new Sound object to play back the Recording . Note that this will only succeed once the Recording is...
Read more >
Expo-av audio recording : r/reactnative - Reddit
I 'm trying to record audio with expo-audio but it's showing an error when I start recording Error: Only one Recording object can...
Read more >
How to Record Audio using React Native Expo
Allow the permission asked. Start and stop the recording accordingly. Now see your command prompt or terminal, you will see the location of...
Read more >
How To Create An Audio/Video Recording App With React ...
During the video recording, we can't receive the recording status as we have done for audio. That's why I have created a function...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found