Package org.openpatch.scratch.internal
Class Sound
java.lang.Object
org.openpatch.scratch.internal.Sound
The Sound class represents a sound object in Scratch. It includes fields for the name of the
sound and the sound file.
Example usage:
Sound s = new Sound("mySound", "path/to/sound.wav");
s.play();
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
changeVolume
(double step) Changes the volume by a stepgetName()
Returns the namedouble
Returns the volumeboolean
Return true if the sound file is playing.void
pause()
Pauses the playing of the sound file.void
play()
Starts playing the sound file.void
setVolume
(double amp) Sets the volumevoid
stop()
Stops the playing of the sound file.
-
Constructor Details
-
Sound
Creates a new ScratchSound object.- Parameters:
name
- The name of the soundsoundPath
- The path to the sound file
-
Sound
Copies a ScratchSound object.- Parameters:
s
- ScratchSound object to copy
-
-
Method Details
-
getName
Returns the name- Returns:
- the name
-
play
public void play()Starts playing the sound file. -
pause
public void pause()Pauses the playing of the sound file. -
stop
public void stop()Stops the playing of the sound file. -
isPlaying
public boolean isPlaying()Return true if the sound file is playing.- Returns:
- sound file is playing
-
setVolume
public void setVolume(double amp) Sets the volume- Parameters:
amp
- A volume [0...1]
-
changeVolume
public void changeVolume(double step) Changes the volume by a step- Parameters:
step
- The step to change the volume by
-
getVolume
public double getVolume()Returns the volume- Returns:
- the volume
-