use of com.sedmelluq.discord.lavaplayer.player.event.TrackEndEvent in project lavaplayer by sedmelluq.
the class AudioPlayer method startTrack.
/**
* @param track The track to start playing, passing null will stop the current track and return false
* @param noInterrupt Whether to only start if nothing else is playing
* @return True if the track was started
*/
public boolean startTrack(AudioTrack track, boolean noInterrupt) {
InternalAudioTrack newTrack = (InternalAudioTrack) track;
InternalAudioTrack previousTrack;
synchronized (trackSwitchLock) {
previousTrack = activeTrack;
if (noInterrupt && previousTrack != null) {
return false;
}
activeTrack = newTrack;
lastRequestTime = System.currentTimeMillis();
lastReceiveTime = System.nanoTime();
stuckEventSent = false;
if (previousTrack != null) {
previousTrack.stop();
dispatchEvent(new TrackEndEvent(this, previousTrack, newTrack == null ? STOPPED : REPLACED));
shadowTrack = previousTrack;
}
}
if (newTrack == null) {
shadowTrack = null;
return false;
}
dispatchEvent(new TrackStartEvent(this, newTrack));
manager.executeTrack(this, newTrack, manager.getConfiguration(), options);
return true;
}
use of com.sedmelluq.discord.lavaplayer.player.event.TrackEndEvent in project lavaplayer by sedmelluq.
the class AudioPlayer method stopWithReason.
private void stopWithReason(AudioTrackEndReason reason) {
shadowTrack = null;
synchronized (trackSwitchLock) {
InternalAudioTrack previousTrack = activeTrack;
activeTrack = null;
if (previousTrack != null) {
previousTrack.stop();
dispatchEvent(new TrackEndEvent(this, previousTrack, reason));
}
}
}
use of com.sedmelluq.discord.lavaplayer.player.event.TrackEndEvent in project lavaplayer by sedmelluq.
the class AudioPlayer method handleTerminator.
private void handleTerminator(InternalAudioTrack track) {
synchronized (trackSwitchLock) {
if (activeTrack == track) {
activeTrack = null;
dispatchEvent(new TrackEndEvent(this, track, track.getActiveExecutor().failedBeforeLoad() ? LOAD_FAILED : FINISHED));
}
}
}
Aggregations