0

I'm trying to use the mp3agic java library from within ColdFusion. Not being a java programmer (I'm mildly familiar with it), I'm a little confused. I've been able to instantiate the object and see a list of methods, but I'm not sure how to point it to a particular file.

In the examples (https://github.com/mpatric/mp3agic), they show:

Mp3File mp3file = new Mp3File("SomeMp3File.mp3");
System.out.println("Length of this mp3 is: " + mp3file.getLengthInSeconds() + " seconds");
System.out.println("Bitrate: " + mp3file.getLengthInSeconds() + " kbps " + (mp3file.isVbr() ? "(VBR)" : "(CBR)"));
System.out.println("Sample rate: " + mp3file.getSampleRate() + " Hz");
System.out.println("Has ID3v1 tag?: " + (mp3file.hasId3v1Tag() ? "YES" : "NO"));
System.out.println("Has ID3v2 tag?: " + (mp3file.hasId3v2Tag() ? "YES" : "NO"));
System.out.println("Has custom tag?: " + (mp3file.hasCustomTag() ? "YES" : "NO"));

And the first line of which is what's confusing. How, in CF terms, do I accomplish that?

Thanks!

Rob

RobG
  • 576
  • 2
  • 9
  • 21
  • 2
    FWIW, some tips on [working with java objects](http://stackoverflow.com/questions/21870117/error-while-creating-large-dropdown-in-excel-using-coldfusion/21884968#21884968) from CF you might find helpful. – Leigh Feb 24 '14 at 23:47

1 Answers1

2

Should be something like

<cfset m = createObject("java", "path.to.Mp3File")>
<cfset m.init("path\to\your\mp3")>
<cfoutput>#m.getSampleRate()#</cfoutput>
Adrian J. Moreno
  • 14,350
  • 1
  • 37
  • 44
  • Do not know if that project has a published API, but you can also get the `package` path ie "path.to.Mp3File" from [the source code](https://github.com/mpatric/mp3agic/blob/master/src/main/java/com/mpatric/mp3agic/Mp3File.java). NB: createObject paths are case sensitive. – Leigh Feb 24 '14 at 23:51