Uses 34242K of libraries. Click here for Pure Java version (10710L/57K).
!7 //set flag DifferentJDA. //lib 1400185 // discord with opus/JNA (hopefully not a problem) import net.dv8tion.jda.core.managers.AudioManager; // Note: moved from core to api in JDA 4.0 import net.dv8tion.jda.core.audio.*; import java.nio.ByteBuffer; import com.sedmelluq.discord.lavaplayer.player.*; import com.sedmelluq.discord.lavaplayer.player.event.*; import com.sedmelluq.discord.lavaplayer.demo.jda.TrackScheduler; import com.sedmelluq.discord.lavaplayer.track.*; import com.sedmelluq.discord.lavaplayer.track.playback.*; import com.sedmelluq.discord.lavaplayer.source.*; import com.sedmelluq.discord.lavaplayer.tools.*; //lib 1400286 // lavaplayer 1.3.22 lib 1400288 // lavaplayer fat lib 1400289 // httpclient lib 1400290 // httpcore lib 1400291 // commons-io lib 1400298 // lavaplayer libconnector.so lib 1400295 lib 1400296 // logback lib 1002510 // jsoup lib 1400299 // apache-commons-logging static AudioPlayerManager playerManager; svoid cleanMeUp { dispose playerManager; } cmodule DiscordAudioSpike > DynTalkBot2 { S myName = "Discord Audio Spike"; start { setLoggingLevel(ch.qos.logback.classic.Level.DEBUG); if (isLinux()) { //loadNativeLibraryInX30(loadLibrary(#1400293)); loadNativeLibrarySnippet/*InX30*/(#1400293); // libopus //loadNativeLibrarySnippet/*InX30*/(#1400294); // libconnector } makeByServer = () -> new ByServer; useAGIBlueForDropPunctuation = false; preprocessAtSelfToMyName = false; if (playerManager == null) { playerManager = new DefaultAudioPlayerManager; AudioSourceManagers.registerLocalSource(playerManager); AudioSourceManagers.registerRemoteSources(playerManager); } } class ByServer extends DynTalkBot2.ByServer { synchronized S processSimplifiedLine(S s, O... _) { try answer super.processSimplifiedLine(s, _); // adding authorized users etc. new Matches m; if null (s = dropMyPrefixOrNull(s)) null; optPar Message msg; Guild guild = msg == null ? null : msg.getGuild(); if "voice channels" ret str(guild.getVoiceChannels()); if "join voice channel" ret joinVoiceChannel(first(guild.getVoiceChannels()); if (eqic(s, "help")) ret ltrim([[ I'm a Discord Audio Test [Bot made by https://BotCompany.de] ]]).replace("@me", atSelf()); null; } S joinVoiceChannel(VoiceChannel vc) { if (vc == null) ret "No channel"; Guild guild = vc.getGuild(); AudioManager am = guild.getAudioManager(); AudioPlayer player = playerManager.createPlayer(); TrackScheduler trackScheduler = new(player); player.addListener(trackScheduler); player.addListener(e -> { temp enter(); print("Audio event: " + e); if (e cast TrackExceptionEvent) printStackTrace(e.exception); }); am.setSendingHandler(new AudioPlayerSendHandler(player)); am.openAudioConnection(vc); /*S trackID = f2s( //loadLibrary(#1400292) // opus mp3ToWAVUnlessExists(loadLibrary(#1001093), javaxCachesDir("1001093.wav")) // mp3 -> wav );*/ S trackID = "http://s3.free-shoutcast.com:18162/;?type=http&nocache=" + randomInt(); playerManager.loadItem(print("Loading: ", trackID), new AudioLoadResultHandler { public void trackLoaded(AudioTrack track) enter { //print("Scheduling track " + track); //trackScheduler.queue(track); //player.playTrack(track); print(player.startTrack(track, false)); print("Started track " + track); print("isPaused: " + player.isPaused()); print("Active track: " + player.getPlayingTrack()); } public void playlistLoaded(AudioPlaylist playlist) enter { for (AudioTrack track : playlist.getTracks()) trackScheduler.queue(track); } public void noMatches() enter { print("noMatches"); } public void loadFailed(FriendlyException e) enter { print("loadFailed: " + e); printStackTrace(e); } }); ret "Audio connection to " + vc.getName() + " opened"; } } } sclass AudioPlayerSendHandler implements AudioSendHandler { AudioPlayer audioPlayer; AudioFrame lastFrame; NotTooOften nto = notTooOften_everySecond(); *(AudioPlayer *audioPlayer) {} public bool canProvide() { lastFrame = audioPlayer.provide(); if (nto.yo()) print("canProvide: " + (lastFrame != null)); ret lastFrame != null; } public byte[] provide20MsAudio() { return lastFrame.getData(); } public bool isOpus() { true; } } svoid setLoggingLevel(ch.qos.logback.classic.Level level) { ch.qos.logback.classic.Logger root = (ch.qos.logback.classic.Logger) org.slf4j.LoggerFactory.getLogger(ch.qos.logback.classic.Logger.ROOT_LOGGER_NAME); root.setLevel(level); }
Began life as a copy of #1024145
download show line numbers debug dex old transpilations
Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1025322 |
Snippet name: | Discord Audio Spike [dev., warning: loads native libraries] |
Eternal ID of this version: | #1025322/63 |
Text MD5: | f859bba836396c8aab51f161f480f470 |
Transpilation MD5: | 3ec11903695d63dcf6e5307951c56e93 |
Author: | stefan |
Category: | javax |
Type: | JavaX source code (Dynamic Module) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-09-22 19:50:46 |
Source code size: | 5102 bytes / 153 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 452 / 1090 |
Version history: | 62 change(s) |
Referenced in: | [show references] |