Loading...
Logo
Processing Forum
EDIT: Oops, i posted this in the Core Library Questions, sorry, this was a mistake.

Hello,

i'm writing a sketch which is loading random mp3-files from the data folder. The files are loaded and played with Minims AudioPlayer. I need to know the duration of each loaded file in milliseconds...

When the sketch is running locally, this gives the actual duration of a file and everything works fine:

currentFileLen = player.getMetaData().length();

But, if the sketch is running on my website, it gives not the duration of the whole file but (presumably) the duration of the buffers content.

How can i find out the actual duration of each file when the sketch is running online as an applet?

thank in advance

nossek




Replies(2)

I don't understand exactly why that doesn't work on the website, but you can use player.length() to return the length in  milliseconds of the sound: player.getMetaData().length() returns what the file says is the length, which in my experience is not always correct, while player.length() returns what minim says is the length.
Thanks digitaltembo. Yes, player.length() seem to work fine in the online version as well. Don't know why, but i missed this method of player...