goodatlas / react-native-audio-record

Audio record buffers for React Native (iOS and Android)
MIT License
176 stars 100 forks source link

Storing base64 data in a variable #12

Closed StevenJW closed 5 years ago

StevenJW commented 5 years ago

Recording is working however, I'm trying to store the data that I'm receiving through

AudioRecord.on('data', data => {
  // base64-encoded audio data chunks
});

in a variable. However, it's not working for some reason and I'm really struggling with this. I've tried doing this (within a function):

var tempString = '';
AudioRecord.on('data', data => {
  tempString += data;
});

but it only gives the first part of the data. If I just set it to the data and output it, it does gives different data but never when I try to add all the data together. I've tried arrays, listening to a changing variable and using another function but for some reason they all just gave the first data that is received if I used a similar method to the one I described above. So how do I store all the data that I get from a 3 second audio recording in a variable?

CarlosdpdClluc commented 5 years ago

Did you find any solution to this issue?

StevenJW commented 5 years ago

It turned out it was working after all, was an issue on my end.

xKRUTOIx commented 5 years ago

@StevenJW I'm happy that you've found the solution! I'm struggling with the same problem atm : ) Could you tell me please, how did you decide to store data in a var?