Chapter 16 Multimedia

1.         You can use AIFF, MIDI, and RMF in addition to AU and WAS files in Java 2.

 

2.         You can play the audio file directly by using the play() method in the Applet class, or play it by creating an audio clip and using the getAudioClip() method. You can then invoke AudioClip's play(), stop(), and loop() methods to play, stop, or repeatedly play the audio, respectively.

 

3.         You have to run the program as an applet in order to use audio at the present time. Future releases of the Java API may be more flexible, allowing you to get audio files from within Java applications.

 

4.         getDocumentBase() returns the URL of the HTML file; getCodeBase() return the URL of the applet.

 

5.         The getImage() method in the Applet class requires the URL, but the getImage() method in the ImageIcon class does not require the URL.

 

6.         You can get the URL of the files including image and audio files using the following method:

 

URL url = this.getClass().getResource(filename);.

 

7.         The drawImage() method displays the image on the viewing area.

 

8.         Yes, but you have to make sure the image files are obtained through its URL so it can be loaded from a Web browser.

 

9.         The images cannot be stretched in JLabel. The images can be stretched in JPanel.

 

10.       Use the Applet.getAudioClip() method to obtain an audio clip for Java applications.

 

11.       MediaTracker is used to track images to determine their loading status. You can add an image to a MediaTracker object by invoking its instance method, addImage(). The waitForAll() method can be used to see if all images are loaded. You can assign images with the same ID to register them with a media tracker.