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

27
LINES

< > BotCompany Repo | #1009565 // javaSound_playFile

JavaX fragment (include)

1  
import java.io.*;
2  
import javax.sound.sampled.*;
3  
4  
static Pair<Clip, Flag> javaSound_playFile(File f) ctex {
5  
  AudioInputStream stream;
6  
  AudioFormat format;
7  
  DataLine.Info info;
8  
  final new Flag flag;
9  
  
10  
  stream = AudioSystem.getAudioInputStream(f);
11  
  format = stream.getFormat();
12  
  info = new DataLine.Info(Clip.class, format);
13  
  final Clip clip = (Clip) AudioSystem.getLine(info);
14  
  
15  
  clip.addLineListener(new LineListener {
16  
    public void update(LineEvent event) {
17  
      if (event.getType() == LineEvent.Type.STOP) {
18  
        clip.close();
19  
        flag.raise();
20  
      }
21  
    }
22  
  });
23  
24  
  clip.open(stream);
25  
  clip.start();
26  
  ret pair(clip, flag);
27  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1009565
Snippet name: javaSound_playFile
Eternal ID of this version: #1009565/4
Text MD5: 21c17912701a0e0581f067c70b5e0caf
Author: stefan
Category: javax / sound
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-08-07 21:28:11
Source code size: 676 bytes / 27 lines
Pitched / IR pitched: No / No
Views / Downloads: 411 / 452
Version history: 3 change(s)
Referenced in: [show references]