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


Java AudioPlaylist类代码示例

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


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

示例1: playlistLoaded

import com.sedmelluq.discord.lavaplayer.track.AudioPlaylist; //导入依赖的package包/类
@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);
}
 
开发者ID:LXGaming,项目名称:DiscordBot,代码行数:25,代码来源:AudioPlayerLoadResultHandler.java

示例2: checkSourcesForItemOnce

import com.sedmelluq.discord.lavaplayer.track.AudioPlaylist; //导入依赖的package包/类
private AudioItem checkSourcesForItemOnce(AudioReference reference, AudioLoadResultHandler resultHandler, boolean[] reported) {
  for (AudioSourceManager sourceManager : sourceManagers) {
    AudioItem item = sourceManager.loadItem(this, reference);

    if (item != null) {
      if (item instanceof AudioTrack) {
        log.debug("Loaded a track with identifier {} using {}.", reference.identifier, sourceManager.getClass().getSimpleName());
        reported[0] = true;
        resultHandler.trackLoaded((AudioTrack) item);
      } else if (item instanceof AudioPlaylist) {
        log.debug("Loaded a playlist with identifier {} using {}.", reference.identifier, sourceManager.getClass().getSimpleName());
        reported[0] = true;
        resultHandler.playlistLoaded((AudioPlaylist) item);
      }
      return item;
    }
  }

  return null;
}
 
开发者ID:sedmelluq,项目名称:lavaplayer,代码行数:21,代码来源:DefaultAudioPlayerManager.java

示例3: loadPlaylistWithId

import com.sedmelluq.discord.lavaplayer.track.AudioPlaylist; //导入依赖的package包/类
private AudioPlaylist loadPlaylistWithId(String playlistId, String selectedVideoId) {
  log.debug("Starting to load playlist with ID {}", playlistId);

  try (HttpInterface httpInterface = getHttpInterface()) {
    try (CloseableHttpResponse response = httpInterface.execute(new HttpGet("https://www.youtube.com/playlist?list=" + playlistId))) {
      int statusCode = response.getStatusLine().getStatusCode();
      if (statusCode != 200) {
        throw new IOException("Invalid status code for playlist response: " + statusCode);
      }

      Document document = Jsoup.parse(response.getEntity().getContent(), CHARSET, "");
      return buildPlaylist(httpInterface, document, selectedVideoId);
    }
  } catch (Exception e) {
    throw ExceptionTools.wrapUnfriendlyExceptions(e);
  }
}
 
开发者ID:sedmelluq,项目名称:lavaplayer,代码行数:18,代码来源:YoutubeAudioSourceManager.java

示例4: loadMixWithId

import com.sedmelluq.discord.lavaplayer.track.AudioPlaylist; //导入依赖的package包/类
/**
 * Loads tracks from mix in parallel into a playlist entry.
 *
 * @param mixId ID of the mix
 * @param selectedVideoId Selected track, {@link AudioPlaylist#getSelectedTrack()} will return this.
 * @return Playlist of the tracks in the mix.
 */
public AudioPlaylist loadMixWithId(String mixId, String selectedVideoId) {
  List<String> videoIds = new ArrayList<>();

  try (HttpInterface httpInterface = sourceManager.getHttpInterface()) {
    String mixUrl = "https://www.youtube.com/watch?v=" + selectedVideoId + "&list=" + mixId;

    try (CloseableHttpResponse response = httpInterface.execute(new HttpGet(mixUrl))) {
      int statusCode = response.getStatusLine().getStatusCode();
      if (statusCode != 200) {
        throw new IOException("Invalid status code for mix response: " + statusCode);
      }

      Document document = Jsoup.parse(response.getEntity().getContent(), StandardCharsets.UTF_8.name(), "");
      extractVideoIdsFromMix(document, videoIds);
    }
  } catch (IOException e) {
    throw new FriendlyException("Could not read mix page.", SUSPICIOUS, e);
  }

  if (videoIds.isEmpty()) {
    throw new FriendlyException("Could not find tracks from mix.", SUSPICIOUS, null);
  }

  return loadTracksAsynchronously(videoIds, selectedVideoId);
}
 
开发者ID:sedmelluq,项目名称:lavaplayer,代码行数:33,代码来源:YoutubeMixProvider.java

示例5: loadTracksAsynchronously

import com.sedmelluq.discord.lavaplayer.track.AudioPlaylist; //导入依赖的package包/类
private AudioPlaylist loadTracksAsynchronously(List<String> videoIds, String selectedVideoId) {
  ExecutorCompletionService<AudioItem> completion = new ExecutorCompletionService<>(mixLoadingExecutor);
  List<AudioTrack> tracks = new ArrayList<>();

  for (final String videoId : videoIds) {
    completion.submit(() -> sourceManager.loadTrackWithVideoId(videoId, true));
  }

  try {
    fetchTrackResultsFromExecutor(completion, tracks, videoIds.size());
  } catch (InterruptedException e) {
    Thread.currentThread().interrupt();
  }

  AudioTrack selectedTrack = sourceManager.findSelectedTrack(tracks, selectedVideoId);

  if (tracks.isEmpty()) {
    throw new FriendlyException("No tracks from the mix loaded succesfully.", SUSPICIOUS, null);
  } else if (selectedTrack == null) {
    throw new FriendlyException("The selected track of the mix failed to load.", SUSPICIOUS, null);
  }

  return new BasicAudioPlaylist("YouTube mix", tracks, selectedTrack, false);
}
 
开发者ID:sedmelluq,项目名称:lavaplayer,代码行数:25,代码来源:YoutubeMixProvider.java

示例6: loadTrack

import com.sedmelluq.discord.lavaplayer.track.AudioPlaylist; //导入依赖的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

示例7: loadTracks

import com.sedmelluq.discord.lavaplayer.track.AudioPlaylist; //导入依赖的package包/类
private void loadTracks(AudioTrack track, AudioPlaylist playlist) {
	if (VoiceSendHandler.isSongTooLong(track)) {
		message.editMessage(commandEvent.getClient().getWarning() + " The track was longer than the max length of " +
				QueuedAudioTrack.msToMinSec(VoiceSendHandler.MAX_DURATION * 1000)).queue();
		return;
	}
	// If the queue track was successfull go on, if not return.
	if (bot.queueTrack(track, commandEvent, message) && (playlist == null || !commandEvent.getSelfMember().hasPermission(commandEvent.getTextChannel(), Permission.MESSAGE_ADD_REACTION))) {
		message.editMessage(commandEvent.getClient().getSuccess() + " Successfully added track to queue.").queue();
	}
}
 
开发者ID:JessWalters,项目名称:Vinny-Redux,代码行数:12,代码来源:PlayCommand.java

示例8: playlistLoaded

import com.sedmelluq.discord.lavaplayer.track.AudioPlaylist; //导入依赖的package包/类
@Override
public void playlistLoaded(AudioPlaylist audioPlaylist) {
	if (audioPlaylist.isSearchResult() || audioPlaylist.getTracks().size() == 0) {
		loadTracks(audioPlaylist.getTracks().get(0), null);
	}
	else if (audioPlaylist.getSelectedTrack() != null) {
		loadTracks(audioPlaylist.getSelectedTrack(), null);
	}
	else {
		loadTracks(audioPlaylist.getTracks().get(0), null);
		// TODO: Playlists
	}
	}
 
开发者ID:JessWalters,项目名称:Vinny-Redux,代码行数:14,代码来源:PlayCommand.java

示例9: play

import com.sedmelluq.discord.lavaplayer.track.AudioPlaylist; //导入依赖的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

示例10: playlistLoaded

import com.sedmelluq.discord.lavaplayer.track.AudioPlaylist; //导入依赖的package包/类
@Override
public void playlistLoaded(AudioPlaylist audioPlaylist) {
    log.error("Loaded playlist instead of stream");
    synchronized (this) {
        this.notify();
    }
}
 
开发者ID:Frederikam,项目名称:GensokyoBot,代码行数:8,代码来源:StreamCombiner.java

示例11: loadAndPlay

import com.sedmelluq.discord.lavaplayer.track.AudioPlaylist; //导入依赖的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

示例12: loadAndPlay

import com.sedmelluq.discord.lavaplayer.track.AudioPlaylist; //导入依赖的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

示例13: addMusicOnly

import com.sedmelluq.discord.lavaplayer.track.AudioPlaylist; //导入依赖的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

示例14: sendPlaylistResponse

import com.sedmelluq.discord.lavaplayer.track.AudioPlaylist; //导入依赖的package包/类
private void sendPlaylistResponse(Message message, TrackResponse response) {
    AudioPlaylist playlist = (AudioPlaylist) response.getAudioItem();

    MessageFactory.makeSuccess(message,
        ":user has added :songs songs from the [:title](:url) playlist to the queue. There are `:queueSize` song(s) ahead of it in the queue."
    )
        .set("songs", playlist.getTracks().size())
        .set("title", playlist.getName())
        .set("url", response.getTrackUrl())
        .set("queueSize", AudioHandler.getQueueSize(response.getMusicManager()))
        .queue();
}
 
开发者ID:avaire,项目名称:avaire,代码行数:13,代码来源:PlayCommand.java

示例15: loadSong

import com.sedmelluq.discord.lavaplayer.track.AudioPlaylist; //导入依赖的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


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