Introduction

Introduction

A React Native module that allows you to fetch and manage audios, images, vidoes.

🚫

This library does not support IOS as of now.

Basic Example

Async/Await

import { getAssets, MEDIA_TYPE } from "rn-media-library";
 
// call the function inside the useEffect on mount and set the state
const fetchAssets = async () => {
  try {
    const { assets } = await getAssets({ mediaType: MEDIA_TYPE.AUDIO });
    //parse and set the value in the state
    setAssets(JSON.parse(assets));
  } catch (error) {
    console.log(error);
  }
};

.then

import { getAssets, MEDIA_TYPE } from "rn-media-library";
 
// ...
 
// call the function inside the useEffect on mount and set the state
getAssets({ mediaType: MEDIA_TYPE.AUDIO })
  .then(({ assets }) => {
    //parse and set the value in the state
    setAssets(JSON.parse(assets));
  })
  .catch((error) => {
    console.log(error);
  });