Welcome to the CSC Q&A.
Get help and give help!
Write great code!
It is our choices... that show what we truly are, far more than our abilities.

Categories

+14 votes
asked in CSC211_Winter2018 by (8 points)

1 Answer

+6 votes

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.

answered by (462 points)
...