Class PlaybackThread

java.lang.Object
ca.corbett.extras.audio.PlaybackThread
All Implemented Interfaces:
Runnable

public class PlaybackThread extends Object implements Runnable
Provides a worker thread that can be used to play audio clips. You can instantiate this directly, but it's easier to go through the various play() wrapper functions in AudioUtil to generate and start the thread for you.
Since:
2018-01-10
Author:
scorbo2
  • Field Details

    • UPDATE_MS

      protected static int UPDATE_MS
    • clip

      protected final Clip clip
    • isPlaying

      protected volatile boolean isPlaying
    • offsetms

      protected final long offsetms
    • limitms

      protected final long limitms
    • lastPlayPositionms

      protected long lastPlayPositionms
    • listeners

      protected final List<PlaybackListener> listeners
    • stopReason

      protected volatile PlaybackThread.StopReason stopReason
  • Constructor Details

  • Method Details

    • isPlaying

      public boolean isPlaying()
    • stop

      public void stop()
    • getCurrentOffset

      public long getCurrentOffset()
      Returns the current offset, in milliseconds, of the playback. If the playback is stopped, this value will represent the last playback position.
      Returns:
      The current offset, in ms, of the playback.
    • getUpdateIntervalMs

      public static int getUpdateIntervalMs()
    • setUpdateIntervalMs

      public static void setUpdateIntervalMs(int ms)
    • run

      public void run()
      Specified by:
      run in interface Runnable
    • addPlaybackListener

      public void addPlaybackListener(PlaybackListener listener)
    • removePlaybackListener

      public void removePlaybackListener(PlaybackListener listener)
    • fireStartedEvent

      protected void fireStartedEvent()
    • fireProgressEvent

      protected boolean fireProgressEvent(long current, long total)
    • fireStopEvent

      protected void fireStopEvent(PlaybackThread.StopReason stopReason)