use of net.robinfriedli.aiode.audio.UrlPlayable in project aiode by robinfriedli.
the class AbstractPlayableLoadingCommand method loadSoundCloudTrack.
private void loadSoundCloudTrack(AudioManager audioManager) {
AudioTrackLoader audioTrackLoader = new AudioTrackLoader(audioManager.getPlayerManager());
String commandInput = getCommandInput();
AudioItem audioItem = audioTrackLoader.loadByIdentifier("scsearch:" + commandInput);
if (audioItem instanceof AudioTrack) {
AudioTrack audioTrack = (AudioTrack) audioItem;
handleResults(Lists.newArrayList(new UrlPlayable(audioTrack)));
this.loadedAudioTrack = audioTrack;
} else if (audioItem == null) {
throw new NoResultsFoundException(String.format("No soundcloud track found for '%s'", commandInput));
} else if (audioItem instanceof AudioPlaylist) {
int limit = getArgumentValueWithTypeOrElse("select", Integer.class, 20);
List<AudioTrack> tracks = ((AudioPlaylist) audioItem).getTracks();
if (tracks.isEmpty()) {
throw new NoResultsFoundException(String.format("No soundcloud track found for '%s'", commandInput));
}
if (tracks.size() > limit) {
tracks = tracks.subList(0, limit);
}
askQuestion(tracks, audioTrack -> audioTrack.getInfo().title, audioTrack -> audioTrack.getInfo().author);
}
}
Aggregations