react-native-get-music-files-v3dev-test
TypeScript icon, indicating that this package has built-in type declarations

3.1.5 • Public • Published

react-native-get-music-files

Instalation

$ npm i react-native-get-music-files-v3dev-test

Imports

import MusicFiles, {
  Constants,
  CoverImage
} from "react-native-get-music-files-v3dev-test";

Constants

{
  SortBy: {
    Artist: 'ARTIST',
    Album: 'ALBUM',
    Title: 'TITLE',
  },
  SortOrder: {
    Ascending: 'ASC',
    Descending: 'DESC',
  },
}
 

example

 
import {Constants} from 'react-native-get-music-files-v3dev-test';
 
const sortBy = Constants.SortBy.Title,
const sortOrder = Constants.SortOrder.Ascending,
 

Methods

search

options

all attributes of the options object are optional

{
  searchParam?: string,
  batchNumber?: string,
  batchSize?: string,
  sortBy?: string,
  sortOrder?: string,
}

returns

{
  "results": {
    id: number,
    path: string,
    duration: number,
    album: string,
    artist: string,
    title: string
    }[],
  "length": number
}

example

 
search = searchParam => {
      MusicFiles.search({
        "searchParam",
        batchSize: 0,
        batchNumber: 0,
        sortBy: Constants.SortBy.Title,
        sortOrder: Constants.SortOrder.Ascending,
      })
        .then(f => {
          console.log(f);
        })
        .catch(er => console.log(e));
    };

getAll

options

all attributes are optional

{
  cover?: boolean,
  coverFolder?: string,
  minimumSongDuration?: number,
  batchSize?: number,
  batchNumber?: number,
  sortBy?: string,
  sortOrder?: string,
}

returns

{
  "results":{
    id: number,
    path: string,
    cover: string,
    duration: number,
    album: string,
    artist: string,
    title: string

  }[],
  "length" : number
}

example

getAll = () => {
  MusicFiles.getAll({
    cover: false,
    batchSize: 0,
    batchNumber: 0,
    sortBy: Constants.SortBy.Title,
    sortOrder: Constants.SortOrder.Ascending
  })
    .then(f => {
      console.log(f);
    })
    .catch(er => console.log(e));
};

getSongByPath

options

all attributes are optional

{
  cover?: boolean,
  coverFolder?: string,
  path?: string,
}

returns

{
  id: number,
  path: string,
  cover: string,
  duration: number,
  album: string,
  artist: string,
  title: string
}[]

example

getSongByPath = () => {
  MusicFiles.getSongsByPath({
    cover: true,
    coverFolder: "pathToCoverFolder",
    path: "pathToSong"
  })
    .then(f => {
      console.log(f);
    })
    .catch(er => console.log(e));
};

getSongByPaths

scans a directory

options

{
  path: string,
  minFileSize: number,
  maxFileSize: number,
  extensionFilter: string,
}[]

returns

{
  id: number,
  path: string,
  cover: string,
  duration: number,
  album: string,
  artist: string,
  title: string
}[]

example

getSongByPaths = () => {
  MusicFiles.getSongsByPaths({
    path: "URI",
    minFileSize: 0,
    maxFileSize: 1024,
    extensionFilter: ".mp3"
  })
    .then(f => {
      console.log(f);
    })
    .catch(er => console.log(e));
};

getArtists

options

all attributes are optional

{
batchSize?: number,
batchNumber?: number,
sortBy?: string,
sortOrder?: string,
}

returns

{
  "results": {
    artist: string,
    numberOfAlbums: number,
    numberOfSongs: number,
  }[],
  "length": number
}

example

getArtists = () => {
  MusicFiles.getArtists({
    batchSize: 0,
    batchNumber: 0,
    sortBy: Constants.SortBy.Artist,
    sortOrder: Constants.SortOrder.Ascending
  })
    .then(f => {
      console.log(f);
    })
    .catch(er => console.log(e));
};

getAlbums

options

all attributes are optional

{
artist?: string,
batchSize?: number,
batchNumber?: number,
sortBy?: string,
sortOrder?: string,
}

returns

{
  results": {
    id: string,
    album: string,
    artist: string,
    numberOfSongs: number,
    firstYear: number,
    lastYear: number,
  }[],
  "length": number
}

example

getAlbums = () => {
  MusicFiles.getAlbums({
    artist: "searchParam",
    batchSize: 0,
    batchNumber: 0,
    sortBy: Constants.SortBy.Artist,
    sortOrder: Constants.SortOrder.Ascending
  })
    .then(f => {
      console.log(f);
    })
    .catch(er => console.log(e));
};

getSongs

options

all attributes are optional

{
artist?: string,
album?: string,
batchSize?: number,
batchNumber?: number,
sortBy?: string,
sortOrder?: string,
}

returns

{
 "results": {
     id: string,
     title: string,
     album: string,
     artist: string,
     duration: number,
     path: string,
 }[],
 "length": number
}

example

getSongs = () => {
  MusicFiles.getSongs({
    artist: "artist",
    album: "album",
    batchSize: 0,
    batchNumber: 0,
    sortBy: Constants.SortBy.Artist,
    sortOrder: Constants.SortOrder.Ascending
  })
    .then(f => {
      console.log(f);
    })
    .catch(er => console.log(e));
};

Components

use this component instead of cover: true for better performance.

inherits from Image.

<CoverImage src={"pathToSong"} width={120} height={120} />

Example

https://github.com/Drazail/react-native-get-music-files/blob/v3dev/example/App.js

Readme

Keywords

Package Sidebar

Install

npm i react-native-get-music-files-v3dev-test

Weekly Downloads

1

Version

3.1.5

License

IST

Unpacked Size

149 kB

Total Files

52

Last publish

Collaborators

  • drazail