@gauch_99/react-native-audio-files
v1.2.1
Published
This package provides functionality to retrieve all audio files stored on an Android device. With this module, you can easily access and manage audio files within your React Native application.
Downloads
34
Maintainers
Readme
react-native-audio-files
This package provides functionality to retrieve all audio files stored on an Android device. With this module, you can easily access and manage audio files within your React Native application.
Installation
npm install react-native-audio-files
Usage
import { fetchAudioFiles } from 'react-native-audio-files';
const audioFiles = await fetchAudioFiles();
Or Follow Basic Example:
import { fetchAudioFiles } from 'react-native-audio-files';
const [audioFiles, setAudioFiles] = useState([]);
useEffect(() => {
const getAudioFiles = async () => {
return await fetchAudioFiles();
};
getAudioFiles().then((result) => {
setAudioFiles(result);
});
}, []);
return (
<View>
{audioFiles?.map((element, index) => {
return (
<View key={index}>
<Text>{element?.title}</Text>
</View>
);
})}
</View>
);
List of keys available:
| Key | Description | Type | |---------------|-----------------------------------|---------| | addedDate | Added Date Time of the Audio File | String | | album | Album of the Audio File | String | | artist | Artist of the Audio File | String | | audioUrl | Path of the Audio File | String | | duration | Duration of the Audio File | Integer | | id | Unique Id of the Audio File | String | | imageUrl | Image of the Audio File | String | | size | Size of the Audio File | String | | title | Title of the Audio File | String |
Note:
- addedDate is of type UNIX Timestamp, to convert it into the required time format of YYYY-MM-DD HH:MM:SS
const formattedDateTime = new Date(addedDate * 1000).toISOString().slice(0, 19).replace('T', ' ');
- Make sure you have permissions granted from User for Reading Storage according to the Android Versions or you wont be able to fetch files.
Example: <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
Contributing
See the contributing guide to learn how to contribute to the repository and the development workflow.
License
MIT