Just as demonstrated in the ImageAndSoundExamples.java
file on Moodle, you can call a pre-existing sound file into your program as such:
DrawingPanel panel = new DrawingPanel(500,500);
panel.playSoundFile("my_sound.wav");
Keep in mind that the function panel.playMIDIMusicFile(String file)
works as well, but it appears to be used exclusively for MIDI files. In any case, keep in mind that MP3 file formats are not supported by DrawingPanel
and .au
files are usually the best way to go, but .wav
files work as well.