Guest User

Untitled

a guest
Apr 7th, 2013
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. Ma classe Sound.java:
  2.  
  3. import java.applet.*;
  4.  
  5.  
  6. public class Sound {
  7.  
  8. public static final Sound sound1 = new Sound("https://dl-web.dropbox.com/get/Halocube/Heart%20of%20Courage.wav?w=AAC9hdZykOMXLdPphitnFjVuKRj7ue6azrIY0ut-yTn1jw");
  9.  
  10. private AudioClip ac;
  11.  
  12. public Sound(String file){
  13. try{
  14. ac = Applet.newAudioClip(Sound.class.getResource(file));
  15. }catch(Exception e){e.printStackTrace();}
  16.  
  17. }
  18.  
  19. public void play(){
  20. try{
  21. new Thread(){
  22. public void run(){
  23. ac.play();
  24. }
  25. }.start();
  26. }catch(Exception e){e.printStackTrace();}
  27. }
  28. }
  29.  
  30.  
  31. Ma classe GuiMainMenu.java:
  32.  
  33. public class Main{
  34.  
  35.  
  36. public Main(){
  37. Sound.sound1.play();
  38. }
  39.  
  40. public void main(String[] args) {
  41. Main main = new Main();
  42. }
  43.  
  44.  
  45. }
Advertisement
Add Comment
Please, Sign In to add comment