/** * Start the next track, stopping the current one if it is playing. */ public void nextTrack() { // Start the next track, regardless of if something is already playing or not. In case queue was empty, we are // giving null to startTrack, which is a valid argument and will simply stop the player. player.startTrack(queue.poll(), false); }
/** * Start the next track, stopping the current one if it is playing. */ public void nextTrack() { // Start the next track, regardless of if something is already playing or not. In case queue was empty, we are // giving null to startTrack, which is a valid argument and will simply stop the player. player.startTrack(queue.poll(), false); }
/** * Add the next track to queue or play right away if nothing is in the queue. * * @param track The track to play or add to queue. */ public void queue(AudioTrack track) { // Calling startTrack with the noInterrupt set to true will start the track only if nothing is currently playing. If // something is playing, it returns false and does nothing. In that case the player was already playing so this // track goes to the queue instead. if (!player.startTrack(track, true)) { queue.offer(track); } }
/** * Add the next track to queue or play right away if nothing is in the queue. * * @param track The track to play or add to queue. */ public void queue(AudioTrack track) { // Calling startTrack with the noInterrupt set to true will start the track only if nothing is currently playing. If // something is playing, it returns false and does nothing. In that case the player was already playing so this // track goes to the queue instead. if (!player.startTrack(track, true)) { queue.offer(track); } }
public void queue(QueuedAudioTrack track) { if (queue.isEmpty()) { lastRequester = track.getUserId(); } if (!player.startTrack(track.getTrack(), true)) { queue.offer(track); } }
@SuppressWarnings("unchecked") public synchronized void queue(AudioTrack track, boolean... first) { if (!player.startTrack(track, true)) { if (first != null && first.length > 0 && first[0]) { ((List<AudioTrack>) queue).add(0, track.makeClone()); } else { queue.offer(track.makeClone()); } } }
@Override public void onTrackEnd(AudioPlayer player, AudioTrack track, AudioTrackEndReason endReason) { if (endReason.mayStartNext) { if (isInRepeatMode()) { player.startTrack(track.makeClone(), false); return; } skipTrack(); } } }
public void skipTrack() { trackEnded(); if (isInRepeatMode() && player.getPlayingTrack() != null) { player.startTrack(player.getPlayingTrack().makeClone(), false); return; } player.stopTrack(); QueuedAudioTrack poll = queue.poll(); if (poll != null) { lastRequester = poll.getUserId(); player.startTrack(poll.getTrack(), false); } }
public synchronized void next(AudioTrack last) { AudioTrack track; if (repeat && last != null) { track = last.makeClone(); } else { if (loop && last != null) { queue.add(last.makeClone()); } track = queue.poll(); // potential fix #84 if (track != null) { track = track.makeClone(); } } if (!player.startTrack(track, false)) { musicManager.getConnector().closeConnection(); } }
@Override public boolean startTrack(AudioTrack track, boolean noInterrupt) { if (track == null) { stopTrack(); } else { synchronized (lock) { AudioTrack previousTrack = getPlayingTrack(); if (noInterrupt && previousTrack != null) { return false; } if (previousTrack != null) { if (streamCursor == null) { fallback.stopTrack(); } else { detachStream(); } dispatchEvent(new TrackEndEvent(this, previousTrack, REPLACED)); } streamCursor = manager.openTrack(track, detachListener); if (streamCursor == null) { fallback.startTrack(track, false); } dispatchEvent(new TrackStartEvent(this, track)); } } return true; }