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)

1  
please include function makeBasicMP3Player. // libs etc
2  
3  
import javax.sound.sampled.LineUnavailableException;
4  
5  
static void playMp3_javaSound_basicPlayer(File mp3, O... _) ctex {
6  
  Number gain = cast optPar gain(_);
7  
  fixContextClassLoader();
8  
  BasicPlayer player = new BasicPlayer {
9  
    protected void initLine() throws LineUnavailableException {
10  
      super.initLine();
11  
      if (gain != null) ctex {
12  
        setGain(toDouble(gain));
13  
      }
14  
    }
15  
  };
16  
  player.open(mp3);
17  
  player.play();
18  
  try {
19  
    while (licensed() && player.getStatus() == player.PLAYING)
20  
      sleep(10);
21  
  } finally {
22  
    player.stop();
23  
  }
24  
}

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: 207 / 244
Version history: 6 change(s)
Referenced in: [show references]