com.sedmelluq.discord.lavaplayer.track.AudioTrackEndReason Java Examples
The following examples show how to use
com.sedmelluq.discord.lavaplayer.track.AudioTrackEndReason.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Music.java From DiscordBot with Apache License 2.0 | 6 votes |
@Override public void onTrackEnd(AudioPlayer player, AudioTrack track, AudioTrackEndReason endReason) { if (getTrackManager(guild).getQueuedTracks().size() < 2 && endlessMode) { endlessList.forEach(t -> getTrackManager(guild).queue(t, endlessAuthor)); if (guild.getTextChannelsByName(SSSS.getMUSICCHANNEL(guild), true).size() > 0) guild.getTextChannelsByName(SSSS.getMUSICCHANNEL(guild), true).get(0).sendMessage(MSGS.success().setDescription("Repeated queue. *(endless mode)*").build()).queue(); } new Timer().schedule(new TimerTask() { @Override public void run() { if (player.getPlayingTrack() == null) { if (guild.getTextChannelsByName(SSSS.getMUSICCHANNEL(guild), true).size() > 0) { guild.getTextChannelsByName(SSSS.getMUSICCHANNEL(guild), true).get(0).getManager().setTopic( "-music help" ).queue(); } } } }, 500); }
Example #2
Source File: TrackManager.java From DiscordBot with Apache License 2.0 | 6 votes |
@Override public void onTrackEnd(AudioPlayer player, AudioTrack track, AudioTrackEndReason endReason) { try { Guild g = queue.poll().getAuthor().getGuild(); if (queue.isEmpty()) { new Timer().schedule(new TimerTask() { @Override public void run() { g.getAudioManager().closeAudioConnection(); } }, 500); } else { player.playTrack(queue.element().getTrack()); } } catch (Exception e) {} }
Example #3
Source File: EventEmitter.java From Lavalink with MIT License | 6 votes |
@Override public void onTrackEnd(AudioPlayer player, AudioTrack track, AudioTrackEndReason endReason) { JSONObject out = new JSONObject(); out.put("op", "event"); out.put("type", "TrackEndEvent"); out.put("guildId", linkPlayer.getGuildId()); try { out.put("track", Util.toMessage(audioPlayerManager, track)); } catch (IOException e) { out.put("track", JSONObject.NULL); } out.put("reason", endReason.toString()); linkPlayer.getSocket().send(out); }
Example #4
Source File: AudioListener.java From DiscordBot with Apache License 2.0 | 6 votes |
@Override public void onTrackEnd(AudioPlayer audioPlayer, AudioTrack audioTrack, AudioTrackEndReason audioTrackEndReason) { if (audioTrackEndReason.equals(AudioTrackEndReason.FINISHED) && audioTrackEndReason.mayStartNext) { LogHelper.debug("Track Finished, Playing next."); DiscordBot.getInstance().getDiscord().getAudioQueue().playNext(); return; } if (audioTrackEndReason.equals(AudioTrackEndReason.STOPPED)) { LogHelper.debug("Track stopped."); return; } if (audioTrackEndReason.equals(AudioTrackEndReason.REPLACED)) { LogHelper.debug("Track replaced."); } }
Example #5
Source File: PlayerServiceImpl.java From JuniperBot with GNU General Public License v3.0 | 6 votes |
@Override public void skipTrack(Member member, Guild guild) { PlaybackInstance instance = get(guild); if (instance == null) { return; } // сбросим режим если принудительно вызвали следующий if (RepeatMode.CURRENT.equals(instance.getMode())) { instance.setMode(RepeatMode.NONE); } if (instance.getCurrent() != null) { instance.getCurrent().setEndReason(EndReason.SKIPPED); instance.getCurrent().setEndMemberId(member.getUser().getIdLong()); } onTrackEnd(instance, AudioTrackEndReason.FINISHED); }
Example #6
Source File: PlayerServiceImpl.java From JuniperBot with GNU General Public License v3.0 | 6 votes |
@Override protected void onTrackEnd(PlaybackInstance instance, AudioTrackEndReason endReason) { notifyCurrentEnd(instance, endReason); if (endReason.mayStartNext && featureSetService.isAvailable(instance.getGuildId())) { if (instance.playNext()) { return; } TrackRequest current = instance.getCurrent(); if (current != null) { contextService.withContext(instance.getGuildId(), () -> messageManager.onQueueEnd(current)); } } if (endReason != AudioTrackEndReason.REPLACED) { // execute instance reset out of current thread taskExecutor.execute(() -> clearInstance(instance, false)); } }
Example #7
Source File: PlayerServiceImpl.java From JuniperBot with GNU General Public License v3.0 | 6 votes |
private void clearInstance(PlaybackInstance instance, boolean notify) { if (instance == null || !instance.stop()) { return; } if (notify) { notifyCurrentEnd(instance, AudioTrackEndReason.STOPPED); } if (featureSetService.isAvailable(instance.getGuildId())) { musicConfigService.updateVolume(instance.getGuildId(), instance.getPlayer().getVolume()); } Guild guild = discordService.getShardManager().getGuildById(instance.getGuildId()); if (guild != null) { lavaAudioService.closeConnection(guild); } messageManager.clear(instance.getGuildId()); instances.remove(instance.getGuildId()); unregisterInstance(instance); }
Example #8
Source File: PlayerServiceImpl.java From JuniperBot with GNU General Public License v3.0 | 5 votes |
private void notifyCurrentEnd(PlaybackInstance instance, AudioTrackEndReason endReason) { TrackRequest current = instance.getCurrent(); if (current != null) { if (current.getEndReason() == null) { current.setEndReason(EndReason.getForLavaPlayer(endReason)); } contextService.withContext(current.getGuildId(), () -> messageManager.onTrackEnd(current)); } }
Example #9
Source File: TrackScheduler.java From Yui with Apache License 2.0 | 5 votes |
@Override public void onTrackEnd(AudioPlayer player, AudioTrack track, AudioTrackEndReason endReason) { this.lastTrack = track; // Only start the next track if the end reason is suitable for it (FINISHED or LOAD_FAILED) if (endReason.mayStartNext) { if (repeating) player.startTrack(lastTrack.makeClone(), false); else nextTrack(); } }
Example #10
Source File: TrackScheduler.java From MantaroBot with GNU General Public License v3.0 | 5 votes |
@Override public void onTrackEnd(IPlayer player, AudioTrack track, AudioTrackEndReason endReason) { if (endReason.mayStartNext) { nextTrack(false, false); onTrackStart(); } }
Example #11
Source File: TrackScheduler.java From lavaplayer with Apache License 2.0 | 5 votes |
@Override public void onTrackEnd(AudioPlayer player, AudioTrack track, AudioTrackEndReason endReason) { // Only start the next track if the end reason is suitable for it (FINISHED or LOAD_FAILED) if (endReason.mayStartNext) { nextTrack(); } }
Example #12
Source File: MusicScheduler.java From lavaplayer with Apache License 2.0 | 5 votes |
@Override public void onTrackEnd(AudioPlayer player, AudioTrack track, AudioTrackEndReason endReason) { if (endReason.mayStartNext) { startNextTrack(true); messageDispatcher.sendMessage(String.format("Track %s finished.", track.getInfo().title)); } }
Example #13
Source File: TrackScheduler.java From lavaplayer with Apache License 2.0 | 5 votes |
@Override public void onTrackEnd(AudioPlayer player, AudioTrack track, AudioTrackEndReason endReason) { // Only start the next track if the end reason is suitable for it (FINISHED or LOAD_FAILED) if (endReason.mayStartNext) { nextTrack(); } }
Example #14
Source File: RemoteAudioTrackExecutor.java From lavaplayer with Apache License 2.0 | 5 votes |
@Override public void stop() { frameBuffer.lockBuffer(); frameBuffer.setTerminateOnEmpty(); frameBuffer.clear(); markerTracker.trigger(STOPPED); remoteNodeManager.onTrackEnd(null, track, AudioTrackEndReason.STOPPED); }
Example #15
Source File: RemoteNodeManager.java From lavaplayer with Apache License 2.0 | 5 votes |
@Override public void onTrackEnd(AudioPlayer player, AudioTrack track, AudioTrackEndReason endReason) { AudioTrackExecutor executor = ((InternalAudioTrack) track).getActiveExecutor(); if (endReason != AudioTrackEndReason.FINISHED && executor instanceof RemoteAudioTrackExecutor) { for (RemoteNodeProcessor processor : activeProcessors) { processor.trackEnded((RemoteAudioTrackExecutor) executor, true); } } }
Example #16
Source File: DefaultAudioPlayer.java From lavaplayer with Apache License 2.0 | 5 votes |
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)); } } }
Example #17
Source File: EventEmitter.java From andesite-node with MIT License | 5 votes |
@Override public void onTrackEnd(AudioPlayer player, AudioTrack track, AudioTrackEndReason endReason) { sendEvent.accept(event("TrackEndEvent", track) .put("reason", endReason.toString()) .put("mayStartNext", endReason.mayStartNext)); sendPlayerUpdate(); }
Example #18
Source File: TrackEventListener.java From Shadbot with GNU General Public License v3.0 | 5 votes |
@Override public void onTrackEnd(AudioPlayer player, AudioTrack track, AudioTrackEndReason endReason) { Mono.justOrEmpty(MusicManager.getInstance().getGuildMusic(this.guildId)) .filter(ignored -> endReason == AudioTrackEndReason.FINISHED) // Everything seems fine, reset error counter. .doOnNext(ignored -> this.errorCount.set(0)) .flatMap(ignored -> this.nextOrEnd()) .subscribeOn(Schedulers.boundedElastic()) .subscribe(null, ExceptionHandler::handleUnknownError); }
Example #19
Source File: PlayerListener.java From FlareBot with MIT License | 5 votes |
@Override public void onTrackEnd(AudioPlayer aplayer, AudioTrack atrack, AudioTrackEndReason reason) { GuildWrapper wrapper = FlareBotManager.instance().getGuild(player.getGuildId()); if (wrapper == null) return; // No song on next if (player.getPlaylist().isEmpty()) { FlareBotManager.instance().getLastActive().put(Long.parseLong(player.getGuildId()), System.currentTimeMillis()); } VoteUtil.remove(SkipCommand.getSkipUUID(), wrapper.getGuild()); if (wrapper.isSongnickEnabled()) { if (GuildUtils.canChangeNick(player.getGuildId())) { Guild c = wrapper.getGuild(); if (c == null) { wrapper.setSongnick(false); } else { if (player.getPlaylist().isEmpty()) c.getController().setNickname(c.getSelfMember(), null).queue(); } } else { if (!GuildUtils.canChangeNick(player.getGuildId())) { MessageUtils.sendPM(Getters.getGuildById(player.getGuildId()).getOwner().getUser(), "FlareBot can't change it's nickname so SongNick has been disabled!"); } } } }
Example #20
Source File: RequestHandler.java From andesite-node with MIT License | 5 votes |
private static void setEndMarker(AudioPlayer player, AudioTrack track, JsonObject object) { var end = asLong(object.getValue("end", object.getValue("endTime")), 0); if(track != null && end != 0) { track.setMarker(new TrackMarker(end, state -> { switch(state) { case REACHED: case BYPASSED: case LATE: STOP_PLAYER_WITH_REASON.accept(player, AudioTrackEndReason.FINISHED); } })); } }
Example #21
Source File: PlayerServiceImpl.java From JuniperBot with GNU General Public License v3.0 | 4 votes |
@Override protected void onTrackStuck(PlaybackInstance instance) { onTrackEnd(instance, AudioTrackEndReason.LOAD_FAILED); }
Example #22
Source File: AudioLossCounter.java From Lavalink with MIT License | 4 votes |
@Override public void onTrackEnd(AudioPlayer __, AudioTrack ___, AudioTrackEndReason ____) { lastTrackEnded = System.currentTimeMillis(); }
Example #23
Source File: Player.java From Lavalink with MIT License | 4 votes |
@Override public void onTrackEnd(AudioPlayer player, AudioTrack track, AudioTrackEndReason endReason) { myFuture.cancel(false); }
Example #24
Source File: StreamAudioPlayer.java From lavaplayer with Apache License 2.0 | 4 votes |
@Override public void onTrackEnd(AudioPlayer player, AudioTrack track, AudioTrackEndReason endReason) { if (endReason.mayStartNext || endReason == AudioTrackEndReason.CLEANUP) { dispatchEvent(new TrackEndEvent(StreamAudioPlayer.this, track, endReason)); } }
Example #25
Source File: TrackEndEvent.java From lavaplayer with Apache License 2.0 | 4 votes |
/** * @param player Audio player * @param track Audio track that ended * @param endReason The reason why the track stopped playing */ public TrackEndEvent(AudioPlayer player, AudioTrack track, AudioTrackEndReason endReason) { super(player); this.track = track; this.endReason = endReason; }
Example #26
Source File: TrackEndEvent.java From Lavalink-Client with MIT License | 4 votes |
public AudioTrackEndReason getReason() { return reason; }
Example #27
Source File: TrackEndEvent.java From Lavalink-Client with MIT License | 4 votes |
public TrackEndEvent(IPlayer player, AudioTrack track, AudioTrackEndReason reason) { super(player); this.track = track; this.reason = reason; }
Example #28
Source File: LavalinkInternalPlayerEventHandler.java From Lavalink-Client with MIT License | 4 votes |
@Override public void onTrackEnd(IPlayer player, AudioTrack track, AudioTrackEndReason endReason) { if (endReason != AudioTrackEndReason.REPLACED && endReason != AudioTrackEndReason.STOPPED) { ((LavalinkPlayer) player).clearTrack(); } }
Example #29
Source File: FrameLossTracker.java From andesite-node with MIT License | 4 votes |
@Override public void onTrackEnd(AudioPlayer player, AudioTrack track, AudioTrackEndReason endReason) { end(); }
Example #30
Source File: AudioEventAdapter.java From lavaplayer with Apache License 2.0 | 2 votes |
/** * @param player Audio player * @param track Audio track that ended * @param endReason The reason why the track stopped playing */ public void onTrackEnd(AudioPlayer player, AudioTrack track, AudioTrackEndReason endReason) { // Adapter dummy method }