id3_codec 1.0.2 id3_codec: ^1.0.2 copied to clipboard
A cross-platform, pure-Dart package for reading and editing ID3 meta data.
id3_codec #
A cross-platform, pure-Dart package for reading and editing ID3 meta data.
ID3 version that supports decode to readable tags #
- ✅ v1
- ✅ v1.1
- ✅ v2.2
- ✅ v2.3
- ✅ v2.4
ID3 version that supports edit or encoding #
- ✅ v1
- ✅ v1.1
- ❌ v2.2(Not support)
- ✅ v2.3
- ✅ v2.4
Update record #
You can read CHANGELOG for detailed update information.
Install #
Depend on it Run this command:
With Flutter:
flutter pub add id3_codec
This will add a line like this to your package's pubspec.yaml (and run an implicit flutter pub get):
dependencies:
id3_codec: ^{lastest version}
Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.
How to use #
Decode #
You can read all ID3 tag information from a given byte sequence. And display with ID3MetataInfo
or a Map.
Of course, you can also refer to the example I provided to familiarize yourself with the detailed usage.
- read by async.
final data = await rootBundle.load("assets/song1.mp3");
final decoder = ID3Decoder(data.buffer.asUint8List());
decoder.decodeAsync().then((metadata) {
debugPrint(metadata.toString());
});
- read by sync.
final data = await rootBundle.load("assets/song1.mp3");
final decoder = ID3Decoder(data.buffer.asUint8List());
final metadata = decoder.decodeSync();
debugPrint(metadata.toString());
Encode #
You can edit existing id3 tags, or add new tag information into it.
- edit or encode v1 and v1.1
final data = await rootBundle.load("assets/song2.mp3");
final bytes = data.buffer.asUint8List();
final encoder = ID3Encoder(bytes);
final resultBytes = encoder.encode(MetadataV1Body(
title: 'Ting wo shuo,xiexie ni',
artist: 'Wu ming',
album: 'Gan en you ni',
year: '2021',
comment: 'I am very happy!',
track: 1,
genre: 2
));
// you can read [resultBytes] by ID3Decoder or other ID3 tag pubs;
- edit or encode v2.3/v2.4
final data = await rootBundle.load("assets/song1.mp3");
final bytes = data.buffer.asUint8List();
final header = await rootBundle.load("assets/wx_header.png");
final headerBytes = header.buffer.asUint8List();
final encoder = ID3Encoder(bytes);
// if you need encode or edit v2.4, just use `MetadataV2p4Body` instead of `MetadataV2p3Body`
// ignore: prefer_const_constructors
final resultBytes = encoder.encodeSync(MetadataV2p3Body(
title: '听我说谢谢你!',
imageBytes: headerBytes,
artist: '歌手ijinfeng',
userDefines: {
"时长": '2:48',
"userId": "ijinfeng"
},
album: 'ijinfeng的专辑',
));
// you can read [resultBytes] by `ID3Decoder` or other ID3 tag pubs;