Implementing the Applet
The folder view of the project is shown in the below image.
Step 1: First, create the file as SoundApplet.java and enter the code into it.
Step 2: Once the code is been inserted then we need to create the AppletImage.html file, through which we will display the output.
HTML
<!DOCTYPE html> < html > < head > < title >Sound Applet</ title > </ head > < body > < applet code = "SoundApplet.class" width = "300" height = "300" > </ applet > </ body > </ html > |
Step 3: We need to have the sample sound file which we need to manage from applet. Here, we have the sound.wav file which is present in the code directory.
Step 4: Then we need to compile the Java code using the below command:
javac SoundApplet.java
Step 5: Now finally we need to run the application using the below command:
appletviewer SoundApplet.html
How to Play Sound using Applet?
In this article, we will be using the Applet window to play the sound or music. Here, we will have buttons like Play, Pause, and Restart. Using these buttons we will manage the sound in the Applet window.
Contact Us