react-native-audio-recorder-player
react-native-audio-recorder-player copied to clipboard
Example on Android, Mac: Recording Silent When Played Back
Version of react-native-audio-recorder-player
3.5.1
Version of React Native
0.66.3
Platforms you faced the error (IOS or Android or both?)
Android emulator, running on a Macbook (Intel)
Expected behavior
Pressing "Play" (in the Example app) should result in a previously recorded sound being played back, audibly.
Actual behavior
Pressing "Play" (in the Example app), after recording a sound results in silence (for the same duration that was recorded). I have ensured that the volume for the android emulator is at its maximum.
Steps to reproduce the behabior
Reviewing the log statements, it LOOKS like although the Android emulator is the target platform, iOS values are being used for "audioSet" (see below)... Is this expected? Could this be the problem?
LOG Running "RNAudioRecorderPlayer" with {"rootTag":1}
LOG write external stroage {"android.permission.READ_EXTERNAL_STORAGE": "granted",
"android.permission.RECORD_AUDIO": "granted", "android.permission.WRITE_EXTERNAL_STORAGE": "granted"}
LOG permissions granted
LOG audioSet {
"AVEncoderAudioQualityKeyIOS": 96,
<-- iOS value - but running Android emulator (running on a Mac)
"AVFormatIDKeyIOS": "aac",
<-- iOS value - but running Android emulator (running on a Mac)
"AVNumberOfChannelsKeyIOS": 2,
<-- iOS value - but running Android emulator (running on a Mac)
"AudioEncoderAndroid": 3,
"AudioSourceAndroid": 1}
LOG uri: file:////data/user/0/com.rnaudiorecorderplayer/cache/sound.mp4
LOG file:////data/user/0/com.rnaudiorecorderplayer/cache/sound.mp4
LOG onStartPlay
LOG file: /data/user/0/com.rnaudiorecorderplayer/cache/sound.mp4 volume: set volume
The same problem.
@YevheniiImpltech, @hyochan - I found that if you enter: adb emu avd hostmicon
, it enables audio on the android emulator on MacOS.
I've appended this command to the "android" script in package.json:
"android": "react-native run-android && adb emu avd hostmicon"
.
This is how i solved the problem -> Extended controls (3 dots in emulator control bar) > Microphone > Virtual microphone uses host audio input
https://stackoverflow.com/questions/5924190/how-do-you-enable-a-microphone-input-in-the-android-emulator
Good to know - thanks for the tip!