Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
460 views
in Technique[技术] by (71.8m points)

.net - How to get the Properties of a *.mp3 File in C#

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...