on_audio_edit 1.5.1
Flutter Plugin used to edit and read audios/songs infos/tags [Mp3, OggVorbis, Wav, etc...].
on_audio_edit
on_audio_edit is a Flutter Plugin used to edit and read audios/songs 🎶 infos/tags [Mp3, OggVorbis, Wav, etc...].
This Plugin use AdrienPoupa:jaudiotagger as dependency to edit audios tags.
Help:
Any problem? Issues
Any suggestion? Pull request
Translations:
NOTE: Feel free to help with readme translations
Topics:
How to Install:
Add the following code to your pubspec.yaml:
dependencies:
on_audio_edit: ^1.5.1
Request Permission:
You will need add the following code to your AndroidManifest.xml
Note: This Plugin don't have a built-in request permission
<manifest> ...
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
</manifest>
Legacy External Storage:
If you are using/want to use Android 10 will need add the following code to your AndroidManifest.xml
<application> ...
android:requestLegacyExternalStorage="true"
</application>
Some Features:
- Read Audios/Songs tags.
- Edit Audios/Songs tags.
- Supports Android 10 and above.
TODO:
- Add better performance for all plugin.
- Add
[deleteArtwork]to Android 10 and above. - Add
[deleteArtworks]to Android 10 and above. - Add
[deleteAudio]to Android 10 and above. - Fix bugs.
How to use:
OnAudioEdit() // The main method to start using the plugin.
All types of methods on this plugin:
Read methods
| Methods | Parameters | Return |
|---|---|---|
readAudio | (String) | AudioModel |
readAudios | (List<String>) | List<AudioModel> |
readSingleAudioTag | (String, TagsType) | String |
readSpecificsAudioTags | (String, List<TagsType>) | AudioModel |
Edit methods
| Methods | Parameters | Return |
|---|---|---|
editAudio | (String, Map<TagsType, dynamic>) | bool |
editAudios | (List<String>, List<Map<TagsType, dynamic>>) | bool |
editArtwork | (String, bool, String, ArtworkFormat, int, String) | bool |
Delete methods
| Methods | Parameters | Return |
|---|---|---|
deleteArtwork | [W](String) | bool |
deleteArtworks | [W](List<String>) | bool |
deleteAudio | [W](String) | bool |
Permission/Image methods
| Methods | Parameters | Return |
|---|---|---|
getImage | ArtworkFormat, Quality | ImageModel |
permissionsStatus | bool | |
resetComplexPermission | [Q] | bool |
requestComplexPermission | [Q] | bool |
requestComplexPermission | [Q] | bool |
[Q] -> Only necessary on Android 10 or above.
[W] -> These methods are currently only implemented on Android 9 or below.
TagsType:
| Types | Types | Types | Types | Types |
|---|---|---|---|---|
ALBUM_ARTIST | ORIGINAL_ARTIST | ORIGINAL_ALBUM | TRACK | FORMAT |
ARTIST | ORIGINAL_LYRICIST | LYRICS | TITLE | SAMPLE_RATE |
ARTISTS | ORIGINAL_YEAR | LANGUAGE | TEMPO | CHANNELS |
BEATS_PER_MINUTE | PRODUCER | KEY | TAGS | COVER_ART |
COMPOSER | QUALITY | ISRC | SUBTITLE | TYPE |
COUNTRY | RATING | FIRST_ARTWORK | LENGTH | More |
GENRE | RECORD_LABEL | YEAR | BITRATE |
Examples:
OnAudioEdit
final OnAudioEdit _audioEdit = OnAudioEdit();
readAudio
// data: "/storage/1E65-6GH3/SomeMusic.mp3" or "/storage/someFolder/SomeMusic.mp3"
AudioModel song = await _audioEdit.readAudio(data);
String songTitle = song.title;
String songArtist = song.artist ?? '<No Artist>';
readAudios
List<String> allData = [data0, data1, data2];
List<AudioModel> song = await _audioEdit.readAudios(allData);
...
String songTitle1 = song[0].title;
String songTitle2 = song[1].title;
String songTitle3 = song[2].title;
readSingleAudioTag
String title = await _audioEdit.readSingleAudioTag(data, TagsType.TITLE);
print(title); // Ex: Heavy, California
...
String artist = await _audioEdit.readSingleAudioTag(data, TagsType.ARTIST);
print(artist); // Ex: Jungle
readSpecificsAudioTags
List<TagsType> tags = [
TagsType.TITLE,
TagsType.ARTIST
];
AudioModel songSpecifics = await _audioEdit.readSpecificsAudioTags(data, tags);
...
String songTitle = songSpecifics.title;
String songArtist = songSpecifics ?? '<No Artist>';
editAudio
Map<TagsType, dynamic> tags = {
TagsType.TITLE: "New Title",
TagsType.ARTIST: "New Artist"
};
bool song = await _audioEdit.editAudio(data, tags);
print(song); //True or False
editAudios
⚠ Note: This method isn't implemented on Android 10 or above. Instead use: editAudio
// Tags
List<<Map<TagsType, dynamic>> tags = [];
Map<TagsType, dynamic> getTags = {
TagsType.TITLE: "New Title",
TagsType.ARTIST: "New Artist"
};
tags.add(getTags);
// Songs data
List<String> data;
data.add(song1);
data.add(song2);
data.add(song3);
bool result = await _audioEdit.editAudios(data, tags);
print(result); //True or False
editArtwork
⚠ Note: If openFilePicker is false, imagePath can't be null.
// Parameters: openFilePicker, imagePath, format, size, description
// DEFAULT: true, null, ArtworkFormat.JPEG, 24, "artwork"
bool song = await _audioEdit.editArtwork(data);
print(song); //True or False