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

24
LINES

< > BotCompany Repo | #1023249 // playMp3_javaSound_basicPlayer (supports gain)

JavaX fragment (include)

please include function makeBasicMP3Player. // libs etc

import javax.sound.sampled.LineUnavailableException;

static void playMp3_javaSound_basicPlayer(File mp3, O... _) ctex {
  Number gain = cast optPar gain(_);
  fixContextClassLoader();
  BasicPlayer player = new BasicPlayer {
    protected void initLine() throws LineUnavailableException {
      super.initLine();
      if (gain != null) ctex {
        setGain(toDouble(gain));
      }
    }
  };
  player.open(mp3);
  player.play();
  try {
    while (licensed() && player.getStatus() == player.PLAYING)
      sleep(10);
  } finally {
    player.stop();
  }
}

Author comment

Began life as a copy of #1014503

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1023249
Snippet name: playMp3_javaSound_basicPlayer (supports gain)
Eternal ID of this version: #1023249/7
Text MD5: 430c7776b7b139588ac04053a569d230
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-05-19 11:45:31
Source code size: 640 bytes / 24 lines
Pitched / IR pitched: No / No
Views / Downloads: 204 / 239
Version history: 6 change(s)
Referenced in: [show references]