id3tag 0.2.0 id3tag: ^0.2.0 copied to clipboard
A cross-platform, pure-Dart package for reading ID3 meta data
ID3Tag #
ID3Tag is a small library for reading common ID3 meta data from mp3-files and other types of media files. There are of course already other libraries for doing this out there, but at the time of creating this library, none of them provided support in three critical areas:
- Reading chapter (
CHAP
) and table of contents (CTOC
) frames - Reading ID3 meta data without having to load the entire file into memory
- Easy extensibility to be able to implement support for additional frame types
Thus, the above list was the basic motivation for creating this library. Also, the specific use case of supporting mp3 audio books was another motivating factor (hence support for chapters and large file sizes).
Features #
- Support for ID3 v2.3 (and above)
- Support for common ID3 frames, such as:
- Text information frames see here
- Chapter frames, i.e.
CHAP
frames - Table of contents frames, i.e.
CTOC
frames - Attached picture frames, i.e.
APIC
frames - Comment frames, i.e.
COMM
frames
Usage #
To use this package, simply include the dependency, import the package and then use the class ID3TagReader
to read
the ID3 tag from a file.
final parser = ID3TagReader.path('path to a file');
final tag = parser.readTagSync();
print('Title: ${tag.title}');
print('All chapters: ${tag.chapters}');
// Or:
print('Chapters in top level table of contents: ${tag.topLevelChapters}');
During development, it may sometimes be convenient to use files in the form of asset resources. To accomplish this, you can use the snippet below (requires the path_provider package):
import 'package:path_provider/path_provider.dart';
...
final ByteData fileData = await rootBundle.load('some asset file');
final filePath = '${(await getTemporaryDirectory()).path}/a file name';
File(filePath).writeAsBytesSync(fileData.buffer.asUint8List(fileData.offsetInBytes, fileData.lengthInBytes));
Additional information #
This library was initially derived from the package id3, but later refactored, rewritten and and rearchitected for better extensibility, readability and robustness. The architecture was in part inspired by OutcastID3.