Class Playback

java.lang.Object
pi.resources.sound.Playback
All Implemented Interfaces:
Runnable
Direct Known Subclasses:
MusicPlayback, SoundPlayback

public abstract class Playback extends Object implements Runnable
The SoundPlayback class is a wrapper SourceDataLine on which a Sound playback can be carried out.
Author:
Steffen Wilke, Matthias Wilke
See Also:
  • play(Sound)
  • Field Details

  • Method Details

    • start

      public void start()
      Starts playing the audio.
      Throws:
      IllegalStateException - if the audio has already been started
    • addPlaybackListener

      public void addPlaybackListener(PlaybackListener listener)
      Adds a SoundPlaybackListener to this instance.
      Parameters:
      listener - The SoundPlaybackListener to be added.
    • removePlaybackListener

      public void removePlaybackListener(PlaybackListener listener)
      Removes a SoundPlaybackListener from this instance.
      Parameters:
      listener - The SoundPlaybackListener to be removed.
    • paused

      @Setter public void paused(boolean paused)
      Sets the paused state of this playback to the provided value.
      Parameters:
      paused - Whether to pause or resume this playback
    • pause

      public void pause()
      Pauses this playback. If this playback is already paused, this call has no effect.
    • resume

      public void resume()
      Resumes this playback. If this playback is already playing, this call has no effect.
    • isPaused

      public boolean isPaused()
      Determines if this playback is paused.
      Returns:
      Whether this playback is paused
    • isPlaying

      public boolean isPlaying()
      Determines if this playback has sound to play. If it is paused but still in the middle of playback, it will return true, but it will return false if it has finished or it has been cancelled.
      Returns:
      Whether this playback has sound to play
    • cancel

      public void cancel()
      Attempts to cancel the playback of this audio. If the playback was successfully cancelled, it will notify listeners.
    • masterVolume

      @Getter public double masterVolume()
      Gets the current volume of this playback, considering all VolumeControl objects created for it.
      Returns:
      The current volume.
    • volume

      @Getter public double volume()
      Gets the current master volume of this playback. This will be approximately equal to the value set by a previous call to setVolume, though rounding errors may occur.
      Returns:
      The settable volume.
    • volume

      @Setter public void volume(double volume)
      Sets the master volume of this playback.
      Parameters:
      volume - The new volume.
    • createVolumeControl

      public Playback.VolumeControl createVolumeControl()
    • getVolumeControls

      public Collection<Playback.VolumeControl> getVolumeControls()
    • toStringFormatter

      protected ToStringFormatter toStringFormatter(Object object)