In: Computer Science
Using eclipse IDE, create a java project and call it applets.
Create a package and call it multimedia.
Download an image and save it in package folder.
In the package, create a java applet where you load the image.
Use the drawImage() method to display the image, scaled to different sizes.
Create animation in Java using the image.
In the same package folder, download a sound.
Include the sound in your applets and make it repeated while the applet executes. You can locate, load, and play sounds using both the play() and the getAudioClip() methods.
Include your applet in an html file and run it on Internet Explorer browser.
Note:
I just need the code and the method, as in how to do this specific program. Your help is very much needed, thankyou.
ImageAndSound.java
import java.awt.*;
import java.applet.*;
public class ImageAndSound extends Applet {
private static final long serialVersionUID = 8619622398244769699L;
private Image image;
private AudioClip audioClip;
public void init() {
// give image location
image = getImage(getDocumentBase(),
"https://images-na.ssl-images-amazon.com/images/I/117SgwPpbbL.jpg");
this.setSize(500, 500);
// give sound location
audioClip =
getAudioClip(getCodeBase(),
"http://www.wavsource.com/snds_2018-06-03_5106726768923853/tv/batman/batman_theme_x.wav");
}
public void paint(Graphics g) {
audioClip.play();// playing
sound
for (int i = 40; i < 250; i++) {
// showing animation
g.drawImage(image, 0 + i, 100, 250, 250, this);// show and scaled
the image
try {
Thread.sleep(100);
} catch
(Exception e) {
}
}
}
}
Program Screenshot
Output