User Tools

Site Tools


adding_sound_to_your_application

This is an old revision of the document!


Adding Sound to Your Application

Here is a Java method to play a short bell sound effect that is in a wav format.

You will need the file bell.wav

import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Clip;
 
public void playBell() 
{
  File bellFile = new File("bell.wav");
  try 
  {
      bell = AudioSystem.getClip();
      bell.open(AudioSystem.getAudioInputStream(bellFile));
      bell.start();
  } catch (Exception e) 
  {
      e.printStackTrace();
  }
 
}
adding_sound_to_your_application.1778082192.txt.gz · Last modified: by frchris

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki