I have tried several methods found on internet, but may be because i would be missing something, so i wasn’t able to achieve that i wanted. Is there any config, that i need to add so to add that file in the app bundle and can we accessible.
here are some references that i tried:
- In React Native how do you bundle a text file and read it’s value at runtime?
- React Native import audio file from android res (but i am using the react native track player).
- https://github.com/doublesymmetry/react-native-track-player/issues/967
I stored that mp3 file in android/app/src/main/assets only but in the url if i provide this or any path it isn’t accessible even used the require also , but that too didn’t worked for me.
let path;
RNFS.readFileAssets('omchant.mp3', 'base64')
.then((res) => {
console.log(':the file found');
// path = ;
})
.catch((er) => console.log('teh error in the file path ==>', er));
await TrackPlayer.add([
{
id: 1,
url: require("/android/app/src/main/assets/filename.mp3"),
title: 'Fluidity',
artist: 'tobylane',
},
]);
but didn’t goes as expected.