|
12 | 12 | import com.sedmelluq.discord.lavaplayer.source.vimeo.VimeoAudioSourceManager;
|
13 | 13 | import com.sedmelluq.discord.lavaplayer.source.youtube.YoutubeAudioSourceManager;
|
14 | 14 |
|
| 15 | +import java.util.Set; |
| 16 | + |
15 | 17 | /**
|
16 | 18 | * A helper class for registering built-in source managers to a player manager.
|
17 | 19 | */
|
@@ -50,6 +52,55 @@ public static void registerLocalSource(AudioPlayerManager playerManager) {
|
50 | 52 | registerLocalSource(playerManager, MediaContainerRegistry.DEFAULT_REGISTRY);
|
51 | 53 | }
|
52 | 54 |
|
| 55 | + /** |
| 56 | + * Registers all built-in remote audio sources to the specified player manager, excluding the specified sources. |
| 57 | + * Local file audio source must be registered separately. |
| 58 | + * |
| 59 | + * @param playerManager Player manager to register the source managers to |
| 60 | + * @param excludedSources Source managers to exclude from registration |
| 61 | + */ |
| 62 | + @SafeVarargs |
| 63 | + public static void registerRemoteSources(AudioPlayerManager playerManager, Class<? extends AudioSourceManager>... excludedSources) { |
| 64 | + registerRemoteSources(playerManager, MediaContainerRegistry.DEFAULT_REGISTRY, excludedSources); |
| 65 | + } |
| 66 | + |
| 67 | + /** |
| 68 | + * Registers all built-in remote audio sources to the specified player manager, excluding the specified sources. |
| 69 | + * Local file audio source must be registered separately. |
| 70 | + * |
| 71 | + * @param playerManager Player manager to register the source managers to |
| 72 | + * @param containerRegistry Media container registry to be used by any probing sources. |
| 73 | + * @param excludedSources Source managers to exclude from registration |
| 74 | + */ |
| 75 | + @SafeVarargs |
| 76 | + public static void registerRemoteSources(AudioPlayerManager playerManager, MediaContainerRegistry containerRegistry, Class<? extends AudioSourceManager>... excludedSources) { |
| 77 | + Set<Class<? extends AudioSourceManager>> excluded = Set.of(excludedSources); |
| 78 | + if (!excluded.contains(YoutubeAudioSourceManager.class)) { |
| 79 | + playerManager.registerSourceManager(new YoutubeAudioSourceManager(true, null, null)); |
| 80 | + } |
| 81 | + if (!excluded.contains(SoundCloudAudioSourceManager.class)) { |
| 82 | + playerManager.registerSourceManager(SoundCloudAudioSourceManager.createDefault()); |
| 83 | + } |
| 84 | + if (!excluded.contains(BandcampAudioSourceManager.class)) { |
| 85 | + playerManager.registerSourceManager(new BandcampAudioSourceManager()); |
| 86 | + } |
| 87 | + if (!excluded.contains(VimeoAudioSourceManager.class)) { |
| 88 | + playerManager.registerSourceManager(new VimeoAudioSourceManager()); |
| 89 | + } |
| 90 | + if (!excluded.contains(TwitchStreamAudioSourceManager.class)) { |
| 91 | + playerManager.registerSourceManager(new TwitchStreamAudioSourceManager()); |
| 92 | + } |
| 93 | + if (!excluded.contains(BeamAudioSourceManager.class)) { |
| 94 | + playerManager.registerSourceManager(new BeamAudioSourceManager()); |
| 95 | + } |
| 96 | + if (!excluded.contains(GetyarnAudioSourceManager.class)) { |
| 97 | + playerManager.registerSourceManager(new GetyarnAudioSourceManager()); |
| 98 | + } |
| 99 | + if (!excluded.contains(HttpAudioSourceManager.class)) { |
| 100 | + playerManager.registerSourceManager(new HttpAudioSourceManager(containerRegistry)); |
| 101 | + } |
| 102 | + } |
| 103 | + |
53 | 104 | /**
|
54 | 105 | * Registers the local file source manager to the specified player manager.
|
55 | 106 | *
|
|
0 commit comments