@@ -4,6 +4,20 @@ A modern .NET library for reading and writing metadata in media files.
44
55[ ![ License: MIT] ( https://img.shields.io/badge/License-MIT-yellow.svg )] ( https://opensource.org/licenses/MIT )
66
7+ ## When to Use TagLibSharp2
8+
9+ ** Choose TagLibSharp2 if you need:**
10+ - MIT license (TagLib# is LGPL)
11+ - Async I/O for high-throughput scenarios
12+ - Modern .NET features (nullable types, ` Span<T> ` )
13+ - Result-based error handling (no exceptions)
14+
15+ ** Choose TagLib# if you need:**
16+ - MP4/M4A, ASF/WMA, APE, or AIFF support (not yet implemented here)
17+ - A battle-tested library used in production for years
18+
19+ See the [ Migration Guide] ( docs/MIGRATION-FROM-TAGLIB.md ) for detailed comparison.
20+
721## Features
822
923- ** Modern .NET** : Built for .NET 8+ with nullable reference types, ` Span<T> ` , and async support
@@ -31,59 +45,28 @@ dotnet build
3145## Quick Start
3246
3347``` csharp
34- using TagLibSharp2 .Id3 .Id3v2 ;
3548using TagLibSharp2 .Mpeg ;
3649using TagLibSharp2 .Xiph ;
3750using TagLibSharp2 .Ogg ;
3851
39- // Read ID3v2 tags from MP3 files
40- var mp3Data = File .ReadAllBytes (" song.mp3" );
41- var id3Result = Id3v2Tag .Read (mp3Data );
42- if (id3Result .IsSuccess )
43- {
44- var tag = id3Result .Tag ! ;
45- Console .WriteLine ($" Title: {tag .Title }" );
46- Console .WriteLine ($" Artist: {tag .Artist }" );
47- Console .WriteLine ($" Album: {tag .Album }" );
48- }
49-
50- // High-level MP3 access (prefers ID3v2, falls back to ID3v1)
51- var mp3Result = Mp3File .ReadFromFile (" song.mp3" );
52- if (mp3Result .IsSuccess )
52+ // Read MP3 tags (prefers ID3v2, falls back to ID3v1)
53+ var result = Mp3File .ReadFromFile (" song.mp3" );
54+ if (result .IsSuccess )
5355{
54- var mp3 = mp3Result .File ! ;
55- Console .WriteLine ($" Title: {mp3 .Title }" );
56- Console .WriteLine ($" Artist: {mp3 .Artist }" );
56+ var mp3 = result .File ! ;
57+ Console .WriteLine ($" {mp3 .Title } by {mp3 .Artist }" );
5758
5859 // Modify and save
5960 mp3 .Title = " New Title" ;
60- var originalData = File .ReadAllBytes (" song.mp3" );
61- mp3 .SaveToFile (" song.mp3" , originalData );
61+ mp3 .SaveToFile (" song.mp3" , File .ReadAllBytes (" song.mp3" ));
6262}
6363
64- // Read FLAC metadata (sync)
65- var flacResult = FlacFile .ReadFromFile (" song.flac" );
66- if (flacResult .IsSuccess )
67- {
68- var flac = flacResult .File ! ;
69- Console .WriteLine ($" Title: {flac .Title }" );
70- Console .WriteLine ($" Artist: {flac .Artist }" );
71- }
64+ // FLAC and Ogg Vorbis work the same way
65+ var flac = FlacFile .ReadFromFile (" song.flac" ).File ;
66+ var ogg = OggVorbisFile .ReadFromFile (" song.ogg" ).File ;
7267
73- // Read FLAC metadata (async)
74- var flacAsync = await FlacFile .ReadFromFileAsync (" song.flac" );
75- if (flacAsync .IsSuccess )
76- {
77- Console .WriteLine ($" Title: {flacAsync .File ! .Title }" );
78- }
79-
80- // Read Ogg Vorbis comments
81- var oggResult = OggVorbisFile .ReadFromFile (" song.ogg" );
82- if (oggResult .IsSuccess )
83- {
84- var ogg = oggResult .File ! ;
85- Console .WriteLine ($" Title: {ogg .Title }" );
86- }
68+ // Async support for high-throughput scenarios
69+ var asyncResult = await Mp3File .ReadFromFileAsync (" song.mp3" );
8770```
8871
8972See the [ examples] ( examples/ ) directory for more comprehensive usage patterns.
@@ -157,6 +140,7 @@ This is a clean-room rewrite of media tagging functionality, designed from speci
157140
158141## Documentation
159142
143+ - [ Migration Guide] ( docs/MIGRATION-FROM-TAGLIB.md ) - Migrating from TagLib#
160144- [ Architecture Overview] ( docs/ARCHITECTURE.md ) - Design principles and allocation behavior
161145- [ Core Types Reference] ( docs/CORE-TYPES.md ) - Complete API documentation
162146- [ Building Guide] ( docs/BUILDING.md ) - Build instructions and requirements
0 commit comments