Please help me convert this Java code to ColdFusion
Hello everyone,
I'm not skilled at Java at all so I could really use your help. I'm trying to read the duration and bit rate from an mp3 file. I'm using a java library called "mp3spi" from http://www.javazoom.net/mp3spi/documents.html.
So var I've been able to determine that these objects exist:
<cfset AudioFormat = createObject("java", "org.tritonus.share.sampled.TAudioFormat")>
<cfset AudioFileFormat = createObject("java", "org.tritonus.share.sampled.file.TAudioFileFormat")>
<cfset AudioFileReader = createObject("java", "javax.sound.sampled.spi.AudioFileReader")>
I'm having trouble with the following code and converting it to ColdFusion:
File file = new File("filename.mp3");
AudioFileFormat baseFileFormat = new MpegAudioFileReader().getAudioFileFormat(file);
Map properties = baseFileFormat.properties();
Long duration = (Long) properties.get("duration");
I've tried several ways of setting the above variables, but I keep getting an error that either MpegAudioFileReader or getAudioFileFormat doesn't exist. However when I dump the variables I used to create the Java objects, they do exist.
Here is what I have:
<cfscript>
mp3file = FileOpen(ExpandPath("./") & originalfile, "readBinary");
baseFileFormat = AudioFileReader.getAudioFileFormat(mp3file);
properties = baseFileFormat.properties();
duration = properties.get("duration");
</cfscript>
I can't figure out how to use File, AudioFileFormat, Map, and Long respectively in my cfscript.
Thank you.
-- Simone
Message was edited by: shenry I'm not asking for someone to write my code for me. I'm saying I don't understand this Java code and I'm getting errors with my own code and can't figure out where I've gone wrong.
