Module javafx.media

Class AudioClip

java.lang.Object
javafx.scene.media.AudioClip

public final class AudioClip extends Object
An AudioClip represents a segment of audio that can be played with minimal latency. Clips are loaded similarly to Media objects but have different behavior, for example, a Media cannot play itself. AudioClips are also usable immediately. Playback behavior is fire and forget: once one of the play methods is called the only operable control is stop(). An AudioClip may also be played multiple times simultaneously. To accomplish the same task using Media one would have to create a new MediaPlayer object for each sound played in parallel. Media objects are however better suited for long-playing sounds. This is primarily because AudioClip stores in memory the raw, uncompressed audio data for the entire sound, which can be quite large for long audio clips. A MediaPlayer will only have enough decompressed audio data pre-rolled in memory to play for a short amount of time so it is much more memory efficient for long clips, especially if they are compressed.

Example usage:


     AudioClip plonkSound = new AudioClip("http://somehost/path/plonk.aiff");
     plonkSound.play();
 
Since:
JavaFX 2.0