use of com.sedmelluq.discord.lavaplayer.player.event.TrackStartEvent 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;
}
Aggregations