Java Code Examples for com.sedmelluq.discord.lavaplayer.track.AudioTrack#getDuration()
The following examples show how to use
com.sedmelluq.discord.lavaplayer.track.AudioTrack#getDuration() .
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: ForwardCommand.java From JuniperBot with GNU General Public License v3.0 | 6 votes |
@Override protected boolean doInternal(GuildMessageReceivedEvent message, TrackRequest request, long millis) { PlaybackInstance instance = playerService.get(message.getGuild()); AudioTrack track = request.getTrack(); long duration = track.getDuration(); long position = instance.getPosition(); millis = Math.min(duration - position, millis); if (instance.seek(position + millis)) { messageManager.onMessage(message.getChannel(), "discord.command.audio.forward", messageManager.getTitle(track.getInfo()), CommonUtils.formatDuration(millis)); request.setResetMessage(true); return true; } return fail(message); }
Example 2
Source File: SeekCommand.java From JuniperBot with GNU General Public License v3.0 | 5 votes |
@Override protected boolean doInternal(GuildMessageReceivedEvent message, TrackRequest request, long millis) { AudioTrack track = request.getTrack(); long duration = track.getDuration(); millis = Math.min(duration, millis); if (playerService.get(message.getGuild()).seek(millis)) { messageManager.onMessage(message.getChannel(), "discord.command.audio.seek", messageManager.getTitle(track.getInfo()), CommonUtils.formatDuration(millis)); request.setResetMessage(true); return true; } return fail(message); }
Example 3
Source File: AudioMessageManager.java From JuniperBot with GNU General Public License v3.0 | 5 votes |
private String getTextProgress(PlaybackInstance instance, AudioTrack track, boolean bonusActive) { StringBuilder builder = new StringBuilder(); boolean closeDuration = false; if (bonusActive && instance.getPlayer().getPlayingTrack() != null) { if (!track.getInfo().isStream) { double progress = (double) instance.getPosition() / (double) track.getDuration(); builder.append(AudioUtils.getProgressString((int) (progress * 100))).append(" "); } builder.append("`").append(CommonUtils.formatDuration(instance.getPosition())); closeDuration = true; } if (!track.getInfo().isStream) { if (track.getDuration() >= 0) { if (bonusActive && builder.length() > 0) { builder.append(" / "); } builder.append(CommonUtils.formatDuration(track.getDuration())); } } if (closeDuration) { builder.append("`"); } if (track.getInfo().isStream) { builder.append(String.format(bonusActive ? " (%s)" : "%s", messageService.getMessage("discord.command.audio.panel.stream"))); } return builder.toString(); }
Example 4
Source File: AudioUtils.java From MantaroBot with GNU General Public License v3.0 | 5 votes |
public static String getQueueList(ConcurrentLinkedDeque<AudioTrack> queue) { StringBuilder sb = new StringBuilder(); int n = 1; for (AudioTrack audioTrack : queue) { long aDuration = audioTrack.getDuration(); String duration = String.format("%02d:%02d", TimeUnit.MILLISECONDS.toMinutes(aDuration), TimeUnit.MILLISECONDS.toSeconds(aDuration) - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(aDuration)) ); User dj = audioTrack.getUserData() != null ? MantaroBot.getInstance().getShardManager() .getUserById(String.valueOf(audioTrack.getUserData())) : null; sb.append("**") .append(n) .append(". [") .append(StringUtils.limit(audioTrack.getInfo().title, 30)) .append("](") .append(audioTrack.getInfo().uri) .append(")** (") .append(duration) .append(")") .append(dj != null ? " **[" + dj.getName() + "]**" : "") .append("\n"); n++; } return sb.toString(); }
Example 5
Source File: LocalPlayerWrapper.java From kyoko with MIT License | 4 votes |
private boolean canChangeSpeed(AudioTrack track) { if (track == null) return false; if (track.getSourceManager() instanceof YoutubeAudioSourceManager && track.getDuration() == Long.MAX_VALUE) return false; return !(track.getSourceManager() instanceof TwitchStreamAudioSourceManager); }