-
Notifications
You must be signed in to change notification settings - Fork 1
Getting Started
Hirdaya Shrestha edited this page Sep 14, 2026
·
1 revision
Add hAudiotagger to your pubspec.yaml:
dependencies:
haudiotagger: ^1.3.3Then run:
flutter pub getThat's it. No native build configuration needed — pre-built binaries are downloaded automatically for each platform.
import 'package:haudiotagger/haudiotagger.dart';
final tag = await Haudiotagger.read('/path/to/song.mp3');
if (tag != null) {
print('Title: ${tag.title}');
print('Artist: ${tag.trackArtist}');
print('Album: ${tag.album}');
print('Year: ${tag.year}');
print('Genre: ${tag.genre}');
}await Haudiotagger.write('/path/to/song.mp3', Tag(
title: 'My Song',
trackArtist: 'Artist Name',
album: 'Album Name',
year: 2024,
genre: 'Rock',
));Only the fields you specify are changed — everything else stays intact:
await Haudiotagger.update('/path/to/song.mp3', TagChanges(
title: 'New Title',
));Process multiple files at once:
final paths = ['/path/to/song1.mp3', '/path/to/song2.mp3', '/path/to/song3.mp3'];
// Write same tag to all files
final result = await Haudiotagger.batchWrite(paths, Tag(
album: 'New Album',
));
print('Success: ${result.successes}, Failed: ${result.failures}');On the web, use the *FromBytes variants:
// Read from bytes
final tag = await Haudiotagger.readFromBytes(fileBytes);
// Write to bytes (returns modified bytes)
final modified = await Haudiotagger.writeToBytes(fileBytes, Tag(
title: 'My Song',
));The host page must be cross-origin isolated for WASM shared memory. Add these headers when serving:
Cross-Origin-Opener-Policy: same-origin
Cross-Origin-Embedder-Policy: require-corp
flutter run -d chrome \
--web-header=Cross-Origin-Opener-Policy=same-origin \
--web-header=Cross-Origin-Embedder-Policy=require-corpConfigure your web server to send the required headers. See Web Setup for detailed instructions.
All operations return Result types that can throw HaudiotaggerError:
try {
final tag = await Haudiotagger.read('/path/to/song.mp3');
} on HaudiotaggerError catch (e) {
print('Error: ${e.message}');
}Common errors:
- OpenFile — File not found or corrupted
- Read — Failed to parse metadata
- Write — Failed to write metadata
- UnsupportedFormat — File format not supported
- Examples — Common use cases and patterns
- API Reference — Complete method documentation
- Web Setup — Detailed web configuration
Made with ❤️ and 🦀 by Hirdaya Shrestha