{"id":13777344,"url":"https://github.com/cinder92/react-native-get-music-files","last_synced_at":"2025-05-11T11:33:21.560Z","repository":{"id":37359608,"uuid":"79403022","full_name":"cinder92/react-native-get-music-files","owner":"cinder92","description":"React Native package to get music files from local and sd for iOS and Android","archived":false,"fork":false,"pushed_at":"2024-04-11T12:44:46.000Z","size":1568,"stargazers_count":124,"open_issues_count":4,"forks_count":63,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-05-07T05:21:34.527Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cinder92.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-01-19T01:32:54.000Z","updated_at":"2024-08-03T18:10:49.087Z","dependencies_parsed_at":"2023-02-01T08:30:58.311Z","dependency_job_id":"2a270f22-fbc2-4df5-a72d-9976b84f53f7","html_url":"https://github.com/cinder92/react-native-get-music-files","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cinder92%2Freact-native-get-music-files","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cinder92%2Freact-native-get-music-files/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cinder92%2Freact-native-get-music-files/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cinder92%2Freact-native-get-music-files/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cinder92","download_url":"https://codeload.github.com/cinder92/react-native-get-music-files/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225043093,"owners_count":17411927,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T18:00:41.910Z","updated_at":"2024-11-17T13:30:39.249Z","avatar_url":"https://github.com/cinder92.png","language":"Kotlin","funding_links":[],"categories":["\u003ca name=\"OS-\u0026-System-\u0026-File-Manager:-Native-Modules\"\u003eOS, System \u0026 File Manager: Native Modules\u003c/a\u003e","Kotlin"],"sub_categories":[],"readme":"# react-native-get-music-files\nReact Native package to get music files from local and sd for iOS and Android\n# What does this package?\n\nThis package allow you to get music files from Android \u0026 iOS with following properties:\n\n* Title\n* Author\n* Album\n* Duration\n* FilePath\n* Cover\n* Duration\n* Genre\n## Getting started\n\n`$ yarn add react-native-get-music-files`\nor \n`$ yarn add https://github.com/cinder92/react-native-get-music-files.git`\n\n#### iOS\n\n1. Add in `info.plist` following permission\n```\n\u003ckey\u003eNSAppleMusicUsageDescription\u003c/key\u003e\n\u003cstring\u003eThis permission is not needed by the app, but it is required by an underlying API. If you see this dialog, contact us.\u003c/string\u003e\n``` \n2. Add MediaPlayer.framework under build settings in Xcode\n3. Ensure all your music files are sync from a computer to a real iPhone device (this package does not work in simulators)\n\n#### Android\n\n1. Navigate to `android/app/src/main/AndroidManifest.xml` and ensure to add this permission\n```\n\u003cuses-permission android:name=\"android.permission.READ_EXTERNAL_STORAGE\"/\u003e\n\u003cuses-permission android:name=\"android.permission.READ_MEDIA_AUDIO\"/\u003e \u003c-- Add this for Android 13 and newer versions\n```\n\n## Before usage\n\nAs this package needs permissions from the device, please ensure that you asked for permissions before run any of this package functions.\n\n## Constants\n```js\nSortSongFields {\n    TITLE, DURATION, ARTIST, GENRE, ALBUM\n}\n\nSortSongOrder {\n    ASC, DESC\n}\n```\n\n## Usage\n```js\n\nimport { getAll, getAlbums, searchSongs, SortSongFields, SortSongOrder } from \"react-native-get-music-files\";\n\n\nconst songsOrError = await getAll({\n    limit: 20,\n    offset: 0,\n    coverQuality: 50,\n    minSongDuration: 1000,\n    sortBy: SortSongFields.TITLE,\n    sortOrder: SortSongOrder.DESC,\n});\n\n// error \nif (typeof songsOrError === 'string') {\n    // do something with the error\n    return;\n}\n\nconst albumsOrError = await getAlbums({\n    limit: 10,\n    offset: 0,\n    coverQuality: 50,\n    artist: 'Rihanna',\n    sortBy: SortSongFields.ALBUM,\n    sortOrder: SortSongOrder.DESC,\n});\n\n// error \nif (typeof albumsOrError === 'string') {\n    // do something with the error\n    return;\n}\n\nconst resultsOrError = await searchSongs({\n    limit: 10,\n    offset: 0,\n    coverQuality: 50,\n    searchBy: '...',\n    sortBy: SortSongFields.DURATION,\n    sortOrder: SortSongOrder.DESC,\n});\n\n// error \nif (typeof resultsOrError === 'string') {\n    // do something with the error\n    return;\n}\n```\n\nMusicFiles returns an array of objects where you can loop, something like this.\n\n```js\n[\n  {\n    title : \"La danza del fuego\",\n    author : \"Mago de Oz\",\n    album : \"Finisterra\",\n    genre : \"Folk\",\n    duration : 209120,\n    cover : \"data:image/jpeg;base64, ....\",\n    url : \"/sdcard/0/la-danza-del-fuego.mp3\"\n  }\n]\n```\n\n  \n#### Return Types\n* Album\n\n    Type: Object\n    \n    | property \t| type \t| description \t|\n    |---------------:\t|:--------:\t|-------------------------------\t|\n    | album \t| string \t| album name \t|\n    | artist \t| string \t| author \t|\n    | cover \t| string \t| base64 of the artwork \t|\n    | numberOfSongs \t| number \t| number of songs in this album \t|\n\n* Song\n\n    | property \t| type \t| description \t|\n    |---------------\t|--------\t|-------------------------------\t|\n    | title \t| string \t| title\t|\n    | artist \t| string \t|  artist\t|\n    | album \t| string \t|  album name\t|\n    | duration \t| string \t|  duration in ms\t|\n    | genre \t| string \t|  genre\t|\n    | cover \t| string \t|  base64 of the artwork\t|\n    | url \t| string \t| path of the song \t|\n\n\n#### Methods\n\n* ##### getAlbums\n    \n    `async getAlbums(options) → {Promise\u003cAlbum[] | string\u003e}`\n\n    * options\n    \n        Type: Object\n        \n        | property \t| type \t| description \t|\n        |---------------\t|--------\t|-------------------------------\t|\n        | artist  \t| string \t|  required\t|\n        | limit  \t| number \t|  optional\t|\n        | offset  \t| number \t|  required if limit set\t|\n        | coverQuality  \t| number \t|  optional\t|\n        | sortBy     |  string | optional |\n        | sortOrder   | string  | optional |\n\n    * returns\n  \n        Type: Albums\n        Error: string\n* ##### getAll\n    \n    `async getAll(options) → {Promise\u003cSong[] | string\u003e}`\n    \n    * options\n    \n        Type: Object\n        \n        | property \t| type \t| description \t|\n        |---------------\t|--------\t|-------------------------------\t|\n        | limit  \t| number \t|  optional\t|\n        | offset  \t| number \t|  required if limit set\t|\n        | coverQuality  \t| string \t|  optional\t|\n        | minSongDuration  \t| number \t|  optional\t|\n        | sortBy     |  string | optional |\n        | sortOrder   | string  | optional |\n        \n    * returns\n    \n        Type: Song\n        Error: string\n* ##### searchSongs\n    \n    `async searchSongs(options) → { Promise\u003cSong[] | string\u003e }`\n    \n    * options\n    \n        Type: Object\n        \n        | property \t| type \t| description \t|\n        |---------------\t|--------\t|-------------------------------\t|\n        | searchBy  \t| string \t|  required\t|\n        | limit  \t| number \t|  optional\t|\n        | offset  \t| number \t|  required if limit set\t|\n        | coverQuality  \t| number \t|  optional\t|\n        | sortBy     |  string | optional |\n        | sortOrder   | string  | optional |\n   \n    * returns\n        Type: Song\n        Error: string\n\n## Usage:\n\n[example app](https://github.com/cinder92/react-native-get-music-files/tree/master/example)\n\n# Version Changes\n\n# 2.2\n\n- [x] Android \u0026 iOS compatible\n- [x] Retro-compat turbo module\n- [x] Limit \u0026 offset to paginate results\n- [x] Compatible with `https://github.com/zoontek/react-native-permissions`\n\nPR are welcome!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcinder92%2Freact-native-get-music-files","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcinder92%2Freact-native-get-music-files","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcinder92%2Freact-native-get-music-files/lists"}