Question

Possible Duplicate:
How to retrieve duration of MP3 in .NET?

I'm makin' a little mp3 player here and I've pretty much got everything covered. I would like to be able to display the duration of the song but am kinda confused as to go about doing so. I've searched around the net and have seen so many examples that seem so long which makes me wonder if there's an easier way to get the duration of a song?

Was it helpful?

Solution

You may be interested in Mp3Sharp. I haven't used it much, but I see functions such as BitsPerSample, which may be useful for what you're trying to accomplish.

OTHER TIPS

The only way to make sure the duration of an MP3 is to decode it.

Especially when it's VBR encoded, it's hard to guess the length by the file size. Some MP3s have the length in the ID3 tag, so you can take that as a hint; but in my experience, even that's not always accurate.

You need to decode the mp3. For a nice article on decoding mp3s see http://blog.bjrn.se/2008/10/lets-build-mp3-decoder.html It is not written for c# but is fairly complete.

If rolling your own library is not something you're interested in, the link to the other question has links to libraries that are worth looking at.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top