Getting mp3 file length

后端 未结 1 1530
野性不改
野性不改 2021-01-06 14:21

I am currently trying to write an Audio Player in C#. I am using BASS library to deal with playing music but now i have small problem with getting length of the song.

相关标签:
1条回答
  • 2021-01-06 14:50

    You can use the Microsoft.WindowsAPICodePack.Shell:

    using Microsoft.WindowsAPICodePack.Shell;
    

    Then code like so:

    string file = "myfile.mp3"
    ShellFile so = ShellFile.FromFilePath(file);
    double 100nanoseconds;
    double.TryParse(so.Properties.System.Media.Duration.Value.ToString(), out 100nanoseconds);
    

    There is a code project that could help you as well

    0 讨论(0)
提交回复
热议问题