AvahW
AvahW

Reputation: 2201

Can you read the length of an mp3 file in python 3 on windows 10?

I am currently creating a music player in python 3.3 and I have a way of opening the mp3/wav files, namely through using through 'os.startfile()', but, this way of running the files means that if I run more than one, the second cancels the first, and the third cancels the second, and so on and so forth, so I only end up running the last file. So, basically, I would like a way of reading the mp3 file length so that I can use 'time.sleep(SongLength)' between the start of each file. Thanks in advance.

EDIT: I forgot to mention, but I would prefer to do this using only pre-installed libraries, as i am hoping to publish this online as a part of a (much) larger program

Upvotes: 0

Views: 396

Answers (2)

AvahW
AvahW

Reputation: 2201

i've managed to do this Using an external module, as after ages of trying to do it without any, i gave up and used tinytag, as it is easy to install and use.

Upvotes: 1

lamados
lamados

Reputation: 51

Nothing you can do without external libraries, as far as I know. Try using pymad. Use it like this:

import mad
SongFile = mad.MadFile("something.mp3")
SongLength = SongFile.total_time()

Upvotes: 0

Related Questions