jsierles / react-native-audio

Audio recorder library for React Native
MIT License
1.16k stars 539 forks source link

AudioRecorder.onProgress not being called on iOS simulator #362

Closed bmbmjmdm closed 4 years ago

bmbmjmdm commented 4 years ago

Version

Tell us which versions you are using ( you can see the versions in your package.json ):

react-native-audio : "^4.3.0" react-native : "0.62.0-rc.1" react : "16.11.0" using react-native-sound ? Yes

Expected behaviour :

Setting up a callback with AudioRecorder.onProgress should trigger the callback after AudioRecorder.startRecording() is called

Actual behaviour

While this does appear to work on my android physical device, it does NOT appear to work on my iOS simulator

Steps to reproduce

I'll just paste the code:

    promptSpeaking () {
            AudioRecorder.prepareRecordingAtPath(this.filePath, { MeteringEnabled: true })

            AudioRecorder.onProgress = (data) => {
                console.log("progress")
            }

            this.animateWithSound({
                callback: ( ) => {
                    this.finishAnimateWithSound()
                    AudioRecorder.startRecording()
                    setTimeout(this.stopRecording, 5000)
                }
            })
        },

I can confirm stopRecording gets called after 5 seconds, which means AudioRecorder.startRecording must have been called too. However I don't see any "progress" logs in the console.

Link to a git repo that reproduces bug

https://github.com/bmbmjmdm/wesley-app

bmbmjmdm commented 4 years ago

I found the problem! The file could not be created/written to because I was not explicitly setting the proper AudioEncoding


AudioRecorder.prepareRecordingAtPath(audioPath, {
  AudioEncoding: "aac"
});