Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/krtirtho/metadata_god
Audio file Metadata reading and writing library for Flutter
https://github.com/krtirtho/metadata_god
android audio flac flutter id3 linux m4a macos mp3 ogg-tags rust windows
Last synced: 12 days ago
JSON representation
Audio file Metadata reading and writing library for Flutter
- Host: GitHub
- URL: https://github.com/krtirtho/metadata_god
- Owner: KRTirtho
- License: mit
- Created: 2022-09-01T06:27:51.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-10-16T06:17:19.000Z (about 1 year ago)
- Last Synced: 2024-10-08T08:05:13.914Z (about 1 month ago)
- Topics: android, audio, flac, flutter, id3, linux, m4a, macos, mp3, ogg-tags, rust, windows
- Language: Dart
- Homepage:
- Size: 98.6 MB
- Stars: 22
- Watchers: 2
- Forks: 12
- Open Issues: 14
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Metadata God
A flutter plugin for retrieving and writing audio tags/metadata from audio files. It supports almost all kind of audio files
## Supported Audio Formats
| File Format | Metadata Format |
| ----------- | --------------------- |
| mp3 | id3v2.4 |
| m4a, mp4 | MPEG-4 audio metadata |
| flac | Vorbis comment |## Installation
Run in terminal:
```bash
$ flutter pub add metadata_god
```## Configuration
### Android
For using `metadata_god` in Android it needs `READ_EXTERNAL_STORAGE` and `WRITE_EXTERNAL_STORAGE` permissionsSo, add following green highlighted lines to `android/app/src/main/AndroidManifest.xml` file:
```diff
+
+
// .... rest of the file
```Finally, use packages like `permission_handler` to request storage permissions from user if not granted already
```dart
// before calling any method of MetadataGod in android
// check if storage permission is granted or not
// if not, request for permission
initState(){
final hasStorageAccess = Platform.isAndroid ? await Permission.storage.isGranted : true
if(!hasStorageAccess){
await Permission.storage.request();
if(!await Permission.storage.isGranted){
return;
}
}
// ... call all the metadata_god methods from here
}
```> Following configuration would work with file path that are allowed explicitly by android. If you want entire storage access you'll need `MANAGE_EXTERNAL_STORAGE` permission and request the user to enable access to entire storage in app info settings.
### Other platforms
Linux, Windows and MacOS doesn't need any extra configuration and good to go after installation
## Usage
```dart
import 'package:flutter/material.dart';
import 'package:mime/mime.dart';
import 'package:metadata_god/metadata_god.dart';// Initialize the plugin
void main(){
WidgetsFlutterBinding.ensureInitialized();
MetadataGod.initialize();
runApp(const MyApp());
}// Get metadata from file
Metadata metadata = await MetadataGod.getMetadata("/path/to/audio-file");// Set metadata to file
await MetadataGod.writeMetadata(
"/path/to/audio-file",
Metadata(
title: "Leave the Door Open",
artist: "Bruno Mars, Anderson .Paak, Silk Sonic",
album: "An Evening with Silk Sonic",
genre: "R&B, Soul",
year: 2021,
albumArtist: "Bruno Mars, Anderson .Paak",
trackNumber: 1,
trackTotal: 12,
discNumber: 1,
discTotal: 5,
durationMs: 248000,
fileSize: file.lengthSync(),
picture: Picture(
data: File("/path/to/cover-image").readAsBytesSync(),
mimeType: lookupMimeType("/path/to/cover-image"),
),
),
);
```## Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
## License
[MIT](https://choosealicense.com/licenses/mit/)
## Author
[Kingkor Roy Tirtho](https://github.com/KRTirtho)