Search in sources :

Example 71 with AudioTrack

use of com.sedmelluq.discord.lavaplayer.track.AudioTrack in project Ardent by adamint.

the class Queue method noArgs.

@Override
public void noArgs(Guild guild, MessageChannel channel, User user, Message message, String[] args) throws Exception {
    StringBuilder sb = new StringBuilder();
    String queuedBy = "queued by";
    sb.append("__Music Queue__\n");
    BlockingQueue<ArdentTrack> queue = getGuildAudioPlayer(guild, channel).scheduler.manager.getQueue();
    Iterator<ArdentTrack> iterator = queue.iterator();
    int current = 1;
    ArrayList<AudioTrack> trackList = new ArrayList<>();
    while (iterator.hasNext()) {
        ArdentTrack ardentTrack = iterator.next();
        AudioTrack track = ardentTrack.getTrack();
        trackList.add(track);
        sb.append("#" + current + ": " + track.getInfo().title + ": " + track.getInfo().author + " " + getDuration(track) + "\n     *" + queuedBy + " " + GuildUtils.getShard(guild).jda.getUserById(ardentTrack.getAuthor()).getName() + "*\n");
        current++;
    }
    if (current == 1) {
        sb.append("There aren't any songs in the queue!");
    }
    sendTranslatedMessage(sb.toString(), sendTo(channel, guild), user);
}
Also used : ArrayList(java.util.ArrayList) AudioTrack(com.sedmelluq.discord.lavaplayer.track.AudioTrack)

Example 72 with AudioTrack

use of com.sedmelluq.discord.lavaplayer.track.AudioTrack in project DiscordBot by LXGaming.

the class NowPlayingCommand method execute.

@Override
public void execute(TextChannel textChannel, Member member, Message message, List<String> arguments) {
    EmbedBuilder embedBuilder = new EmbedBuilder();
    embedBuilder.setAuthor(textChannel.getJDA().getSelfUser().getName(), null, textChannel.getJDA().getSelfUser().getEffectiveAvatarUrl());
    embedBuilder.setColor(DiscordUtil.DEFAULT);
    AudioTrack audioTrack = DiscordBot.getInstance().getDiscord().getAudioPlayer().getPlayingTrack();
    if (audioTrack == null) {
        embedBuilder.setTitle("Nothing is currently playing.", null);
        DiscordBot.getInstance().getDiscord().getMessageSender().sendMessage(textChannel, embedBuilder.build(), true);
        return;
    }
    embedBuilder.addField("Now playing", audioTrack.getInfo().title, false);
    embedBuilder.setFooter(DiscordUtil.getTimestamp(audioTrack.getPosition()) + " / " + DiscordUtil.getTimestamp(audioTrack.getDuration()), null);
    DiscordBot.getInstance().getDiscord().getMessageSender().sendMessage(textChannel, embedBuilder.build(), true);
}
Also used : EmbedBuilder(net.dv8tion.jda.core.EmbedBuilder) AudioTrack(com.sedmelluq.discord.lavaplayer.track.AudioTrack)

Example 73 with AudioTrack

use of com.sedmelluq.discord.lavaplayer.track.AudioTrack in project DiscordBot by LXGaming.

the class AudioPlayerLoadResultHandler method playlistLoaded.

@Override
public void playlistLoaded(AudioPlaylist audioPlaylist) {
    for (Iterator<AudioTrack> iterator = audioPlaylist.getTracks().iterator(); iterator.hasNext(); ) {
        AudioTrack audioTrack = iterator.next();
        if (audioTrack == null) {
            continue;
        }
        Audio audio = new Audio(getTextChannel(), getMember(), audioTrack);
        DiscordBot.getInstance().getDiscord().getAudioQueue().getQueue().add(audio);
        if (DiscordBot.getInstance().getDiscord().getAudioPlayer().getPlayingTrack() == null) {
            DiscordBot.getInstance().getDiscord().getAudioQueue().playNext();
        } else {
            LogHelper.debug("'" + audio.getAudioTrack().getInfo().title + "' Has been added to the queue.");
        }
        audio = null;
    }
    LogHelper.debug(audioPlaylist.getTracks().size() + " Songs have been added to the queue.");
    EmbedBuilder embedBuilder = new EmbedBuilder();
    embedBuilder.setAuthor(textChannel.getJDA().getSelfUser().getName(), null, textChannel.getJDA().getSelfUser().getEffectiveAvatarUrl());
    embedBuilder.setColor(DiscordUtil.SUCCESS);
    embedBuilder.setTitle(audioPlaylist.getTracks().size() + " Songs have been added to the queue.", null);
    DiscordBot.getInstance().getDiscord().getMessageSender().sendMessage(textChannel, embedBuilder.build(), true);
}
Also used : EmbedBuilder(net.dv8tion.jda.core.EmbedBuilder) AudioTrack(com.sedmelluq.discord.lavaplayer.track.AudioTrack) Audio(io.github.lxgaming.discordbot.entries.Audio)

Example 74 with AudioTrack

use of com.sedmelluq.discord.lavaplayer.track.AudioTrack in project legendarybot by greatman.

the class MusicManager method loadAndPlay.

/**
 * Load a song
 * @param channel The channel to send the alert in.
 * @param trackUrl The song URL
 * @param voiceChannel the voice channel to play the music in.
 */
public void loadAndPlay(final TextChannel channel, final String trackUrl, VoiceChannel voiceChannel) {
    GuildMusicManager musicManager = getGuildAudioPlayer(channel.getGuild());
    playerManager.loadItemOrdered(musicManager, trackUrl, new AudioLoadResultHandler() {

        @Override
        public void trackLoaded(AudioTrack track) {
            channel.sendMessage("Adding to queue " + track.getInfo().title).queue();
            play(channel.getGuild(), musicManager, track, voiceChannel);
        }

        @Override
        public void playlistLoaded(AudioPlaylist playlist) {
            AudioTrack firstTrack = playlist.getSelectedTrack();
            if (firstTrack == null) {
                firstTrack = playlist.getTracks().get(0);
            }
            channel.sendMessage("Adding to queue " + firstTrack.getInfo().title + " (first track of playlist " + playlist.getName() + ")").queue();
            play(channel.getGuild(), musicManager, firstTrack, voiceChannel);
        }

        @Override
        public void noMatches() {
            channel.sendMessage("Nothing found by " + trackUrl).queue();
        }

        @Override
        public void loadFailed(FriendlyException exception) {
            channel.sendMessage("Could not play: " + exception.getMessage()).queue();
        }
    });
}
Also used : AudioLoadResultHandler(com.sedmelluq.discord.lavaplayer.player.AudioLoadResultHandler) AudioTrack(com.sedmelluq.discord.lavaplayer.track.AudioTrack) AudioPlaylist(com.sedmelluq.discord.lavaplayer.track.AudioPlaylist) FriendlyException(com.sedmelluq.discord.lavaplayer.tools.FriendlyException)

Example 75 with AudioTrack

use of com.sedmelluq.discord.lavaplayer.track.AudioTrack in project Rubicon by Rubicon-Bot.

the class MusicManager method sendQueue.

public Message sendQueue() {
    if (!isBotInVoiceChannel())
        return message(error("Error!", "Bot is not in a voice channel."));
    EmbedBuilder builder = new EmbedBuilder();
    builder.setColor(Colors.COLOR_PRIMARY);
    builder.setTitle("Queue");
    StringBuilder content = new StringBuilder();
    for (AudioTrack track : getCurrentMusicManager().getScheduler().getQueue()) {
        content.append(":small_orange_diamond: [" + track.getInfo().title + "](" + track.getInfo().uri + ")\n");
    }
    builder.setDescription(content.toString());
    parsedCommandInvocation.getMessage().getTextChannel().sendMessage(builder.build()).queue();
    return null;
}
Also used : EmbedBuilder(net.dv8tion.jda.core.EmbedBuilder) AudioTrack(com.sedmelluq.discord.lavaplayer.track.AudioTrack)

Aggregations

AudioTrack (com.sedmelluq.discord.lavaplayer.track.AudioTrack)85 FriendlyException (com.sedmelluq.discord.lavaplayer.tools.FriendlyException)26 ArrayList (java.util.ArrayList)23 AudioPlaylist (com.sedmelluq.discord.lavaplayer.track.AudioPlaylist)21 AudioLoadResultHandler (com.sedmelluq.discord.lavaplayer.player.AudioLoadResultHandler)18 EmbedBuilder (net.dv8tion.jda.core.EmbedBuilder)17 AudioTrackInfo (com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo)11 List (java.util.List)10 JsonBrowser (com.sedmelluq.discord.lavaplayer.tools.JsonBrowser)9 IOException (java.io.IOException)9 BasicAudioPlaylist (com.sedmelluq.discord.lavaplayer.track.BasicAudioPlaylist)8 TimeUnit (java.util.concurrent.TimeUnit)7 GuildMessageReceivedEvent (net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent)7 YoutubeAudioSourceManager (com.sedmelluq.discord.lavaplayer.source.youtube.YoutubeAudioSourceManager)6 Optional (java.util.Optional)6 MessageBuilder (net.dv8tion.jda.core.MessageBuilder)6 Permission (net.dv8tion.jda.core.Permission)6 AudioPlayer (com.sedmelluq.discord.lavaplayer.player.AudioPlayer)5 InternalAudioTrack (com.sedmelluq.discord.lavaplayer.track.InternalAudioTrack)5 Slf4j (lombok.extern.slf4j.Slf4j)5