tags:

views:

26

answers:

1

How to stop any sound from java application?

A: 

Check out the Sound API.

To simply mute sound you can do something like this:

Port p = (Port)AudioSystem.getLine(Port.Info.SPEAKER);
p.open();

//print out volume
FloatControl vol = (FloatControl)p.getControl(FloatControl.Type.VOLUME);
System.out.println("Current Volume: " + vol.getValue());

//mute sound
BooleanControl mute = (BooleanControl)p.getControl(BooleanControl.Type.MUTE);
mute.setValue(true);

p.close();
dogbane
I think he did mean, not just muting, but solution for pause functionality, to resume playback after. What do you think?
Eugene