henri17
henri17

Reputation: 33

How can i read mp3 tags c#, windows 8 metro ap

i`m writing simple metro style app in c#. Now i have problem accessing files after picking them with filepicker. I got file access error in TagLib.File.Create(fileo.Path).

    var picker = new FileOpenPicker();
    picker.FileTypeFilter.Add(".mp3");
    var file = await picker.PickMultipleFilesAsync();
foreach (StorageFile fileo in file)
    {
     TagLib.File mp3 = TagLib.File.Create(fileo.Path);
     string pikkus = mp3.Properties.Duration.ToString();
    }

Upvotes: 1

Views: 1009

Answers (2)

user3143955
user3143955

Reputation: 31

I found a solution here How to: Get IDE Tags of a file

Read Mp3 Tags:

try
{
var file = await StorageFile.GetFileFromPathAsync(path);
MusicProperties musicProperties = await file.Properties.GetMusicPropertiesAsync();
}
catch(Exception e){
//Error Message here
}

Show Mp3 Tags:

string title = musicProperties.Title;
string artist = musicProperties.Artist;
string album = musicProperties.Album;

Upvotes: 2

troyou
troyou

Reputation: 190

you can read the mp3 tags buy Get the MusicPropertes with the file.

MusicProperties musicProp = await file.Properties.GetMusicPropertiesAsync();

Upvotes: 3

Related Questions