Link to home
Create AccountLog in
Delphi

Delphi

--

Questions

--

Followers

Top Experts

Avatar of alex67500
alex67500

How To Get The Length Of An MP3 File (in milliseconds)?
im looking for a function or procedure that would get the length of an mp3 file in milliseconds (so that i could use it with a timer to play the next song when the previous one is finished)

function getlength(filename):integer

Zero AI Policy

We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.


Avatar of alanwhincupalanwhincup

I would say that the easiest way to do this is to chuck a TMediaPlay component on a form and then use it to open up the MP3 and then just read MediaPlayer.Length for the duration of the file.

Cheers,

Alan

If you are using the TMediaPlay component, you can also use a thread or a timer with fixed time, and on a regular interval check the status property of the player. That way, you will know when the media is stopped, and can then load and start the next one.

ASKER CERTIFIED SOLUTION
Avatar of Member_2_248744Member_2_248744🇺🇸

Link to home
membership
Log in or create a free account to see answer.
Signing up is free and takes 30 seconds. No credit card required.
Create Account

There is a calculation you can do with the MP3 Filesize and BitRate (such as 128 kps).  The BitRate data is saved in the MP3 tag.  I dont know the exact math but it's a good starting point without actually loading the mp3.

Don

Reward 1Reward 2Reward 3Reward 4Reward 5Reward 6

EARN REWARDS FOR ASKING, ANSWERING, AND MORE.

Earn free swag for participating on the platform.


alex67500:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
Delphi

Delphi

--

Questions

--

Followers

Top Experts

Delphi is the most powerful Object Pascal IDE and component library for cross-platform Native App Development with flexible Cloud services and broad IoT connectivity. It provides powerful VCL controls for Windows 10 and enables FMX development for Windows, Mac and Mobile. Delphi is your choice for ultrafast Enterprise Strong Developmentâ„¢. Look for increased memory for large projects, extended multi-monitor support, improved Object Inspector and much more. Delphi is 5x faster for development and deployment across multiple desktop, mobile, cloud and database platforms including 32-bit and 64-bit Windows 10.