react-native-live-audio-stream
react-native-live-audio-stream copied to clipboard
[help] How to play the received data on "data" emit?
LiveAudioStream.on("data", (data) => {
// play the data as audio
});
I want to use this in socket, hence I don't want to export an audio file, and just want to play whatever I receive.
I figured out I should play the data using AudioTrack
from Android API, so I created a fork and added couple of functionalities. Check it out here: https://github.com/xiqi/react-native-live-audio-stream/pull/26
I still don't know (and don't need to) play the data on iOS.
https://github.com/theInfiTualEr/react-native-live-audio-stream/ also addresses playing the audio recorded in Android on Web (It generates wav audio header). Still, no iOS support.
Hello @theInfiTualEr, I'm using your version and it works fine, i can read the data with the header and play it using LiveAudioStream.addPlay
. However I also would like to store this data to be read elsewhere, but when I do this I can't manage to open the stored file in any player, ffmpeg also gives an error.
This is how I store the data:
LiveAudioStream.on("data", data => {
RNFS.writeFile(`${ExternalCachesDirectoryPath}/test-audio-{new Date().getDate()}.wav`, data)
.then(() => console.log("wrote"))
.catch(err => console.log(err));
});
Do you happen to have any idea how one could store the contents from data and play it in other machines?
Do you happen to have any idea how one could store the contents from data and play it in other machines?
Checkout https://github.com/goodatlas/react-native-audio-record