audiocogs / aurora.js

JavaScript audio decoding framework
http://audiocogs.org/codecs
1.26k stars 185 forks source link

aurora.js with react-native #200

Open iPhaeton opened 7 years ago

iPhaeton commented 7 years ago

Hi, is it possible to use aurora.js with react-native? I tried this method: https://medium.com/@aakashns/using-core-node-js-modules-in-react-native-apps-64acd4d07140 an managed to have aurora.js read an asset from file using AV.Asset.fromFile();. But when I try asset.decodeToBuffer(), I get the following error:

Failed to execute 'readAsArrayBuffer' on 'FileReader': parameter 1 is not of type 'Blob'.

shavavo commented 4 years ago

Hi, could you share how you resolved this?

iPhaeton commented 4 years ago

Hi. It was a long time ago... If I'm not mistaking, I had to read a file into a buffer and create the asset from that buffer, like this:

import RNFS from 'react-native-fs';
import b64AB from 'base64-arraybuffer';

...

const file = await RNFS.readFile(path, 'base64');
const buffer = b64AB.decode(file);
const asset = AV.Asset.fromBuffer(buffer);