2 Replies - 360 Views - Last Post: 24 April 2012 - 10:58 AM Rate Topic: -----

#1 Crowz  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 68
  • Joined: 09-February 12

Easiest way to implement sounds in java?

Posted 24 April 2012 - 09:11 AM

So let's say I have a JoGL program.
It's already programmed so when something hits a wall, it's velocity negates and it goes the other way.
These are obviously in if statements something like this:

if (x < radius) {
     x = radius;
     vx = -vx;
}



So I want to put within that if statement to play a sound when that condition is met.
Is This A Good Question/Topic? 0
  • +

Replies To: Easiest way to implement sounds in java?

#2 g00se  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 2812
  • View blog
  • Posts: 11,899
  • Joined: 20-September 08

Re: Easiest way to implement sounds in java?

Posted 24 April 2012 - 10:34 AM

http://technojeeves....ig-clock-applet is something in which i've implemented sound to my satisfaction. Source there too
Was This Post Helpful? 0
  • +
  • -

#3 farrell2k  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 856
  • Posts: 2,620
  • Joined: 29-July 11

Re: Easiest way to implement sounds in java?

Posted 24 April 2012 - 10:58 AM

AudioInputStream ais = AudioSystem.getAudioInputStream(new File("x.wav"));
Clip clip = AudioSystem.getClip();
clip.open(ais);
clip.start();


Was This Post Helpful? 1
  • +
  • -

Page 1 of 1