1

There!

I'm trying to get a song thumbnail in React Native (Expo). 1. I fetch all songs from device storage. 2. I push it to different components.

But I can't get an image for a song that user chooses. I don't where can I find that.

So, hope you will help me. Thanks!

Code:

async componentDidMount() {
    /* Ask READ_EXTERNAL_STORAGE, WRITE_EXTERNAL_STORAGE permissions */
    const { status } = await Permissions.askAsync(
        Permissions.CAMERA_ROLL
    );

    if(status === 'granted') { // IF ok THEN read music
        const media = await MediaLibrary.getAssetsAsync({
            mediaType: MediaLibrary.MediaType.audio,
            sortBy: MediaLibrary.SortBy.modificationTime
        });
        this.props.uploadSongsList(media);
    } else { // Cast error
        this.props.castError("We haven't got permissions to read your music files.");
    }
}

That's the way how I fetch songs. Still, I receive id, filename, and some other stuff, but need preview image.

oles
  • 166
  • 1
  • 2
  • 10

0 Answers0