1.0.5 • Published 5 years ago

mediafile-fetch v1.0.5

Weekly downloads
24
License
-
Repository
-
Last release
5 years ago

mediafile-fetch

React Native package to get music files from local and sd for Android(only)

Getting started

$ npm install mediafile-fetch --save

Mostly automatic installation

$ react-native link mediafile-fetch

Manual installation

Android

  1. Open up android/app/src/main/java/[...]/MainActivity.java
  • Add import com.confi.mediafiles.RNMediafileFetchPackage; to the imports at the top of the file
  • Add new RNMediafileFetchPackage() to the list returned by the getPackages() method
  1. Append the following lines to android/settings.gradle:
    include ':mediafile-fetch'
    project(':mediafile-fetch').projectDir = new File(rootProject.projectDir, 	'../node_modules/mediafile-fetch/android')
  2. Insert the following lines inside the dependencies block in android/app/build.gradle:
      compile project(':mediafile-fetch')

Usage

import AllMusic from 'mediafile-fetch';

componentDidMount(){
        AllMusic.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(tracks)).catch((err) => console.log(err));
}

It returns an array of objects where you can loop, something like this.

[
  {
    id : 1,
    title : "La danza del fuego",
    author : "Mago de Oz",
    album : "Finisterra",
    genre : "Folk",
    duration : 132132312321, // miliseconds
    cover : "file:///sdcard/0/123.png",
    blur : "file:///sdcard/0/123-blur.png", //Will come null if createBLur is set to false
    path : "/sdcard/0/la-danza-del-fuego.mp3"
  }
]