com.sedmelluq.discord.lavaplayer.source.AudioSourceManager Java Examples

The following examples show how to use com.sedmelluq.discord.lavaplayer.source.AudioSourceManager. 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: DefaultAudioPlayerManager.java    From lavaplayer with Apache License 2.0 6 votes vote down vote up
private AudioTrackExecutor createExecutorForTrack(InternalAudioTrack track, AudioConfiguration configuration,
                                                  AudioPlayerOptions playerOptions) {

  AudioSourceManager sourceManager = track.getSourceManager();

  if (remoteNodeManager.isEnabled() && sourceManager != null && sourceManager.isTrackEncodable(track)) {
    return new RemoteAudioTrackExecutor(track, configuration, remoteNodeManager, playerOptions.volumeLevel);
  } else {
    AudioTrackExecutor customExecutor = track.createLocalExecutor(this);

    if (customExecutor != null) {
      return customExecutor;
    } else {
      int bufferDuration = Optional.ofNullable(playerOptions.frameBufferDuration.get()).orElse(frameBufferDuration);
      return new LocalAudioTrackExecutor(track, configuration, playerOptions, useSeekGhosting, bufferDuration);
    }
  }
}
 
Example #3
Source File: DefaultAudioPlayerManager.java    From lavaplayer with Apache License 2.0 6 votes vote down vote up
@Override
public void registerSourceManager(AudioSourceManager sourceManager) {
  sourceManagers.add(sourceManager);

  if (sourceManager instanceof HttpConfigurable) {
    Function<RequestConfig, RequestConfig> configurator = httpConfigurator;

    if (configurator != null) {
      ((HttpConfigurable) sourceManager).configureRequests(configurator);
    }

    Consumer<HttpClientBuilder> builderConfigurator = httpBuilderConfigurator;

    if (builderConfigurator != null) {
      ((HttpConfigurable) sourceManager).configureBuilder(builderConfigurator);
    }
  }
}
 
Example #4
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 #5
Source File: DefaultAudioPlayerManager.java    From lavaplayer with Apache License 2.0 5 votes vote down vote up
@Override
public void setHttpBuilderConfigurator(Consumer<HttpClientBuilder> configurator) {
  this.httpBuilderConfigurator = configurator;

  if (configurator != null) {
    for (AudioSourceManager sourceManager : sourceManagers) {
      if (sourceManager instanceof HttpConfigurable) {
        ((HttpConfigurable) sourceManager).configureBuilder(configurator);
      }
    }
  }
}
 
Example #6
Source File: DefaultAudioPlayerManager.java    From lavaplayer with Apache License 2.0 5 votes vote down vote up
@Override
public void setHttpRequestConfigurator(Function<RequestConfig, RequestConfig> configurator) {
  this.httpConfigurator = configurator;

  if (configurator != null) {
    for (AudioSourceManager sourceManager : sourceManagers) {
      if (sourceManager instanceof HttpConfigurable) {
        ((HttpConfigurable) sourceManager).configureRequests(configurator);
      }
    }
  }
}
 
Example #7
Source File: DefaultAudioPlayerManager.java    From lavaplayer with Apache License 2.0 5 votes vote down vote up
private AudioTrack decodeTrackDetails(AudioTrackInfo trackInfo, DataInput input) throws IOException {
  String sourceName = input.readUTF();

  for (AudioSourceManager sourceManager : sourceManagers) {
    if (sourceName.equals(sourceManager.getSourceName())) {
      return sourceManager.decodeTrack(trackInfo, input);
    }
  }

  return null;
}
 
Example #8
Source File: DefaultAudioPlayerManager.java    From lavaplayer with Apache License 2.0 5 votes vote down vote up
@Override
public <T extends AudioSourceManager> T source(Class<T> klass) {
  for (AudioSourceManager sourceManager : sourceManagers) {
    if (klass.isAssignableFrom(sourceManager.getClass())) {
      return (T) sourceManager;
    }
  }

  return null;
}
 
Example #9
Source File: DefaultAudioPlayerManager.java    From lavaplayer with Apache License 2.0 5 votes vote down vote up
@Override
public void shutdown() {
  remoteNodeManager.shutdown(true);
  garbageCollectionMonitor.disable();
  lifecycleManager.shutdown();

  for (AudioSourceManager sourceManager : sourceManagers) {
    sourceManager.shutdown();
  }

  ExecutorTools.shutdownExecutor(trackPlaybackExecutorService, "track playback");
  ExecutorTools.shutdownExecutor(trackInfoExecutorService, "track info");
  ExecutorTools.shutdownExecutor(scheduledExecutorService, "scheduled operations");
}
 
Example #10
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;
}
 
Example #11
Source File: SavedPlaylistExtractor.java    From FlareBot with MIT License 4 votes vote down vote up
@Override
public Class<? extends AudioSourceManager> getSourceManagerClass() {
    return YoutubeAudioSourceManager.class;
}
 
Example #12
Source File: YoutubeAudioTrack.java    From lavaplayer with Apache License 2.0 4 votes vote down vote up
@Override
public AudioSourceManager getSourceManager() {
  return sourceManager;
}
 
Example #13
Source File: SoundCloudAudioTrack.java    From lavaplayer with Apache License 2.0 4 votes vote down vote up
@Override
public AudioSourceManager getSourceManager() {
  return sourceManager;
}
 
Example #14
Source File: BeamAudioTrack.java    From lavaplayer with Apache License 2.0 4 votes vote down vote up
@Override
public AudioSourceManager getSourceManager() {
  return sourceManager;
}
 
Example #15
Source File: HttpAudioTrack.java    From lavaplayer with Apache License 2.0 4 votes vote down vote up
@Override
public AudioSourceManager getSourceManager() {
  return sourceManager;
}
 
Example #16
Source File: VimeoAudioTrack.java    From lavaplayer with Apache License 2.0 4 votes vote down vote up
@Override
public AudioSourceManager getSourceManager() {
  return sourceManager;
}
 
Example #17
Source File: NicoAudioTrack.java    From lavaplayer with Apache License 2.0 4 votes vote down vote up
@Override
public AudioSourceManager getSourceManager() {
  return sourceManager;
}
 
Example #18
Source File: BandcampAudioTrack.java    From lavaplayer with Apache License 2.0 4 votes vote down vote up
@Override
public AudioSourceManager getSourceManager() {
  return sourceManager;
}
 
Example #19
Source File: TwitchStreamAudioTrack.java    From lavaplayer with Apache License 2.0 4 votes vote down vote up
@Override
public AudioSourceManager getSourceManager() {
  return sourceManager;
}
 
Example #20
Source File: LocalAudioTrack.java    From lavaplayer with Apache License 2.0 4 votes vote down vote up
@Override
public AudioSourceManager getSourceManager() {
  return sourceManager;
}
 
Example #21
Source File: BaseAudioTrack.java    From lavaplayer with Apache License 2.0 4 votes vote down vote up
@Override
public AudioSourceManager getSourceManager() {
  return null;
}
 
Example #22
Source File: LocalMusicManager.java    From kyoko with MIT License 4 votes vote down vote up
@Override
public void registerSourceManager(AudioSourceManager manager) {
    if (manager != null)
        sourceManagers.add(manager);
}
 
Example #23
Source File: NicoAudioTrack.java    From kyoko with MIT License 4 votes vote down vote up
@Override
public AudioSourceManager getSourceManager() {
    return sourceManager;
}
 
Example #24
Source File: YouTubeExtractor.java    From FlareBot with MIT License 4 votes vote down vote up
@Override
public Class<? extends AudioSourceManager> getSourceManagerClass() {
    return YoutubeAudioSourceManager.class;
}
 
Example #25
Source File: YouTubeExtractor.java    From FlareBot with MIT License 4 votes vote down vote up
@Override
public AudioSourceManager newSourceManagerInstance() throws Exception {
    YoutubeAudioSourceManager manager = new YoutubeAudioSourceManager();
    manager.setPlaylistPageCount(100);
    return manager;
}
 
Example #26
Source File: DefaultAudioPlayerManager.java    From lavaplayer with Apache License 2.0 4 votes vote down vote up
private void encodeTrackDetails(AudioTrack track, DataOutput output) throws IOException {
  AudioSourceManager sourceManager = track.getSourceManager();
  output.writeUTF(sourceManager.getSourceName());
  sourceManager.encodeTrack(track, output);
}
 
Example #27
Source File: Extractor.java    From FlareBot with MIT License 4 votes vote down vote up
default AudioSourceManager newSourceManagerInstance() throws Exception {
    return getSourceManagerClass().newInstance();
}
 
Example #28
Source File: YouTubeSearchExtractor.java    From FlareBot with MIT License 4 votes vote down vote up
@Override
public AudioSourceManager newSourceManagerInstance() throws Exception {
    YoutubeAudioSourceManager manager = new YoutubeAudioSourceManager();
    manager.setPlaylistPageCount(100);
    return manager;
}
 
Example #29
Source File: RandomExtractor.java    From FlareBot with MIT License 4 votes vote down vote up
@Override
public Class<? extends AudioSourceManager> getSourceManagerClass() {
    return YoutubeAudioSourceManager.class;
}
 
Example #30
Source File: SavedPlaylistExtractor.java    From FlareBot with MIT License 4 votes vote down vote up
@Override
public AudioSourceManager newSourceManagerInstance() throws Exception {
    YoutubeAudioSourceManager manager = new YoutubeAudioSourceManager();
    manager.setPlaylistPageCount(100);
    return manager;
}