1 // command line player for MPEG audio file
2 public class MP3Player {
4 private String filename = null;
6 public static void main(String args[]) {
8 MP3Player player = new MP3Player();
13 private void init(String[] args) {
14 if (args.length == 1) {
20 * Playing file from FileInputStream.
22 protected InputStream getInputStream() throws IOException {
23 FileInputStream fin = new FileInputStream(filename);
24 BufferedInputStream bin = new BufferedInputStream(fin);
28 public void play() throws JavaLayerException {
30 System.out.println("playing " + filename + "...");
31 InputStream in = getInputStream();
32 AudioDevice dev = new AudioDevice();
33 Player player = new Player(in, dev);
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);