react-native-get-music-files: RNAndroidAudioStore TypeError: Cannot read property 'getSongs' of undefined
Hello, I’m trying to use RNAndroidAudioStore as mentioned by @Drazail in https://github.com/cinder92/react-native-get-music-files/issues/42#issuecomment-473815037 but it seems to be undefined.
I’m importing it like so:
import MusicFiles, { RNAndroidAudioStore } from 'react-native-get-music-files';
Is this is a recent addition to react-native-get-music-files? Do I need to update the lib to make it work or what?
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 15 (9 by maintainers)
@eff-society
unfortunately the
ALBUM_ARTconstant ofMediaStore.Audio.AlbumColumnswas deprecated in API levelQand always returnsnull, so there is no way of accessing the covers android extracts on each scan. the only way to get the covers currently is to extract the metadata directly from the file itself, save it and send the path over to JS, which as you can imagine is very slow. here i can think of two solutions:1- you can use other methods of
RNAndroidAudioStore, for instance, you can query the songs usingsearchorgetSongs, and then get the covers of the songs you want to show to the user viagetSongByPath({songUri: 'path to the song', cover: true}).2- if you are using the development branch of my fork ( i made a pull request yesterday, so it should be merged into masters branch of this repo soon) you can use
RNAndroidAudioStore.getAllwithbatchNumberanddelayoptions specified to implement some sort of pagination.having said that, I do understand the importance of proper pagination. we have internally implemented pagination for
RNAndroidAudioStore.search, however it hasn’t been tested yet, will add it to this module as soon as that’s done.@eff-society yes, this is a new addition, you will need to install the package via GitHub and follow the instructions given here specifically these steps:
you can also find the example app here
please note that the default export of the module has not been changed, so this update should be 100% backwards compatible.
I am sorry for the inconvenience, will make a pull request with updated docs as soon as possible.
ps. pagination isn’t implemented on RNAndroidAudioStore’s methods yet and will be added in the next pull request.