xiqi / react-native-live-audio-stream

Get live audio stream data for React Native (works for iOS and Android)
MIT License
71 stars 29 forks source link

[Unhandled promise rejection: TypeError: null is not an object (evaluating 'RNLiveAudioStream.init')] #2

Open harivickyhvw opened 3 years ago

harivickyhvw commented 3 years ago

[Unhandled promise rejection: TypeError: null is not an object (evaluating 'RNLiveAudioStream.init')]

I am receiving this error while trying to use this npm package, any solutions?

Thanks in advance

xiqi commented 3 years ago

Try to rebuild the project and install it again if you are running on physical devices.

dorthwein commented 2 years ago

I'm running into this as well unfortunately. If init is called at boot, I get the above null error, if init is called just before calling start() then it says calling on an uninitialized recorder :(

Tried rebuilding the project from android studio already as well. Great package otherwise, works awesome on ios.

dorthwein commented 2 years ago

Wanted to add a fix here. My issue was 2 fold,

(1) The root issue was not having microphone permissions granted.
(2) The other issue is I think the documentation has us using an out of date name for microphone permissions. The below code worked for me!

    Permissions.request("android.permission.RECORD_AUDIO").then(permission => {      
      const options = {
        sampleRate: 16000, // default 44100
        channels: 1, // 1 or 2, default 1
        bitsPerSample: 16, // 8 or 16, default 16
        audioSource: 6, // android only (see below)
        bufferSize: 4096 * 2 // default is 2048
      }
      AudioRecord.init(options)
      AudioRecord.start()
    })
morqxecho-string commented 2 years ago

Same problem :(

tayyab-tariq commented 1 year ago

I am using Expo and already gave permission to record audio but still getting the same error.