noob_saibot

Untitled

Nov 19th, 2022
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. import javax.sound.sampled.AudioInputStream;
  2. import javax.sound.sampled.AudioSystem;
  3. import javax.sound.sampled.Clip;
  4.  
  5. public class Main {
  6. public static void main(String[] args) {
  7. playSound("C:\\Users\\powha\\Documents\\CTT\\ЗАНЯТИЯ\\Конкурсы\\test\\src\\audio\\skeleton.wav");
  8. }
  9. public static synchronized void playSound(final String name) {
  10. new Thread(new Runnable() {
  11. public void run() {
  12. try {
  13. Clip clip = AudioSystem.getClip();
  14. AudioInputStream inputStream = AudioSystem.getAudioInputStream(
  15. Main.class.getResourceAsStream("C:\\Users\\powha\\Documents\\CTT\\ЗАНЯТИЯ\\Конкурсы\\test\\src\\audio\\skeleton.wav"));
  16. clip.open(inputStream);
  17. clip.start();
  18. } catch (Exception e) {
  19. System.err.println(e.getMessage());
  20. }
  21. }
  22. }).start();
  23. }
  24. }
Tags: Java
Advertisement
Add Comment
Please, Sign In to add comment