I’m still worrying away at this annoying problem. What i’m attempting to do ( and nearly finished!) is read some MP3 files of songs to be added to our radio station library. They are just songs that artists and/or record labels send us for broadcast. Properly tagged MP3 files are perfect for broadcast on FM - they have the same specs as the transmission specs.
I have been able to read the MP3 files and extract into a struct most of the variables of each MP3, for example song title, artistname, albumname, songwriter etc to add into the database we use to control our programming, and display on your car’s dash the name etc of the song playing - all that kind of stuff. The only data I havent been able to get this routine to find is the duration of the mp3 file. Believe it or not it isn’t actually part of the mp3 metadata. We need that for figuring out what songs will fit into the time leading up to the next commiitment (news link, ad break etc. ) At the moment, I’m adding the duratoin manually by typing it into a form while the files are loaded into Windows Media player. When you’re librarying 10 albums a day it isnt very efficient to do that for only one item of data per song.
Duration might not be part of the metadata but any playing device instantly knows how long the song is, because they all display it. Even the most basic ones. Also when you play an audio file on a web page, using the HTML5 AUDIO tag the duration is shown there SOMEWHERE too.
So how are they getting the duration? OR more imporantly, how can i do it from Lucee in a way that lets me add the duration to the song’s struct so I can load that automatically into the database with everything else?
**What I’ve tried so far: **
The java library I’m using is called Java ID3 Tag Library
https://javamusictag.sourceforge.net/ but there are others. This gives me everything I need - except duration of the MP3. .
Flollowing suggestions in this thread, I’ve looked at Apache Tika but that seems to be doing almost anything BUT what I’m looking for. I guess I’m confused about that too.
I’'ve seen reference in stackoverflow to AudioFileFormat which apparently has a property called Long duration but i’m confused about how that can help me too - i cant see where to find out anything about AudioFileFormat. Not even uncle Google seems to now much about it.
I guess this is all a result of not getting a degree in computer science but when i was at uni in 1970 such things weren’t available.
Can anyone help me clear away some of the fog so i can see the Duration? Please?
Cheers
Mike Kear
Windsor, NSW, Australia