Java Code Examples for com.sedmelluq.discord.lavaplayer.source.AudioSourceManager#loadItem()

The following examples show how to use com.sedmelluq.discord.lavaplayer.source.AudioSourceManager#loadItem() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultAudioPlayerManager.java    From lavaplayer with Apache License 2.0 6 votes vote down vote up
private AudioItem checkSourcesForItemOnce(AudioReference reference, AudioLoadResultHandler resultHandler, boolean[] reported) {
  for (AudioSourceManager sourceManager : sourceManagers) {
    if (reference.containerDescriptor != null && !(sourceManager instanceof ProbingAudioSourceManager)) {
      continue;
    }

    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;
}
 
Example 2
Source File: LocalMusicManager.java    From kyoko with MIT License 5 votes vote down vote up
@Override
public AudioItem resolve(Guild guild, String query) {
    AudioItem item;
    for (AudioSourceManager manager : sourceManagers) {
        item = manager.loadItem(null, new AudioReference(query, null));
        if (item != null) {
            logger.debug("Loaded item [{}] via {}.", item, manager);
            return item;
        }
    }
    return null;
}
 
Example 3
Source File: UserContextAudioPlayerManager.java    From SkyBot with GNU Affero General Public License v3.0 5 votes vote down vote up
private AudioItem checkSourcesForItemOnce(AudioReference reference, AudioLoadResultHandler resultHandler, boolean[] reported, boolean isPatron) {
    for (final AudioSourceManager sourceManager : sourceManagers.get()) {
        if (reference.containerDescriptor != null && !(sourceManager instanceof ProbingAudioSourceManager)) {
            continue;
        }

        final AudioItem item;

        if (sourceManager instanceof SpotifyAudioSourceManager) {
            item = ((SpotifyAudioSourceManager) sourceManager).loadItem(reference, isPatron);
        } else {
            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;
}