Hello,
I have 2 questions/issues that I hope you can help me with:
- When I try to retrieve the audio file's length (which is clearly set under the Details tab of the file -> Length), it always shows as "00:00:00". Am I doing something wrong or is this not supported?


- Some MP3 files work just fine, and some I get the Id3Tag as null for some reason. Any particular reason why this might be happening?
This is the basic code I am using to extract the file properties:
string[] filePaths = Directory.GetFiles(Path.Combine(_environment.WebRootPath, "audio/songs")); List<SongModel> files = new List<SongModel>(); foreach (string filePath in filePaths){ using(var mp3 = new Mp3(filePath)){ Id3Tag tag = mp3.GetTag(Id3TagFamily.Version2X); if (tag != null) { files.Add(new SongModel{ Album = tag.Album ?? "", Title = tag.Title ?? "", Artist = tag.Band ?? "", Year = tag.Year ?? "", Length = (tag.Length.Value.Minutes.ToString() + ":" + tag.Length.Value.Seconds.ToString()) ?? "00:00", FileName = Path.GetFileName(filePath) }); } } }
Hello,
I have 2 questions/issues that I hope you can help me with:
This is the basic code I am using to extract the file properties:
string[] filePaths = Directory.GetFiles(Path.Combine(_environment.WebRootPath, "audio/songs")); List<SongModel> files = new List<SongModel>(); foreach (string filePath in filePaths){ using(var mp3 = new Mp3(filePath)){ Id3Tag tag = mp3.GetTag(Id3TagFamily.Version2X); if (tag != null) { files.Add(new SongModel{ Album = tag.Album ?? "", Title = tag.Title ?? "", Artist = tag.Band ?? "", Year = tag.Year ?? "", Length = (tag.Length.Value.Minutes.ToString() + ":" + tag.Length.Value.Seconds.ToString()) ?? "00:00", FileName = Path.GetFileName(filePath) }); } } }