Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Applet wav to mp3 conversion - tritonus plugins, lame dlls

 
Amos Matt
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I am trying to convert .wav file to .mp3 using Mp3Encoder.java given by tritonus.
I have kept tritonus_share.jar, tritonus_mp3.jar,tritonus_remaining-0.3.6.jar files under Jboss...\default\lib & under "ext" folder of Jdk. And lametritonus.dll, lame_enc.dll under Windows\system32. when i run Mp3Encoder.java on the command prompt, the input wave file is converted to .mp3.

Now i am trying to use the same conversion code in an Applet to convert the recorded .wav audioinputstream to .mp3.
below is the code...

import org.tritonus.share.sampled.AudioFileTypes;
import org.tritonus.share.sampled.Encodings;

try {
AudioFileFormat.Type targetType = AudioFileTypes.getType("MP3", "mp3");
String outFilename = "Converted" + "." + targetType.getExtension();
try {
if (AudioSystem.write(getConvertedStream(audioInputStream, Encodings.getEncoding("MPEG1L3")), targetType, new File(outFilename)) == -1) {
throw new IOException("Problems writing to file");
}
} catch (Exception ex) {
reportStatus(ex.toString());
}
}
} catch (Throwable t) {
reportStatus("Exception while converting :"+t.getMessage());
}
}//end try-catch

Here when i record the voice and try to call the above code in a method my program throwing exception as "Exception while converting : org.tritonus.share.sampled.AudioFileTypes".

I also found the exception generating by "AudioFileTypes.getType("MP3", "mp3") " call to the tritonus plugin.

Could you please tell me how to solve this problem.

Thank you,
Kanakam
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I suspect it's a permission thing because the code tries to do something that applets aren't allowed to do. Seeing the full chain of exceptions would help.
 
Amos Matt
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ulf,

Here is the stack trace

java.lang.NoClassDefFoundError: org/tritonus/share/sampled/AudioFileTypes
at com.kas.rdd.sound.CapPback.convertTheStream(CapPback.java:768)
at com.kas.rdd.sound.CapPback.actionPerformed(CapPback.java:483)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
throwable rg/tritonus/share/sampled/AudioFileTypes

Thanks.
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It seems that the applet JRE doesn't have access to those files you put in the "ext" directory. Maybe you have more than one JRE installed, and the applet plugin uses a different one?
 
Amos Matt
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ulf,

Just before your reply i found the problem. And what you said is the correct.
I tried putting the jar files in other JRE also. Now my applet is recognizing.

Thank you,
Amos
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic