当前位置: 首页>>代码示例>>Java>>正文


Java AudioLoadResultHandler类代码示例

本文整理汇总了Java中com.sedmelluq.discord.lavaplayer.player.AudioLoadResultHandler的典型用法代码示例。如果您正苦于以下问题:Java AudioLoadResultHandler类的具体用法?Java AudioLoadResultHandler怎么用?Java AudioLoadResultHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


AudioLoadResultHandler类属于com.sedmelluq.discord.lavaplayer.player包,在下文中一共展示了AudioLoadResultHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: loadTrack

import com.sedmelluq.discord.lavaplayer.player.AudioLoadResultHandler; //导入依赖的package包/类
private void loadTrack(String identifier, Member author, Message msg) {


        Guild guild = author.getGuild();
        getPlayer(guild);

        msg.getTextChannel().sendTyping().queue();
        myManager.setFrameBufferDuration(5000);
        myManager.loadItemOrdered(guild, identifier, new AudioLoadResultHandler() {

            @Override
            public void trackLoaded(AudioTrack track) {

                getTrackManager(guild).queue(track, author);
            }

            @Override
            public void playlistLoaded(AudioPlaylist playlist) {
                if (playlist.getSelectedTrack() != null) {
                    trackLoaded(playlist.getSelectedTrack());
                } else if (playlist.isSearchResult()) {
                    trackLoaded(playlist.getTracks().get(0));
                } else {

                    for (int i = 0; i < Math.min(playlist.getTracks().size(), PLAYLIST_LIMIT); i++) {
                        getTrackManager(guild).queue(playlist.getTracks().get(i), author);
                    }
                }
            }

            @Override
            public void noMatches() {
            }

            @Override
            public void loadFailed(FriendlyException exception) {
            }
        });
    }
 
开发者ID:LeeDJD,项目名称:Amme,代码行数:40,代码来源:Music.java

示例2: play

import com.sedmelluq.discord.lavaplayer.player.AudioLoadResultHandler; //导入依赖的package包/类
public void play(String fileName, Runnable action)
{
	this.action = action;
	
	playerManager.loadItem(fileName, new AudioLoadResultHandler()
	{

		@Override
		public void trackLoaded(AudioTrack track) 
		{
			log.info("Attempting to play the requested sound.");
			player.playTrack(track);
		}

		@Override
		public void playlistLoaded(AudioPlaylist playlist) 
		{
			
		}

		@Override
		public void noMatches() 
		{
			if (action != null)
				action.run();
		}

		@Override
		public void loadFailed(FriendlyException exception) 
		{
			
		}			
	});
}
 
开发者ID:SegfaultError11,项目名称:WeenieBot,代码行数:35,代码来源:SoundPlayer.java

示例3: loadAndPlay

import com.sedmelluq.discord.lavaplayer.player.AudioLoadResultHandler; //导入依赖的package包/类
private static void loadAndPlay(final IChannel channel, final String trackUrl) {
    GuildMusicManager musicManager = getGuildAudioPlayer(channel.getGuild());

    playerManager.loadItemOrdered(musicManager, trackUrl, new AudioLoadResultHandler() {
        @Override
        public void trackLoaded(AudioTrack track) {
            BotUtils.sendEmbMessage(channel, SMB.shortMessage(String.format(LANG.getTranslation("music_add"), track.getInfo().title)), true);

            play(musicManager, track);
        }

        @Override
        public void playlistLoaded(AudioPlaylist playlist) {
            AudioTrack firstTrack = playlist.getSelectedTrack();

            if (firstTrack == null) {
                firstTrack = playlist.getTracks().get(0);
            }

            BotUtils.sendEmbMessage(channel, SMB.shortMessage(String.format(LANG.getTranslation("music_add_queue"), firstTrack.getInfo().title, playlist.getName())), true);

            play(musicManager, firstTrack);
        }

        @Override
        public void noMatches() {
            BotUtils.sendEmbMessage(channel, SMB.shortMessage(String.format(LANG.getTranslation("music_notfound"), trackUrl)), true);
        }

        @Override
        public void loadFailed(FriendlyException exception) {
            BotUtils.sendEmbMessage(channel, SMB.shortMessage(LANG.getTranslation("music_notloaded") + exception.getMessage()), true);
        }
    });
}
 
开发者ID:ModdyLP,项目名称:MoMuOSB,代码行数:36,代码来源:MainMusic.java

示例4: loadAndPlay

import com.sedmelluq.discord.lavaplayer.player.AudioLoadResultHandler; //导入依赖的package包/类
/**
 * 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();
        }
    });
}
 
开发者ID:greatman,项目名称:legendarybot,代码行数:42,代码来源:MusicManager.java

示例5: addMusicOnly

import com.sedmelluq.discord.lavaplayer.player.AudioLoadResultHandler; //导入依赖的package包/类
/**
 * Add a song to the queue of a guild
 * @param guild The guild to add the song in
 * @param channel The channel to send the alert in.
 * @param url The URL of the song.
 */
public void addMusicOnly(Guild guild, MessageChannel channel, String url) {
    getPlayerManager().loadItemOrdered(getPlayerManager(), url, new AudioLoadResultHandler() {
        @Override
        public void trackLoaded(AudioTrack track) {
            channel.sendMessage("Adding to queue " + track.getInfo().title).queue();
            getGuildAudioPlayer(guild).scheduler.queue(track);
        }

        @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();
            getGuildAudioPlayer(guild).scheduler.queue(firstTrack);
        }

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

        @Override
        public void loadFailed(FriendlyException exception) {
            channel.sendMessage("Could not play: " + exception.getMessage()).queue();
        }
    });
}
 
开发者ID:greatman,项目名称:legendarybot,代码行数:38,代码来源:MusicManager.java

示例6: loadSong

import com.sedmelluq.discord.lavaplayer.player.AudioLoadResultHandler; //导入依赖的package包/类
private void loadSong(Message message, PlaylistTransformer.PlaylistSong song) {
    Metrics.searchRequests.inc();

    AudioHandler.AUDIO_PLAYER_MANAGER.loadItemOrdered(AudioHandler.MUSIC_MANAGER, song.getLink(), new AudioLoadResultHandler() {
        @Override
        public void trackLoaded(AudioTrack track) {
            Metrics.tracksLoaded.inc();

            AudioHandler.getGuildAudioPlayer(message.getGuild())
                .getScheduler().queue(track, message.getAuthor());
        }

        @Override
        public void playlistLoaded(AudioPlaylist playlist) {
            trackLoaded(playlist.getTracks().get(0));
        }

        @Override
        public void noMatches() {
            Metrics.trackLoadsFailed.inc();
        }

        @Override
        public void loadFailed(FriendlyException exception) {
            Metrics.trackLoadsFailed.inc();
        }
    });
}
 
开发者ID:avaire,项目名称:avaire,代码行数:29,代码来源:LoadPlaylist.java

示例7: loadAndPlay

import com.sedmelluq.discord.lavaplayer.player.AudioLoadResultHandler; //导入依赖的package包/类
private void loadAndPlay(final IChannel channel, final String trackUrl) {
  GuildMusicManager musicManager = getGuildAudioPlayer(channel.getGuild());

  playerManager.loadItemOrdered(musicManager, trackUrl, new AudioLoadResultHandler() {
    @Override
    public void trackLoaded(AudioTrack track) {
      sendMessageToChannel(channel, "Adding to queue " + track.getInfo().title);

      play(channel.getGuild(), musicManager, track);
    }

    @Override
    public void playlistLoaded(AudioPlaylist playlist) {
      AudioTrack firstTrack = playlist.getSelectedTrack();

      if (firstTrack == null) {
        firstTrack = playlist.getTracks().get(0);
      }

      sendMessageToChannel(channel, "Adding to queue " + firstTrack.getInfo().title + " (first track of playlist " + playlist.getName() + ")");

      play(channel.getGuild(), musicManager, firstTrack);
    }

    @Override
    public void noMatches() {
      sendMessageToChannel(channel, "Nothing found by " + trackUrl);
    }

    @Override
    public void loadFailed(FriendlyException exception) {
      sendMessageToChannel(channel, "Could not play: " + exception.getMessage());
    }
  });
}
 
开发者ID:sedmelluq,项目名称:lavaplayer,代码行数:36,代码来源:Main.java

示例8: loadAndPlay

import com.sedmelluq.discord.lavaplayer.player.AudioLoadResultHandler; //导入依赖的package包/类
private void loadAndPlay(final TextChannel channel, final String trackUrl) {
  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);
    }

    @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);
    }

    @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();
    }
  });
}
 
开发者ID:sedmelluq,项目名称:lavaplayer,代码行数:36,代码来源:Main.java

示例9: loadAndMeme

import com.sedmelluq.discord.lavaplayer.player.AudioLoadResultHandler; //导入依赖的package包/类
public void loadAndMeme(final CommandContext context, final String trackUrl) {
    GuildMusicManager musicManager = getGuildAudioPlayer(context, true);
    if (musicManager.isMeme()) {
        playerManager.loadItemOrdered(musicManager, trackUrl, new AudioLoadResultHandler() {
            @Override
            public void trackLoaded(AudioTrack track) {
                playMeme(context, musicManager, track);
            }

            @Override
            public void playlistLoaded(AudioPlaylist playlist) {
                AudioTrack firstTrack = playlist.getSelectedTrack();
                if (firstTrack == null) {
                    firstTrack = playlist.getTracks().get(0);
                }
                playMeme(context, musicManager, firstTrack);
            }

            @Override
            public void noMatches() {
            }

            @Override
            public void loadFailed(FriendlyException exception) {
            }
        });
    } else {
        context.getTextChannel().sendMessage("I can't meme while music's playing...").queue();
    }
}
 
开发者ID:Godson777,项目名称:KekBot,代码行数:31,代码来源:MusicPlayer.java

示例10: loadAndPlay

import com.sedmelluq.discord.lavaplayer.player.AudioLoadResultHandler; //导入依赖的package包/类
private void loadAndPlay(final TextChannel channel, final String trackUrl) {
	final GuildMusicManager musicManager = getGuildAudioPlayer(channel.getGuild());

	playerManager.loadItemOrdered(musicManager, trackUrl, new AudioLoadResultHandler() {
		public void trackLoaded(AudioTrack track) {
			channel.sendMessage("Adding to queue " + track.getInfo().title).queue();

			play(channel.getGuild(), musicManager, track, channel, channel.getGuild().getAudioManager());
		}

		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, channel, channel.getGuild().getAudioManager());
		}

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

		public void loadFailed(FriendlyException exception) {
			channel.sendMessage("Could not play: " + exception.getMessage()).queue();
		}
	});
}
 
开发者ID:JoeZwet,项目名称:ncsBot,代码行数:33,代码来源:AudioCommandHandler.java

示例11: loadTrack

import com.sedmelluq.discord.lavaplayer.player.AudioLoadResultHandler; //导入依赖的package包/类
private final MusicCommand loadTrack(String identifier, MessageEvent event, VoiceChannel channel, int max_tracks) {
    if (event == null) {
        return this;
    }
    final Member author = event.getMember();
    if (author == null) {
        return this;
    }
    final Guild guild = author.getGuild();
    if (guild == null) {
        return this;
    }
    final TrackManager trackManager = getTrackManager(guild, channel);
    if (trackManager == null) {
        return null;
    }
    manager.setFrameBufferDuration(Config.CONFIG.getBotMusicFrameBufferDuration());
    manager.loadItemOrdered(guild, identifier, new AudioLoadResultHandler() {
        @Override
        public void trackLoaded(AudioTrack track) {
            try {
                trackManager.queue(track, author);
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        }

        @Override
        public void playlistLoaded(AudioPlaylist playlist) {
            if (playlist == null || max_tracks == 0) {
                return;
            }
            final List<AudioTrack> tracks = playlist.getTracks();
            if (tracks == null || tracks.isEmpty()) {
                return;
            }
            final int max = Math.min(tracks.size(), Standard.PLAYLIST_LIMIT);
            for (int i = 0; i < max; i++) {
                if (max_tracks != -1) {
                    if (i >= max_tracks) {
                        return;
                    }
                }
                trackManager.queue(tracks.get(i), author);
            }
        }

        @Override
        public void noMatches() {
        }

        @Override
        public void loadFailed(FriendlyException exception) {
        }
    });
    return this;
}
 
开发者ID:Panzer1119,项目名称:Supreme-Bot,代码行数:58,代码来源:MusicCommand.java

示例12: loadAndPlay

import com.sedmelluq.discord.lavaplayer.player.AudioLoadResultHandler; //导入依赖的package包/类
private void loadAndPlay(GuildMusicManager mng, final MessageChannel channel, String url, final boolean addPlaylist)
{
    final String trackUrl;

    //Strip <>'s that prevent discord from embedding link resources
    if (url.startsWith("<") && url.endsWith(">"))
        trackUrl = url.substring(1, url.length() - 1);
    else
        trackUrl = url;

    playerManager.loadItemOrdered(mng, trackUrl, new AudioLoadResultHandler()
    {
        @Override
        public void trackLoaded(AudioTrack track)
        {
            String msg = "Adding to queue: " + track.getInfo().title;
            if (mng.player.getPlayingTrack() == null)
                msg += "\nand the Player has started playing;";

            mng.scheduler.queue(track);
            channel.sendMessage(msg).queue();
        }

        @Override
        public void playlistLoaded(AudioPlaylist playlist)
        {
            AudioTrack firstTrack = playlist.getSelectedTrack();
            List<AudioTrack> tracks = playlist.getTracks();


            if (firstTrack == null) {
                firstTrack = playlist.getTracks().get(0);
            }

            if (addPlaylist)
            {
                channel.sendMessage("Adding **" + playlist.getTracks().size() +"** tracks to queue from playlist: " + playlist.getName()).queue();
                tracks.forEach(mng.scheduler::queue);
            }
            else
            {
                channel.sendMessage("Adding to queue " + firstTrack.getInfo().title + " (first track of playlist " + playlist.getName() + ")").queue();
                mng.scheduler.queue(firstTrack);
            }
        }

        @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();
        }
    });
}
 
开发者ID:ExidCuter,项目名称:JDodoBot,代码行数:60,代码来源:PlayerControl.java

示例13: ytsearch

import com.sedmelluq.discord.lavaplayer.player.AudioLoadResultHandler; //导入依赖的package包/类
@Command(
        name = "ytsearch",
        description = "Search youtube for videos",
        usage = "`>>ytsearch <name of the video>`",
        permission = CommandPermission.USER,
        category = CommandCategory.UTIL
)
public static void ytsearch(@Argument("member") Member member, @Argument("channel") TextChannel channel, @Argument("input") String input) {
    GabrielBot.getInstance().playerManager.loadItem("ytsearch: " + input, new AudioLoadResultHandler() {
        @Override
        public void trackLoaded(AudioTrack track) {

        }

        @Override
        public void playlistLoaded(AudioPlaylist playlist) {
            EmbedBuilder eb = new EmbedBuilder().setTitle("Search results").setColor(member.getColor()).setThumbnail("https://www.seeklogo.net/wp-content/uploads/2016/11/youtube-logo-preview-1.png");
            List<AudioTrack> list = playlist.getTracks();
            for(int i = 0; i < Math.min(5, list.size()); i++) {
                AudioTrackInfo info = list.get(i).getInfo();
                eb.appendDescription(String.format("%d - **[%s](%s)** - Uploaded by %s `(%s)`%n%n",
                        i+1,
                        info.title.replace("]", "\\]"),
                        info.uri,
                        info.author,
                        Utils.getDuration(info.length)
                ));
            }
            channel.sendMessage(eb.build()).queue();
        }

        @Override
        public void noMatches() {
            channel.sendMessage("No video found").queue();
        }

        @Override
        public void loadFailed(FriendlyException exception) {

        }
    });
}
 
开发者ID:natanbc,项目名称:GabrielBot,代码行数:43,代码来源:UtilCommands.java

示例14: loadTrack

import com.sedmelluq.discord.lavaplayer.player.AudioLoadResultHandler; //导入依赖的package包/类
private void loadTrack(String identifier, Member author, Message msg, Command.MessageSender chat) {
    if (author.getVoiceState().getChannel() == null) {
        chat.sendMessage("You are not in a Voice Channel!");
        return;
    }

    Guild guild = author.getGuild();
    getPlayer(guild); // Make sure this guild has a player.

    msg.getTextChannel().sendTyping().queue();
    myManager.loadItemOrdered(guild, identifier, new AudioLoadResultHandler() {

        @Override
        public void trackLoaded(AudioTrack track) {
            chat.sendEmbed(String.format(QUEUE_TITLE, MessageUtil.userDiscrimSet(author.getUser()), 1, ""),
                    String.format(QUEUE_DESCRIPTION, CD, getOrNull(track.getInfo().title), "", MIC, getOrNull(track.getInfo().author), ""));
            getTrackManager(guild).queue(track, author);
        }

        @Override
        public void playlistLoaded(AudioPlaylist playlist) {
            if (playlist.getSelectedTrack() != null) {
                trackLoaded(playlist.getSelectedTrack());
            } else if (playlist.isSearchResult()) {
                trackLoaded(playlist.getTracks().get(0));
            } else {
                chat.sendEmbed(String.format(QUEUE_TITLE, MessageUtil.userDiscrimSet(author.getUser()), Math.min(playlist.getTracks().size(), PLAYLIST_LIMIT), "s"),
                        String.format(QUEUE_DESCRIPTION, DVD, getOrNull(playlist.getName()), "", "", "", ""));
                for (int i = 0; i < Math.min(playlist.getTracks().size(), PLAYLIST_LIMIT); i++) {
                    getTrackManager(guild).queue(playlist.getTracks().get(i), author);
                }
            }
        }

        @Override
        public void noMatches() {
            chat.sendEmbed(String.format(ERROR, identifier), "\u26A0 No playable tracks were found.");
        }

        @Override
        public void loadFailed(FriendlyException exception) {
            chat.sendEmbed(String.format(ERROR, identifier), "\u26D4 " + exception.getLocalizedMessage());
        }
    });
    tryToDelete(msg);
}
 
开发者ID:DinosParkour,项目名称:deeJay,代码行数:47,代码来源:MusicCommand.java

示例15: addTrack

import com.sedmelluq.discord.lavaplayer.player.AudioLoadResultHandler; //导入依赖的package包/类
private void addTrack(final Message message, final String identifier, final boolean now) {
  outputChannel.set((TextChannel) message.getChannel());

  manager.loadItemOrdered(this, identifier, new AudioLoadResultHandler() {
    @Override
    public void trackLoaded(AudioTrack track) {
      connectToFirstVoiceChannel(guild.getAudioManager());

      message.getChannel().sendMessage("Starting now: " + track.getInfo().title + " (length " + track.getDuration() + ")").queue();

      if (now) {
        scheduler.playNow(track, true);
      } else {
        scheduler.addToQueue(track);
      }
    }

    @Override
    public void playlistLoaded(AudioPlaylist playlist) {
      List<AudioTrack> tracks = playlist.getTracks();
      message.getChannel().sendMessage("Loaded playlist: " + playlist.getName() + " (" + tracks.size() + ")").queue();

      connectToFirstVoiceChannel(guild.getAudioManager());

      AudioTrack selected = playlist.getSelectedTrack();

      if (selected != null) {
        message.getChannel().sendMessage("Selected track from playlist: " + selected.getInfo().title).queue();
      } else {
        selected = tracks.get(0);
        message.getChannel().sendMessage("Added first track from playlist: " + selected.getInfo().title).queue();
      }

      if (now) {
        scheduler.playNow(selected, true);
      } else {
        scheduler.addToQueue(selected);
      }

      for (int i = 0; i < Math.min(10, playlist.getTracks().size()); i++) {
        if (tracks.get(i) != selected) {
          scheduler.addToQueue(tracks.get(i));
        }
      }
    }

    @Override
    public void noMatches() {
      message.getChannel().sendMessage("Nothing found for " + identifier).queue();
    }

    @Override
    public void loadFailed(FriendlyException throwable) {
      message.getChannel().sendMessage("Failed with message: " + throwable.getMessage() + " (" + throwable.getClass().getSimpleName() + ")").queue();
    }
  });
}
 
开发者ID:sedmelluq,项目名称:lavaplayer,代码行数:58,代码来源:MusicController.java


注:本文中的com.sedmelluq.discord.lavaplayer.player.AudioLoadResultHandler类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。