Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javax.sound.sampled.AudioInputStream;
- import javax.sound.sampled.AudioSystem;
- import javax.sound.sampled.Clip;
- public class Main {
- public static void main(String[] args) {
- playSound("C:\\Users\\powha\\Documents\\CTT\\ЗАНЯТИЯ\\Конкурсы\\test\\src\\audio\\skeleton.wav");
- }
- public static synchronized void playSound(final String name) {
- new Thread(new Runnable() {
- public void run() {
- try {
- Clip clip = AudioSystem.getClip();
- AudioInputStream inputStream = AudioSystem.getAudioInputStream(
- Main.class.getResourceAsStream("C:\\Users\\powha\\Documents\\CTT\\ЗАНЯТИЯ\\Конкурсы\\test\\src\\audio\\skeleton.wav"));
- clip.open(inputStream);
- clip.start();
- } catch (Exception e) {
- System.err.println(e.getMessage());
- }
- }
- }).start();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment