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