It is necessary to display the time of the tracks. It turns out to do, if for example only mp3. But there may be other formats in the playlist, such as WAV and Vorbis. How can you implement automatic switching between types to display time for any of the two file types. Now done as follows:
private static void Main(string[] args) { try { foreach (var file in GetFileInfo()) { Mp3FileReader reader = new Mp3FileReader(file.FullName); WaveFileReader s; //?? TimeSpan duration = reader.TotalTime; Console.WriteLine(duration); } } catch (Exception e) { Console.WriteLine(e); } Console.ReadKey(); } public static IList<FileInfo> GetFileInfo() { DirectoryInfo directories = new DirectoryInfo("D:\\TestAudio"); var extensions = new string[] { "*.mp3", "*.mp4", "*.wav", "*.wma", "*.ogg", "*.spx" }; var files = extensions.SelectMany(ext => directories.GetFiles(ext, SearchOption.AllDirectories)); return files.ToList(); } When it comes to WAV files, it displays an exception accordingly.
