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

55
LINES

< > BotCompany Repo | #1025787 // Play with Lava AudioPlayer v2

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

Uses 29324K of libraries. Click here for Pure Java version (2694L/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>";
  transient double bufferSeconds = 5.0;
  transient CircularFifoBuffer buffer = new(iround(bufferSeconds*50));
  
  start-thread {
    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");
    
    doEvery(20, r {
      temp enter();
      AudioFrame frame = player.provide();
      if (frame == null) print("no frame");
      else {
        buffer.add(frame.getData());
        AudioDataFormat format = frame.getFormat();
        print("timecode: " + frame.getTimecode()
        + ", length: " + frame.getDataLength()
        + ", format: " + shortClassName(format)
        + ", sampleRate: " + format.sampleRate + ", buf: " + buffer.size() + "/" + buffer.getBase());
      }
    });
  }
      
  void cleanMeUp {
    if (player != null) player.destroy();
  }
}

Author comment

Began life as a copy of #1025786

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: #1025787
Snippet name: Play with Lava AudioPlayer v2
Eternal ID of this version: #1025787/4
Text MD5: a13bd2993e3daec19c62946c8f820303
Transpilation MD5: 216cb27e78de3efd0c36c9c67371ae4c
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:37:42
Source code size: 1970 bytes / 55 lines
Pitched / IR pitched: No / No
Views / Downloads: 213 / 329
Version history: 3 change(s)
Referenced in: