Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

57
LINES

< > BotCompany Repo | #1025786 // Play with Lava AudioPlayer

JavaX source code (Dynamic Module) [tags: use-pretranspiled] - run with: Stefan's OS

Uses 29324K of libraries. Click here for Pure Java version (2857L/15K).

!7

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.*;
import com.sedmelluq.discord.lavaplayer.format.*;

//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 1002510 // jsoup
lib 1400299 // apache-commons-logging
lib 1011966 // slf4j-api-1.7.25.jar

cmodule PlayWithLava > DynPrintLog {
  transient AudioPlayer player;
  switchable S radioURL = "http://s3.free-shoutcast.com:18162/;?type=http&nocache=<RNDINT>";
  
  start-thread {
    try {
      AudioPlayerManager playerManager = lavaPlayer_playerManager();
      player = playerManager.createPlayer();
      lavaPlayer_printPlayerEvents(player);
      print("Have player");
      lavaPlayer_loadItem(module(), playerManager, player, radioURL.replace("<RNDINT>", str(randomInt())));
      print("Track loaded");
      
      repeat 1000 {
        AudioFrame frame = player.provide();
        if (frame == null) print("no frame");
        else {
          AudioDataFormat format = frame.getFormat();
          print("timecode: " + frame.getTimecode()
          + ", length: " + frame.getDataLength()
          + ", format: " + shortClassName(format)
          + ", sampleRate: " + format.sampleRate);
        }
        sleep(10);
      }
    } finally {
      if (player != null)
        player.stopTrack();
    }
  }
      
  void cleanMeUp {
    if (player != null) player.destroy();
  }
}

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: #1025786
Snippet name: Play with Lava AudioPlayer
Eternal ID of this version: #1025786/10
Text MD5: 634ee3276481ac634b0b389abfb0fde3
Transpilation MD5: 9531c2535534dd320de25d68274fc6a1
Author: stefan
Category: javax
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-10-19 23:18:27
Source code size: 1888 bytes / 57 lines
Pitched / IR pitched: No / No
Views / Downloads: 211 / 365
Version history: 9 change(s)
Referenced in: [show references]