I have problem with my app. When I run app in Eclipse, sound played well, but if I export app to runnable jar, sound doesn't work.
Method, where sound is played:
public static synchronized void playSound()
{
new Thread(new Runnable()
{
// The wrapper thread is unnecessary, unless it blocks on the
// Clip finishing; see comments.
public void run()
{
try
{
Clip clip = AudioSystem.getClip();
AudioInputStream inputStream = AudioSystem.getAudioInputStream(getClass().getResourceAsStream("sound.wav"));
clip = AudioSystem.getClip();
clip.open(inputStream);
clip.start();
}
catch (Exception e)
{
System.err.println(e.getMessage());
}
}
}).start();
}
Where can be a mistake?
Exporting Produces No Sound. Please help. Topic is solved POSTS HERE ARE PRIVATE. INSTRUCTIONS BELOW: ALL posts made in this forum are ' Private ' so that only you and staff can see them. This allows sharing of personal data, projects and other information.
Exporting in WAV format is possible without any addons. Exporting as MP3 requires that you install something called LAME encoder into Audacity. There is a way to get that kind of magic.
AME would not export audio from that track, but Premiere would. Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
If you have a stereo file with the left and right blue waves exactly out of step with each other, it may sound a little wacky, but files like that make it through quite a bit of quality control and nobody catches it. Until you play it in a mono sound system (one speaker) or mixdown to mono. Then the sound drops dead.
The problem is in this
AudioInputStream inputStream = AudioSystem.getAudioInputStream(getClass().getResourceAsStream("sound.wav"));
in JAR file isn't working getResourceAsStream
for any reason. So I replace it with getResource
:
AudioInputStream inputStream = AudioSystem.getAudioInputStream(getClass().getResource("sound.wav"));
and this works fine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With