View Javadoc

1   /*
2    * JarInspector - Copyright (C) 2004 Che Inc., Rosario Argentina
3    *
4    * This program is free software; you can redistribute it and/or
5    * modify it under the terms of the GNU Library General Public
6    * License as published by the Free Software Foundation; either
7    * version 2 of the License, or (at your option) any later version.
8    *
9    * This library is distributed in the hope that it will be useful,
10   * but WITHOUT ANY WARRANTY; without even the implied warranty of
11   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12   * Library General Public License for more details.
13   *
14   * You should have received a copy of the GNU Library General Public
15   * License along with this library; if not, write to the Free
16   * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17   */
18  
19  package inc.che.common.audio;
20  
21  // Imports
22  
23  import java.io.File;
24  import java.io.FileInputStream;
25  import java.io.IOException;
26  import java.io.InputStream;
27  
28  import org.apache.log4j.Logger;
29  
30  import sun.audio.AudioData;
31  import sun.audio.AudioDataStream;
32  import sun.audio.AudioStream;
33  
34  /***
35   *  <b>@todo</b>
36   * @version $Id: AudioPlayer.java,v 1.1 2005/03/06 12:56:48 stevemcmee Exp $
37   * @author <address> Steve McMee &lt;Steve@users.sourceforge.net&gt; </address>
38   */
39  
40  public final class AudioPlayer {
41  
42      /*** CVS ID of this file */
43      public static final String CVS_ID =
44          "$Id: AudioPlayer.java,v 1.1 2005/03/06 12:56:48 stevemcmee Exp $";
45  
46      /***
47       * logger instance for this class
48       */
49  
50      private static Logger log = Logger.getLogger(AudioPlayer.class);
51  
52      /***
53       * forbidden Constructor
54       */
55      private AudioPlayer() {
56      }
57  
58      public static void play(File audioFile) throws IOException {
59          play(new FileInputStream(audioFile));
60      }
61  
62      public static void play(InputStream is) throws IOException {
63          AudioData data = new AudioStream(is).getData();
64          AudioDataStream audiostream = new AudioDataStream(data);
65          sun.audio.AudioPlayer.player.start(audiostream);
66      }
67  
68  }