React Native Expo Native music library to retrieve song's albums, genres, artists, folders. (Only for working for android at the time being, Need a macbook to implements IOS part)
npm install expo-music-library
- Import
import * as MedialLibrary from "expo-music-library";
-
Request permission to access storage
let permissions = await MusicLibrary.requestPermissionsAsync(); while (!permissions.granted) { permissions = await MusicLibrary.requestPermissionsAsync(); }
-
Retrieve Audio files
const results = await MusicLibrary.getAssetsAsync({ after: lastMediaAsset, mediaType: MusicLibrary.MediaType.audio, sortBy: sortBy, });
-
Retrieve Albums
const folders = await MusicLibrary.getAlbumsAsync()
-
Retrieve Album's Songs
const albumAssets = await MusicLibrary.getAlbumAssetsAsync(albumName)
-
Retrieve Artists
const artists = await MusicLibrary.getArtistsAsync()
-
Retrieve Artist's Songs
const artistAssets = await MusicLibrary.getArtistAssetsAsync(artistId)
-
Retrieve Folders
const folders = await MusicLibrary.getFoldersAsync()
-
Retrieve Folder's Songs
const folderAssets = await MusicLibrary.getFolderAssetsAsync(folderId)
-
Retrieve Genres
const genres = await MusicLibrary.getGenresAsync()
-
Retrieve Genre's Songs
const genreAssets = await MusicLibrary.getGenreAssetsAsync(genreId)
If my you find my work usefull and want to support me, kindly buy me a coffee here