How to play a sound after an event trigger in JAVA.?

such as the following event:

if (variable==1)
{
[code to play sound here]
}

I just need to know how to get a computer to automatically play a sound after an event without any user interaction, such as pushing the pay button on a sound file processor.

✅ Answers

? Best Answer

  • InputStream in = new FileInputStream(filename);
    AudioStream as = new AudioStream(in);
    AudioPlayer.player.start(as);
  • Leave a Comment