Skip to content

Audio File Length 00:00:00 #56

Description

@XxDaShTixX

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions