Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Audio File Length 00:00:00 #56

Open
XxDaShTixX opened this issue May 16, 2021 · 0 comments
Open

Audio File Length 00:00:00 #56

XxDaShTixX opened this issue May 16, 2021 · 0 comments

Comments

@XxDaShTixX
Copy link

XxDaShTixX commented May 16, 2021

Hello,
I have 2 questions/issues that I hope you can help me with:

  1. 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?

image
image

  1. 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) }); } } }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant