Class LocalAudioTrackExecutor

    • Constructor Detail

      • LocalAudioTrackExecutor

        public LocalAudioTrackExecutor​(InternalAudioTrack audioTrack,
                                       AudioConfiguration configuration,
                                       AudioPlayerOptions playerOptions,
                                       boolean useSeekGhosting,
                                       int bufferDuration)
        Parameters:
        audioTrack - The audio track that this executor executes
        configuration - Configuration to use for audio processing
        playerOptions - Mutable player options (for example volume).
        useSeekGhosting - Whether to keep providing old frames continuing from the previous position during a seek until frames from the new position arrive.
        bufferDuration - The size of the frame buffer in milliseconds
    • Method Detail

      • getStackTrace

        public java.lang.StackTraceElement[] getStackTrace()
      • 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
      • waitOnEnd

        public void waitOnEnd()
                       throws java.lang.InterruptedException
        Wait until all the frames from the frame buffer have been consumed. Keeps the buffering thread alive to keep it interruptible for seeking until buffer is empty.
        Throws:
        java.lang.InterruptedException - When interrupted externally (or for seek/stop).
      • 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.
      • executeProcessingLoop

        public void executeProcessingLoop​(LocalAudioTrackExecutor.ReadExecutor readExecutor,
                                          LocalAudioTrackExecutor.SeekExecutor seekExecutor,
                                          boolean waitOnEnd)
        Execute the read and seek loop for the track.
        Parameters:
        readExecutor - Callback for reading the track
        seekExecutor - Callback for performing a seek on the track, may be null on a non-seekable track
      • provide

        public AudioFrame provide​(long timeout,
                                  java.util.concurrent.TimeUnit unit)
                           throws java.util.concurrent.TimeoutException,
                                  java.lang.InterruptedException
        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.
        Throws:
        java.util.concurrent.TimeoutException - When wait time is above zero, but no track info is found in that time.
        java.lang.InterruptedException - When interrupted externally (or for seek/stop).
      • 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).