Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[help] How to play the received data on "data" emit? #25

Open
theInfiTualEr opened this issue Sep 20, 2023 · 4 comments
Open

[help] How to play the received data on "data" emit? #25

theInfiTualEr opened this issue Sep 20, 2023 · 4 comments

Comments

@theInfiTualEr
Copy link

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.

@theInfiTualEr
Copy link
Author

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: #26

I still don't know (and don't need to) play the data on iOS.

@theInfiTualEr
Copy link
Author

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.

@Artotim
Copy link

Artotim commented Feb 2, 2024

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?

@theInfiTualEr
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants