TechTalkz.com Logo Ask the Experts!

Go Back   TechTalkz.com Technology & Computer Troubleshooting Forums > Tech Support Archives > Programing Languages > C#(C Sharp)

Get duration for MP3 file?

C#(C Sharp)

 
 
Thread Tools Display Modes
Unread 01-10-2007, 04:14 PM   #1
Gustaf
Guest
 
Posts: n/a
Get duration for MP3 file?

I've been googling for this for a while now, and it appears it's not at
easy as it sounds, due to MP3's variable bitrate option and other things
that goes above my head. Hopefully, there's a simple solution, that
doesn't include learning hardcore C and writing my own MP3 decoder. All
I want is a number of seconds for an MP3 file. Somehow, Windows itself
can do it. Could this be extracted from a system source somehow?

Gustaf
 
Unread 01-10-2007, 04:15 PM   #2
Rick
Guest
 
Posts: n/a
Re: Get duration for MP3 file?

On Oct 1, 10:45 am, Gustaf <gust...@algonet.se> wrote:
> I've been googling for this for a while now, and it appears it's not at
> easy as it sounds, due to MP3's variable bitrate option and other things
> that goes above my head. Hopefully, there's a simple solution, that
> doesn't include learning hardcore C and writing my own MP3 decoder. All
> I want is a number of seconds for an MP3 file. Somehow, Windows itself
> can do it. Could this be extracted from a system source somehow?
>
> Gustaf


Use the fmod. http://www.fmod.org

Cheers,

Rick

 
Unread 01-10-2007, 05:09 PM   #3
Nicholas Paldino [.NET/C# MVP]
Guest
 
Posts: n/a
Re: Get duration for MP3 file?

Gustaf,

You will want to look into DirectSound (or DirectX in general). There
should be some managed wrappers for it as well. It will allow you to create
a render graph, and from there, you should be able to get the information
you need.

If you have the luxury of creating a visual control, then you might be
able to load the mp3 into a player control and then get the information you
need from the control.


--
- Nicholas Paldino [.NET/C# MVP]
- mvp@spam.guard.caspershouse.com

"Gustaf" <gustafl@algonet.se> wrote in message
news:X4ednYpD-Iq3i5zaRVnygAA@giganews.com...
> I've been googling for this for a while now, and it appears it's not at
> easy as it sounds, due to MP3's variable bitrate option and other things
> that goes above my head. Hopefully, there's a simple solution, that
> doesn't include learning hardcore C and writing my own MP3 decoder. All I
> want is a number of seconds for an MP3 file. Somehow, Windows itself can
> do it. Could this be extracted from a system source somehow?
>
> Gustaf



 
Unread 01-10-2007, 06:15 PM   #4
Ignacio Machin \( .NET/ C# MVP \)
Guest
 
Posts: n/a
Re: Get duration for MP3 file?

Hi,

"Gustaf" <gustafl@algonet.se> wrote in message
news:X4ednYpD-Iq3i5zaRVnygAA@giganews.com...
> I've been googling for this for a while now, and it appears it's not at
> easy as it sounds, due to MP3's variable bitrate option and other things
> that goes above my head. Hopefully, there's a simple solution, that
> doesn't include learning hardcore C and writing my own MP3 decoder. All I
> want is a number of seconds for an MP3 file. Somehow, Windows itself can
> do it. Could this be extracted from a system source somehow?


I would think so, that it's encoded somewhere in the header of the file. To
be 100% sure you ahve to check the format definition.


 
Unread 02-10-2007, 08:59 AM   #5
Nicolas Noakes
Guest
 
Posts: n/a
Re: Get duration for MP3 file?

"Ignacio Machin ( .NET/ C# MVP )" <machin TA laceupsolutions.com> wrote in
message news:%23l8XLJFBIHA.1356@TK2MSFTNGP03.phx.gbl...

> I would think so, that it's encoded somewhere in the header of the file.
> To be 100% sure you ahve to check the format definition.


As far as I am aware, the audio duration is not explicitly stored anywhere
in the file - it is a function of the bitrate, number of frames, etc.

Reference:
http://www.multiweb.cz/twoinches/mp3inside.htm
http://www.mp3-tech.org/
http://www.gnuware.com/icecast/chap_02_10.html
http://www.mp3-faq.org/tips/mp3struct.htm

Regards,
Nicolas


 
 

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Media Duration Gregory Windows Media 0 21-09-2007 01:19 PM
The duration of playback of wmv file N.Tony Windows Media 1 21-09-2007 12:27 PM
ASF File Repair - Unknown Duration ubik@shaw.ca Windows Media Player 1 15-09-2007 05:15 AM
duration of slides Briana Windows Vista All 7 21-08-2007 06:31 AM
duration of slides Briana Windows Vista All 1 21-08-2007 06:17 AM


< Home - Windows Help - MS Office Help - Hardware Support >


New To Site? Need Help?

All times are GMT. The time now is 02:53 PM.


vBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO
Copyright © 2005-2013, TechTalkz.com. All Rights Reserved - Privacy Policy
Valid XHTML 1.0 Transitional