60 likes | 235 Views
Sounds. Playing Sounds on the Web in Java. Sound. Applets can play sound clips Audio Files supported: .au .midi .rmf .wave .aiff. AudioClip Interface. Method Summary public void loop() Starts playing this audio clip in a loop.
E N D
Sounds Playing Sounds on the Web in Java
Sound • Applets can play sound clips • Audio Files supported: • .au • .midi • .rmf • .wave • .aiff
AudioClip Interface • Method Summary • public voidloop() Starts playing this audio clip in a loop. • public voidplay() Starts playing this audio clip. • public voidstop() Stops playing this audio clip.
Applet Methods for Audio • The applet class contains methods for getting an AudioClip object • AudioClipgetAudioClip(URLurl) • Returns the AudioClip object specified by the URL argument. • AudioClipgetAudioClip(URLurl, Stringname) • Returns the AudioClip object specified by the URL and name arguments.
Using Runnable • Implement runnable in the class • Get URL of sound • Create Thread to play audioStart thread • play the sound, then • loop or • stop thread when done
Another Way • Create a class extending thread. Constructor has audio URL as parameter • Its run class plays the audio • Create an object of the class • Start the object