Package jmri.jmrit
Class Sound
java.lang.Object
jmri.jmrit.Sound
Provide simple way to load and play sounds in JMRI.
This is placed in the jmri.jmrit package by process of elimination. It doesn't belong in the base jmri package, as it's not a basic interface. Nor is it a specific implementation of a basic interface, which would put it in jmri.jmrix. It seems most like a "tool using JMRI", or perhaps a tool for use with JMRI, so it was placed in jmri.jmrit.
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the sound.voiddispose()Dispose this sound.booleanGet if the clip is closed automatically.voidloop()Play the sound as an endless loopvoidloop(int count) Play the sound in a loop count times.voidplay()Play the sound once.voidplay(boolean autoClose) Play the sound once.static voidplaySoundBuffer(byte[] wavData) Play a sound from a buffervoidsetAutoClose(boolean autoClose) Set if the clip be closed automatically.voidstop()Stop playing a loop.
-
Field Details
-
LARGE_SIZE
- See Also:
-
-
Constructor Details
-
Sound
Create a Sound object using the media file at path- Parameters:
path- path, portable or absolute, to the media- Throws:
NullPointerException- if path cannot be converted into a URL byFileUtilSupport.findURL(java.lang.String)
-
Sound
Create a Sound object using the media file- Parameters:
file- reference to the media- Throws:
MalformedURLException- if file cannot be converted into a valid URL
-
Sound
Create a Sound object using the media URL- Parameters:
url- path to the media- Throws:
NullPointerException- if URL is null
-
-
Method Details
-
setAutoClose
Set if the clip be closed automatically.- Parameters:
autoClose- true if closed automatically
-
getAutoClose
Get if the clip is closed automatically.- Returns:
- true if closed automatically
-
close
Closes the sound. -
play
Play the sound once. -
play
Play the sound once.- Parameters:
autoClose- true if auto close clip, false otherwise. Only valid for clips. For streams, autoClose is ignored.
-
loop
Play the sound as an endless loop -
loop
Play the sound in a loop count times. UseClip.LOOP_CONTINUOUSLYto create an endless loop.- Parameters:
count- the number of times to loop
-
stop
Stop playing a loop. -
playSoundBuffer
Play a sound from a buffer- Parameters:
wavData- data to play
-
dispose
Dispose this sound.
-