turt2live

Untitled

Apr 8th, 2012
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.77 KB | None | 0 0
  1. package technodork.ponygladiators.audio;
  2.  
  3. import java.io.FileInputStream;
  4. import java.io.IOException;
  5.  
  6. import sun.audio.AudioPlayer;
  7. import sun.audio.AudioStream;
  8.  
  9. import com.turt2live.ponies.engine.File;
  10.  
  11. /**
  12.  * Sound manager<br>
  13.  * <i>Cleaned up by turt2live</i>
  14.  *
  15.  * @author technodork
  16.  */
  17. public class SoundManager {
  18.     private AudioStream as;
  19.  
  20.     /**
  21.      * Creates a new sound manager
  22.      *
  23.      * @param f the audio file
  24.      */
  25.     public SoundManager(File f){
  26.         try{
  27.             as = new AudioStream(new FileInputStream(f));
  28.         }catch(IOException e){
  29.             e.printStackTrace();
  30.         }
  31.     }
  32.  
  33.     /**
  34.      * Start the audio
  35.      */
  36.     public void play(){
  37.         AudioPlayer.player.start(as);
  38.     }
  39.  
  40.     /**
  41.      *
  42.      * Stops the audio
  43.      */
  44.     public void stop(){
  45.         AudioPlayer.player.stop(as);
  46.     }
  47.  
  48. }
Advertisement
Add Comment
Please, Sign In to add comment