id3_codec 0.0.5 id3_codec: ^0.0.5 copied to clipboard
An ID3 tag information parsing library based on dart, which supports the operation of Flutter on all platforms.
id3_codec #
An ID3 tag information parsing library based on dart, which supports the operation of Flutter
on all platforms.
ID3 version that supports decoding #
- ✅ v1
- ✅ v1.1
- ✅ v2.2
- ✅ v2.3
- ✅ v2.4
ID3 version that supports encoding #
NOW, START SUPPORTED ID3 ENCODE!🎉
- ✅ v1
- ✅ v1.1
- ❌ v2.2
- ✅ v2.3
- ❌ v2.4
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: ^0.0.3
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.
- encode to 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;
- encode to v2.3
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);
// ignore: prefer_const_constructors
final resultBytes = encoder.encodeSync(MetadataV2_3Body(
title: '听我说谢谢你!',
imageBytes: headerBytes,
artist: '歌手ijinfeng',
userDefines: {
"时长": '2:48',
"userId": "ijinfeng"
},
album: 'ijinfeng的专辑',
));
// you can read [resultBytes] by `ID3Decoder` or other ID3 tag pubs;