Skip to content

Commit

Permalink
add new registerRemoteSources method with exclude arg
Browse files Browse the repository at this point in the history
  • Loading branch information
topi314 committed May 5, 2024
1 parent 3fdfd74 commit 2d70c63
Showing 1 changed file with 51 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import com.sedmelluq.discord.lavaplayer.source.vimeo.VimeoAudioSourceManager;
import com.sedmelluq.discord.lavaplayer.source.youtube.YoutubeAudioSourceManager;

import java.util.Set;

/**
* A helper class for registering built-in source managers to a player manager.
*/
Expand Down Expand Up @@ -50,6 +52,55 @@ public static void registerLocalSource(AudioPlayerManager playerManager) {
registerLocalSource(playerManager, MediaContainerRegistry.DEFAULT_REGISTRY);
}

/**
* Registers all built-in remote audio sources to the specified player manager, excluding the specified sources.
* Local file audio source must be registered separately.
*
* @param playerManager Player manager to register the source managers to
* @param excludedSources Source managers to exclude from registration
*/
@SafeVarargs
public static void registerRemoteSources(AudioPlayerManager playerManager, Class<? extends AudioSourceManager>... excludedSources) {
registerRemoteSources(playerManager, MediaContainerRegistry.DEFAULT_REGISTRY, excludedSources);
}

/**
* Registers all built-in remote audio sources to the specified player manager, excluding the specified sources.
* Local file audio source must be registered separately.
*
* @param playerManager Player manager to register the source managers to
* @param containerRegistry Media container registry to be used by any probing sources.
* @param excludedSources Source managers to exclude from registration
*/
@SafeVarargs
public static void registerRemoteSources(AudioPlayerManager playerManager, MediaContainerRegistry containerRegistry, Class<? extends AudioSourceManager>... excludedSources) {
Set<Class<? extends AudioSourceManager>> excluded = Set.of(excludedSources);
if (!excluded.contains(YoutubeAudioSourceManager.class)) {
playerManager.registerSourceManager(new YoutubeAudioSourceManager(true, null, null));
}
if (!excluded.contains(SoundCloudAudioSourceManager.class)) {
playerManager.registerSourceManager(SoundCloudAudioSourceManager.createDefault());
}
if (!excluded.contains(BandcampAudioSourceManager.class)) {
playerManager.registerSourceManager(new BandcampAudioSourceManager());
}
if (!excluded.contains(VimeoAudioSourceManager.class)) {
playerManager.registerSourceManager(new VimeoAudioSourceManager());
}
if (!excluded.contains(TwitchStreamAudioSourceManager.class)) {
playerManager.registerSourceManager(new TwitchStreamAudioSourceManager());
}
if (!excluded.contains(BeamAudioSourceManager.class)) {
playerManager.registerSourceManager(new BeamAudioSourceManager());
}
if (!excluded.contains(GetyarnAudioSourceManager.class)) {
playerManager.registerSourceManager(new GetyarnAudioSourceManager());
}
if (!excluded.contains(HttpAudioSourceManager.class)) {
playerManager.registerSourceManager(new HttpAudioSourceManager(containerRegistry));
}
}

/**
* Registers the local file source manager to the specified player manager.
*
Expand Down

0 comments on commit 2d70c63

Please sign in to comment.