Package com.xebisco.yield
Class AudioPlayer
java.lang.Object
com.xebisco.yield.AbstractBehavior
com.xebisco.yield.ComponentBehavior
com.xebisco.yield.AudioPlayer
- All Implemented Interfaces:
Behavior,Renderable,Closeable,AutoCloseable
The AudioPlayer class is a component behavior that allows for playing, pausing, and manipulating audio clips in a Yield
application.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionThe function returns the audio clip file input.clipRef()The function returns the reference to a clip object.voidclose()Called when the behavior is closed.doublegain()The function returns the value of the variable "gain" as a double.voidgain(double gain) This function sets the gain of the audio player and throws an exception if the gain is not within the valid range.doublelength()This function returns the length of the audio clip.voidloop()This function loops audio using the application's audio manager.doublepan()The function returns the value of the "pan" variable as a double data type.voidpause()This function pauses the audio clip using the application's audio manager.voidplay()This function plays the audio clip using the application's audio manager.booleanplaying()This function returns a boolean value indicating whether the audio is currently playing or not.doubleposition()This function returns the position of the audio player.voidreset()The "reset" function sets the position to 0.setAudioClip(FileInput audioClip) This function sets the audio clip and unloads any previous audio clip if it exists.setClipRef(Object clipRef) This function sets the value of the clipRef variable.setPan(double pan) This function sets the pan of an audio object and throws an exception if the pan is not within the valid range.setPosition(double position) This function sets the position of the audio player using the application's audio manager.Methods inherited from class com.xebisco.yield.ComponentBehavior
application, component, component, entity, onCreate, onLateUpdate, onStart, onUpdate, render, renderIndex, setEntity, setRenderIndex, texture, texture, transformMethods inherited from class com.xebisco.yield.AbstractBehavior
frames, tick
-
Constructor Details
-
AudioPlayer
public AudioPlayer()
-
-
Method Details
-
play
public void play()This function plays the audio clip using the application's audio manager. -
loop
public void loop()This function loops audio using the application's audio manager. -
reset
public void reset()The "reset" function sets the position to 0. -
pause
public void pause()This function pauses the audio clip using the application's audio manager. -
close
Description copied from class:ComponentBehaviorCalled when the behavior is closed.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classComponentBehavior- Throws:
IOException- If an I/O error occurs.
-
position
public double position()This function returns the position of the audio player.- Returns:
- The current position of the audio clip in seconds.
-
setPosition
This function sets the position of the audio player using the application's audio manager.- Parameters:
position- The new position of the audio playback in seconds.- Returns:
- The AudioPlayer instance for method chaining.
-
length
public double length()This function returns the length of the audio clip.- Returns:
- The length of the audio clip in seconds.
-
audioClip
The function returns the audio clip file input.- Returns:
- The FileInput object representing the audio clip.
-
setAudioClip
This function sets the audio clip and unloads any previous audio clip if it exists.- Parameters:
audioClip- The new audio file to be set for the audio player.- Returns:
- The AudioPlayer instance for method chaining.
-
clipRef
The function returns the reference to a clip object.- Returns:
- The reference to the clip object.
-
setClipRef
This function sets the value of the clipRef variable.- Parameters:
clipRef- The new value for the clipRef variable.- Returns:
- The AudioPlayer instance for method chaining.
-
pan
public double pan()The function returns the value of the "pan" variable as a double data type.- Returns:
- The current stereo panning value of the audio.
-
setPan
This function sets the pan of an audio object and throws an exception if the pan is not within the valid range.- Parameters:
pan- The new stereo panning value of the audio. It should be between -1.0 (fully panned to the left) and 1.0 (fully panned to the right).- Returns:
- The AudioPlayer instance for method chaining.
-
playing
public boolean playing()This function returns a boolean value indicating whether the audio is currently playing or not.- Returns:
- True if the audio is currently playing, false otherwise.
-
gain
public double gain()The function returns the value of the variable "gain" as a double.- Returns:
- The current audio gain level.
-
gain
public void gain(double gain) This function sets the gain of the audio player and throws an exception if the gain is not within the valid range.- Parameters:
gain- The new audio gain level to be set. It should be between 0.0 (no sound) and 1.0 (maximum volume).
-