Reputation: 313
I´m programming a little media player with a song library. Now I need to get the properties of a mp3,wma file, like the artist name or the song duration.
What is the best way to get this information?
Upvotes: 18
Views: 29220
Reputation: 20778
Note that NAudio can only run on Windows. I found out ATL .NET and love it because it can work on Stream and it can detect formats as well.
z440.atl.core
Nuget package:dotnet add package z440.atl.core
Track
object and get as many information as you want:var track = new Track(stream);
Console.WriteLine(track.Duration);
Console.WriteLine(track.Album);
Console.WriteLine(track.Title);
// More info
Upvotes: 0
Reputation: 8691
You can examine the ID3
tag of the mp3s. The taglib-sharp library is great for doing so. Source code available (here). Example code:
TagLib.File tagFile = TagLib.File.Create(pathtofile);
string artist = tagFile.Tag.FirstAlbumArtist;
string album = tagFile.Tag.Album;
string title = tagFile.Tag.Title;
...
Not sure if tag-lib supports .wma though... Tag-lib can however be ported to silverlight (if needed).
Upvotes: 27