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

 

Leave a Comment




XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.