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

27
LINES

< > BotCompany Repo | #1009565 // javaSound_playFile

JavaX fragment (include)

import java.io.*;
import javax.sound.sampled.*;

static Pair<Clip, Flag> javaSound_playFile(File f) ctex {
  AudioInputStream stream;
  AudioFormat format;
  DataLine.Info info;
  final new Flag flag;
  
  stream = AudioSystem.getAudioInputStream(f);
  format = stream.getFormat();
  info = new DataLine.Info(Clip.class, format);
  final Clip clip = (Clip) AudioSystem.getLine(info);
  
  clip.addLineListener(new LineListener {
    public void update(LineEvent event) {
      if (event.getType() == LineEvent.Type.STOP) {
        clip.close();
        flag.raise();
      }
    }
  });

  clip.open(stream);
  clip.start();
  ret pair(clip, flag);
}

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: 410 / 450
Version history: 3 change(s)
Referenced in: [show references]