react-native-fs
react-native-fs copied to clipboard
How can i scan for audio files/songs stored on local storage of iOS devices?
I am making a music player using React Native. Can someone please show me some direction on how i can load songs/audio files stored locally on clients device in JSON format and show them as a list? I found react-native-get-music-files npm library that serves the purpose but it only supports Android. Thanks.
try this https://github.com/futurice/react-native-audio-toolkit/blob/master/docs/SOURCES.md
I use react-native-sound to play files that was downloaded once before with RNFS.
@itinance did you accessed the files stored locally on iOS device?
@eslambasher playback of local files is only supported on Android. I need solutions for iOS. Can u give me some pointers?
@themakerman
@itinance did you accessed the files stored locally on iOS device?
Yes, sure. On Android the prefix "file://" is required sometimes while on iOS not.
@eslambasher have you tried "react-native-sound". I have 4 apps with this both for iOS and android that plays local audio files that was downloaded with RNFS. The same for video with react-native-video.
@eslambasher where have you stored the files? Document-Directory? Caches-Directory? You should show at least some code that people can get an idea of what you are talking about in detail
actually,I used it just to test the module but for the recordings files I have to use expo audio for recording and play file (https://docs.expo.io/versions/latest/sdk/audio.html) because my application was created with expo so I could not use the module that I should link, about expo recording i store my audio file in Caches-Directory and then i send it in my database for play it from my site.
@itinance so see i sync the files on my iOS device by connecting it to itunes. I am very new to iOS environment and have no knowledge of objective-c/swift/iOS file system. I just want someway to dump list of audio files synced with itunes [list must contain album art/path to file/title...etc] so i can render it using listView. Can anyone tell me how can i achieve this? I was thinking of rooting my iOS device to better understand where do music files go in future but if react-native-fs can help me achieve it without that it will be great.
ok i am using react-native-get-music-files@v2. v2 supports both iOS and android.
@themakerman, have you got path of music on iOS?
@ithustle yes. using react-native-get-music-files library.
@themakerman, can you show me an example? For me, only works on Android...
@ithustle Hi did you includedNSUsage permissions in your info.plist? I think you have to add key value for this corresponding permission ---> NSAppleMusicUsageDescription
Hi @themakerman. Yes, I did. It just give to me the music title, artists but not file path...
@ithustle okay let me check my code. But will take some time as i am running little busy.
@themakerman, its okay. I'll waiting...
@ithustle @themakerman @eslambasher @itinance Any update for iOS because I am getting audio files from the android devices but not for iOS. Let me know if I am doing anything wrong.
Getting issue with homepage so that is done s.homepage = "https://github.com/cinder92/react-native-get-music-files"
Here is my code.
MusicFiles.getAll({
id: true,
blured: false,
artist: true,
duration: true, //default : true
cover: true, //default : true,
title: true,
cover: true,
batchNumber: 5, //get 5 songs per batch
minimumSongDuration: 10000, //in miliseconds,
fields: [ 'title', 'artwork', 'duration', 'artist', 'genre', 'lyrics', 'albumTitle' ]
})
.then((tracks) => {
console.log('MusicFiles tracks ::::', tracks);
})
.catch((error) => {
console.log('MusicFiles error ::::', error);
});
info.plist
Now i am getting this error: TypeError: null is not an object (evaluating 'RNReactNativeGetMusicFiles.getAll')
same issue...