This function returns the duration of the MP3 file in milliseconds (1ms = 0.001s). Converting this to minutes is trivial enough that I don't think I have to provide code for this, plus you can then decide for yourself if you want to use rounding or not.
Note that not all MP3 files (IIRC) contain duration information so in this case the function will return 0 (same applies if the file can't be opened by mpega.library for some reason).
OK, before someone thinks i can code Here's the source
Not sure if it is what you are looking for
At least you have proved you can use Google . Unfortunately:
- the code is in C# which is not available on AmigaOS - this particular snippet is not too difficult for a developer to translate to another language, though.
- what's worse is that the code will only work for MP3 files encoded to a particular bitrate and quality etc., as it assumes a direct relationship between the filesize in bytes (which is what it gets from the FileInfo object) and the playing time. I usually encode all my MP3 files to a bitrate of192 kb/s and using the joint stereo setting (not sure if the latter changes the byte length), so it would fail miserably with my files.
In short, Antique, you'd better go with one of salass00's methods.
I had OS4 includes for mpega.library generated for diskimage.device but it seems that I deleted them from the SVN when I switched to using mpg123.library instead. If you want I can regenerate and upload them for you tomorrow (shouldn't take many minutes to do).
Done that. But all i get is some errors when compiling. Not sure why. I have added the 2 includes aswell. This one makes no difference if i have or not in the program.... #include <libraries/mpega.h>
The error code. Seems like some missing/wrong header file....?
/tmp/cc067KJ5.o: In function `GetMP3Duration.12662': test2.c:(.text+0x1c42): undefined reference to `IMpega' test2.c:(.text+0x1c46): undefined reference to `IMpega' test2.c:(.text+0x1c52): undefined reference to `IMpega' test2.c:(.text+0x1c56): undefined reference to `IMpega' test2.c:(.text+0x1c8e): undefined reference to `IMpega' /tmp/cc067KJ5.o:test2.c:(.text+0x1c92): more undefined references to `IMpega' follow