How to get length of a song?

Speckled

Member
Joined
Feb 12, 2008
Messages
12
Programming Experience
1-3
I've been pulling my hair on this one today...

I have a song, and am using IO.GetFileInfo.

In this case, the length of the file is returning 6324242? I'm guessing it needs converting to something?

The actual track length is 3:32 seconds.

Any help with the conversion of getting song length appreciated. :)

Thanks,
Ricky
 
Usually the song duration is stored in the file, not as the file size.

There are various methods for getting the duration depending on file type, .mp3, .ogg, .wma, so we can't tell you which method you need without more info.

CT
 
there is an alternative way by using the WMP (Windows Media Player) component

i have code somewhere on the project i am working on, when i get some time i can make up a sample if you want.

but first you can try looking at this approach.

if you do find out how to get it from the MP3 file then please let me know, it could come in handy for my project
 
Try UltraID3Lib, download and add reference, sample code to get duration:
VB.NET:
Dim u As New HundredMilesSoftware.UltraID3Lib.UltraID3
u.Read("track FileName")
MessageBox.Show(u.Duration.ToString)
 
Back
Top