Get MP3 file duration/length
Posted by WorldofCode on Jul 20th, 2010
2010
Jul 20
C# code for if you are trying to get the mp3 length or duration of a media file. You will need to reference Windows Media Player. Go to Com Add-ins to add the wmp.dll to your project.
string Duration = null;
WMPLib.WindowsMediaPlayer w = new WMPLib.WindowsMediaPlayer();
WMPLib.IWMPMedia m = w.newMedia(Filename);
if (m != null) {
Duration = m.durationString;
}
w.close();
View Similar Posts



