Closed ThalKod closed 5 years ago
@ThalKod
Please provide more information likr:
@Drazail I'm using RN 0.59.8, with react-native-get-music-files@2.1.0 running on Android API 28. This is how i'm trying to use it after installation:
...
import MusicFiles from "react-native-get-music-files";
...
useEffect(() => {
navigation.setParams({ handleModal });
fetchMusic();
}, []);
const fetchMusic = async () => {
const status = await Permissions.request('storage');
if(status !== "authorized"){
Alert.alert(
"We can't access your music",
);
}
MusicFiles.getAll({
blured : true, // works only when 'cover' is set to true
artist : true,
duration : true, //default : true
genre : true,
title : true,
cover : true,
minimumSongDuration : 10000,
fields : ['title','albumTitle','genre','lyrics','artwork','duration']
}).then(tracks => {
console.log(tracks)
}).catch(error => {
console.log("error",error);
})
};
...
I'm getting this :
@ThalKod is there any music files on the device?
@Drazail I Added two music files(.mp3
) on the device, they are located in the Downloads/
folder , but i still have the same error...
Any idea what might be the problem ?
@ThalKod
I haven't developed getMusicFiles
class, however after taking a brief look, this error seems to be thrown when the corresponding database table is empty.
Try rebooting the device and check if the problem goes away.
@Drazail Thanks, I reboot the app and it's working(fetched the two music files), but i can see two issues with that:
@ThalKod
you should perform a manual scan in order to access newly added files ( an automatic scan happens on reboot). Most file system management modules ( such as rn-fetch-blob) do offer this feature.
in this case not throwing an error seems to be the expected behavior.
You'd expect "Something get wrong with musicCursor" to go into the catch block, but it doesn't. So basically for now we need to check if (typeof tracks === 'object') { return tracks } else { return [] }
I'm Trying to use the module on Android, but i'm having
Something get wrong with musicCursor
Unable to fetch any musics files...