Class PrimordialAudioTrackExecutor

  • All Implemented Interfaces:
    AudioFrameProvider, AudioTrackExecutor

    public class PrimordialAudioTrackExecutor
    extends java.lang.Object
    implements AudioTrackExecutor
    Executor implementation which is used before a track has actually been executed. Saves the position and loop information, which is applied to the actual executor when one is attached.
    • Constructor Detail

      • PrimordialAudioTrackExecutor

        public PrimordialAudioTrackExecutor​(AudioTrackInfo trackInfo)
        Parameters:
        trackInfo - Information of the track this executor is used with
    • Method Detail

      • execute

        public void execute​(TrackStateListener listener)
        Description copied from interface: AudioTrackExecutor
        Execute the track, which means that this thread will fill the frame buffer until the track finishes or is stopped.
        Specified by:
        execute in interface AudioTrackExecutor
        Parameters:
        listener - Listener for track state events
      • stop

        public void stop()
        Description copied from interface: AudioTrackExecutor
        Stop playing the track, terminating the thread that is filling the frame buffer. Subsequent playback requires a new executor.
        Specified by:
        stop in interface AudioTrackExecutor
      • getPosition

        public long getPosition()
        Specified by:
        getPosition in interface AudioTrackExecutor
        Returns:
        Timecode of the last played frame or in case a seek is in progress, the timecode of the frame being seeked to.
      • setPosition

        public void setPosition​(long timecode)
        Description copied from interface: AudioTrackExecutor
        Perform seek to the specified timecode.
        Specified by:
        setPosition in interface AudioTrackExecutor
        Parameters:
        timecode - The timecode in milliseconds
      • setMarker

        public void setMarker​(TrackMarker marker)
        Description copied from interface: AudioTrackExecutor
        Set the track position marker. This will clear all existing markers.
        Specified by:
        setMarker in interface AudioTrackExecutor
        Parameters:
        marker - Track position marker to set.
      • addMarker

        public void addMarker​(TrackMarker marker)
        Description copied from interface: AudioTrackExecutor
        Adds a marker to the track. Markers can be used to execute code when the track reaches a certain position.
        Specified by:
        addMarker in interface AudioTrackExecutor
        Parameters:
        marker - The marker to add.
      • failedBeforeLoad

        public boolean failedBeforeLoad()
        Specified by:
        failedBeforeLoad in interface AudioTrackExecutor
        Returns:
        True if this track threw an exception before it provided any audio.
      • provide

        public AudioFrame provide​(long timeout,
                                  java.util.concurrent.TimeUnit unit)
        Specified by:
        provide in interface AudioFrameProvider
        Parameters:
        timeout - Specifies the maximum time to wait for data. Pass 0 for non-blocking mode.
        unit - Specifies the time unit of the maximum wait time.
        Returns:
        Provided frame. In case wait time is above zero, null indicates that no data is not available at the current moment, otherwise null means the end of the track.
      • provide

        public boolean provide​(MutableAudioFrame targetFrame)
        Specified by:
        provide in interface AudioFrameProvider
        Parameters:
        targetFrame - Frame to update with the details and data of the provided frame.
        Returns:
        true if a frame was provided.
      • provide

        public boolean provide​(MutableAudioFrame targetFrame,
                               long timeout,
                               java.util.concurrent.TimeUnit unit)
                        throws java.util.concurrent.TimeoutException,
                               java.lang.InterruptedException
        Specified by:
        provide in interface AudioFrameProvider
        Parameters:
        targetFrame - Frame to update with the details and data of the provided frame.
        timeout - Timeout.
        unit - Time unit for the timeout value.
        Returns:
        true if a frame was provided.
        Throws:
        java.util.concurrent.TimeoutException - If no frame became available within the timeout.
        java.lang.InterruptedException - When interrupted externally (or for seek/stop).
      • applyStateToExecutor

        public void applyStateToExecutor​(AudioTrackExecutor executor)
        Apply the position and loop state that had been set on this executor to an actual executor.
        Parameters:
        executor - The executor to apply the state to