Class PrimordialAudioTrackExecutor
- java.lang.Object
-
- com.sedmelluq.discord.lavaplayer.track.playback.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 Summary
Constructors Constructor Description PrimordialAudioTrackExecutor(AudioTrackInfo trackInfo)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddMarker(TrackMarker marker)Adds a marker to the track.voidapplyStateToExecutor(AudioTrackExecutor executor)Apply the position and loop state that had been set on this executor to an actual executor.voidexecute(TrackStateListener listener)Execute the track, which means that this thread will fill the frame buffer until the track finishes or is stopped.booleanfailedBeforeLoad()AudioFrameBuffergetAudioBuffer()longgetPosition()AudioTrackStategetState()AudioFrameprovide()AudioFrameprovide(long timeout, java.util.concurrent.TimeUnit unit)booleanprovide(MutableAudioFrame targetFrame)booleanprovide(MutableAudioFrame targetFrame, long timeout, java.util.concurrent.TimeUnit unit)voidremoveMarker(TrackMarker marker)Removes a marker from the track.voidsetMarker(TrackMarker marker)Set the track position marker.voidsetPosition(long timecode)Perform seek to the specified timecode.voidstop()Stop playing the track, terminating the thread that is filling the frame buffer.
-
-
-
Constructor Detail
-
PrimordialAudioTrackExecutor
public PrimordialAudioTrackExecutor(AudioTrackInfo trackInfo)
- Parameters:
trackInfo- Information of the track this executor is used with
-
-
Method Detail
-
getAudioBuffer
public AudioFrameBuffer getAudioBuffer()
- Specified by:
getAudioBufferin interfaceAudioTrackExecutor- Returns:
- The audio buffer of this executor.
-
execute
public void execute(TrackStateListener listener)
Description copied from interface:AudioTrackExecutorExecute the track, which means that this thread will fill the frame buffer until the track finishes or is stopped.- Specified by:
executein interfaceAudioTrackExecutor- Parameters:
listener- Listener for track state events
-
stop
public void stop()
Description copied from interface:AudioTrackExecutorStop playing the track, terminating the thread that is filling the frame buffer. Subsequent playback requires a new executor.- Specified by:
stopin interfaceAudioTrackExecutor
-
getPosition
public long getPosition()
- Specified by:
getPositionin interfaceAudioTrackExecutor- 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:AudioTrackExecutorPerform seek to the specified timecode.- Specified by:
setPositionin interfaceAudioTrackExecutor- Parameters:
timecode- The timecode in milliseconds
-
getState
public AudioTrackState getState()
- Specified by:
getStatein interfaceAudioTrackExecutor- Returns:
- Current state of the executor
-
setMarker
public void setMarker(TrackMarker marker)
Description copied from interface:AudioTrackExecutorSet the track position marker. This will clear all existing markers.- Specified by:
setMarkerin interfaceAudioTrackExecutor- Parameters:
marker- Track position marker to set.
-
addMarker
public void addMarker(TrackMarker marker)
Description copied from interface:AudioTrackExecutorAdds a marker to the track. Markers can be used to execute code when the track reaches a certain position.- Specified by:
addMarkerin interfaceAudioTrackExecutor- Parameters:
marker- The marker to add.
-
removeMarker
public void removeMarker(TrackMarker marker)
Description copied from interface:AudioTrackExecutorRemoves a marker from the track.- Specified by:
removeMarkerin interfaceAudioTrackExecutor- Parameters:
marker- The marker to remove.
-
failedBeforeLoad
public boolean failedBeforeLoad()
- Specified by:
failedBeforeLoadin interfaceAudioTrackExecutor- Returns:
- True if this track threw an exception before it provided any audio.
-
provide
public AudioFrame provide()
- Specified by:
providein interfaceAudioFrameProvider- Returns:
- Provided frame, or null if none available
-
provide
public AudioFrame provide(long timeout, java.util.concurrent.TimeUnit unit)
- Specified by:
providein interfaceAudioFrameProvider- 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:
providein interfaceAudioFrameProvider- Parameters:
targetFrame- Frame to update with the details and data of the provided frame.- Returns:
trueif 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:
providein interfaceAudioFrameProvider- Parameters:
targetFrame- Frame to update with the details and data of the provided frame.timeout- Timeout.unit- Time unit for the timeout value.- Returns:
trueif 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
-
-