Class ActiverseSound
java.lang.Object
ActiverseEngine.ActiverseSound
Represents a sound player for playing audio files.
This class provides methods to load, play, stop, and manage the volume of audio files.
- Version:
- 1.4.1
-
Constructor Summary
ConstructorsConstructorDescriptionActiverseSound(String filename) Constructs a new ActiverseSound object with the specified audio file. -
Method Summary
Modifier and TypeMethodDescriptionvoiddispose()Releases system resources associated with the audio clip.protected voidfinalize()Ensures resources are cleaned up when object is garbage collected.Gets the filename of the audio file.longGets the total length of the audio clip in milliseconds.longGets the current playback position in milliseconds.floatGets the current volume of the audio file.booleanChecks if the audio file is currently playing.voidloop()Loops the audio continuously.voidloop(int count) Loops the audio a specified number of times.voidpause()Pauses the currently playing audio.voidplay()Plays the loaded audio file.voidresume()Resumes the audio from where it was paused.voidseek(long milliseconds) Seeks to a specific time position in the audio.voidsetVolume(float volume) Sets the volume of the audio file.voidstop()Stops the currently playing audio file.
-
Constructor Details
-
ActiverseSound
Constructs a new ActiverseSound object with the specified audio file.- Parameters:
filename- The path to the audio file.
-
-
Method Details
-
play
public void play()Plays the loaded audio file. -
stop
public void stop()Stops the currently playing audio file. -
isPlaying
public boolean isPlaying()Checks if the audio file is currently playing.- Returns:
- true if the audio file is playing, false otherwise.
-
getFilename
Gets the filename of the audio file.- Returns:
- The filename of the audio file.
-
getVolume
public float getVolume()Gets the current volume of the audio file.- Returns:
- The current volume level (range: 0.0 to 1.0).
-
setVolume
public void setVolume(float volume) Sets the volume of the audio file.- Parameters:
volume- The volume level to set (range: 0.0 to 1.0).
-
loop
public void loop()Loops the audio continuously. -
loop
public void loop(int count) Loops the audio a specified number of times.- Parameters:
count- The number of times to loop. Use Clip.LOOP_CONTINUOUSLY for infinite.
-
pause
public void pause()Pauses the currently playing audio. -
resume
public void resume()Resumes the audio from where it was paused. -
seek
public void seek(long milliseconds) Seeks to a specific time position in the audio.- Parameters:
milliseconds- The position in milliseconds to seek to.
-
getPosition
public long getPosition()Gets the current playback position in milliseconds.- Returns:
- The current position in milliseconds.
-
getLength
public long getLength()Gets the total length of the audio clip in milliseconds.- Returns:
- The duration in milliseconds.
-
dispose
public void dispose()Releases system resources associated with the audio clip. -
finalize
-