changes.
[IRC.git] / Robust / src / Tests / ssJava / mp3decoder / MP3Player.java
1 // command line player for MPEG audio file
2 public class MP3Player {
3
4   private String filename = null;
5
6   public static void main(String args[]) {
7
8     MP3Player player = new MP3Player();
9     player.init(args);
10
11   }
12
13   private void init(String[] args) {
14     if (args.length == 1) {
15       filename = args[0];
16     }
17   }
18
19   /**
20    * Playing file from FileInputStream.
21    */
22   protected InputStream getInputStream() throws IOException {
23     FileInputStream fin = new FileInputStream(filename);
24     BufferedInputStream bin = new BufferedInputStream(fin);
25     return bin;
26   }
27
28   public void play() throws JavaLayerException {
29     try {
30       System.out.println("playing " + filename + "...");
31       InputStream in = getInputStream();
32       AudioDevice dev = new AudioDevice();
33       Player player = new Player(in, dev);
34       player.play();
35     } catch (IOException ex) {
36       throw new JavaLayerException("Problem playing file " + filename, ex);
37     } catch (Exception ex) {
38       throw new JavaLayerException("Problem playing file " + filename, ex);
39     }
40   }
41
42 }