diff options
Diffstat (limited to 'songdbj/javazoom/jl/player/jlp.java')
-rw-r--r-- | songdbj/javazoom/jl/player/jlp.java | 176 |
1 files changed, 0 insertions, 176 deletions
diff --git a/songdbj/javazoom/jl/player/jlp.java b/songdbj/javazoom/jl/player/jlp.java deleted file mode 100644 index ddb3d5ecca..0000000000 --- a/songdbj/javazoom/jl/player/jlp.java +++ /dev/null | |||
@@ -1,176 +0,0 @@ | |||
1 | /* | ||
2 | * 11/19/04 1.0 moved to LGPL. | ||
3 | * | ||
4 | * 06/04/01 Streaming support added. javalayer@javazoom.net | ||
5 | * | ||
6 | * 29/01/00 Initial version. mdm@techie.com | ||
7 | *----------------------------------------------------------------------- | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU Library General Public License as published | ||
10 | * by the Free Software Foundation; either version 2 of the License, or | ||
11 | * (at your option) any later version. | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, | ||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | * GNU Library General Public License for more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU Library General Public | ||
19 | * License along with this program; if not, write to the Free Software | ||
20 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
21 | *---------------------------------------------------------------------- | ||
22 | */ | ||
23 | |||
24 | package javazoom.jl.player; | ||
25 | |||
26 | import java.io.BufferedInputStream; | ||
27 | import java.io.FileInputStream; | ||
28 | import java.io.IOException; | ||
29 | import java.io.InputStream; | ||
30 | import java.net.URL; | ||
31 | |||
32 | import javazoom.jl.decoder.JavaLayerException; | ||
33 | |||
34 | /** | ||
35 | * The <code>jlp</code> class implements a simple command-line | ||
36 | * player for MPEG audio files. | ||
37 | * | ||
38 | * @author Mat McGowan (mdm@techie.com) | ||
39 | */ | ||
40 | public class jlp | ||
41 | { | ||
42 | private String fFilename = null; | ||
43 | private boolean remote = false; | ||
44 | |||
45 | public static void main(String[] args) | ||
46 | { | ||
47 | int retval = 0; | ||
48 | try | ||
49 | { | ||
50 | jlp player = createInstance(args); | ||
51 | if (player!=null) | ||
52 | player.play(); | ||
53 | } | ||
54 | catch (Exception ex) | ||
55 | { | ||
56 | System.err.println(ex); | ||
57 | ex.printStackTrace(System.err); | ||
58 | retval = 1; | ||
59 | } | ||
60 | System.exit(retval); | ||
61 | } | ||
62 | |||
63 | static public jlp createInstance(String[] args) | ||
64 | { | ||
65 | jlp player = new jlp(); | ||
66 | if (!player.parseArgs(args)) | ||
67 | player = null; | ||
68 | return player; | ||
69 | } | ||
70 | |||
71 | private jlp() | ||
72 | { | ||
73 | } | ||
74 | |||
75 | public jlp(String filename) | ||
76 | { | ||
77 | init(filename); | ||
78 | } | ||
79 | |||
80 | protected void init(String filename) | ||
81 | { | ||
82 | fFilename = filename; | ||
83 | } | ||
84 | |||
85 | protected boolean parseArgs(String[] args) | ||
86 | { | ||
87 | boolean parsed = false; | ||
88 | if (args.length == 1) | ||
89 | { | ||
90 | init(args[0]); | ||
91 | parsed = true; | ||
92 | remote = false; | ||
93 | } | ||
94 | else if (args.length == 2) | ||
95 | { | ||
96 | if (!(args[0].equals("-url"))) | ||
97 | { | ||
98 | showUsage(); | ||
99 | } | ||
100 | else | ||
101 | { | ||
102 | init(args[1]); | ||
103 | parsed = true; | ||
104 | remote = true; | ||
105 | } | ||
106 | } | ||
107 | else | ||
108 | { | ||
109 | showUsage(); | ||
110 | } | ||
111 | return parsed; | ||
112 | } | ||
113 | |||
114 | public void showUsage() | ||
115 | { | ||
116 | System.out.println("Usage: jlp [-url] <filename>"); | ||
117 | System.out.println(""); | ||
118 | System.out.println(" e.g. : java javazoom.jl.player.jlp localfile.mp3"); | ||
119 | System.out.println(" java javazoom.jl.player.jlp -url http://www.server.com/remotefile.mp3"); | ||
120 | System.out.println(" java javazoom.jl.player.jlp -url http://www.shoutcastserver.com:8000"); | ||
121 | } | ||
122 | |||
123 | public void play() | ||
124 | throws JavaLayerException | ||
125 | { | ||
126 | try | ||
127 | { | ||
128 | System.out.println("playing "+fFilename+"..."); | ||
129 | InputStream in = null; | ||
130 | if (remote == true) in = getURLInputStream(); | ||
131 | else in = getInputStream(); | ||
132 | AudioDevice dev = getAudioDevice(); | ||
133 | Player player = new Player(in, dev); | ||
134 | player.play(); | ||
135 | } | ||
136 | catch (IOException ex) | ||
137 | { | ||
138 | throw new JavaLayerException("Problem playing file "+fFilename, ex); | ||
139 | } | ||
140 | catch (Exception ex) | ||
141 | { | ||
142 | throw new JavaLayerException("Problem playing file "+fFilename, ex); | ||
143 | } | ||
144 | } | ||
145 | |||
146 | /** | ||
147 | * Playing file from URL (Streaming). | ||
148 | */ | ||
149 | protected InputStream getURLInputStream() | ||
150 | throws Exception | ||
151 | { | ||
152 | |||
153 | URL url = new URL(fFilename); | ||
154 | InputStream fin = url.openStream(); | ||
155 | BufferedInputStream bin = new BufferedInputStream(fin); | ||
156 | return bin; | ||
157 | } | ||
158 | |||
159 | /** | ||
160 | * Playing file from FileInputStream. | ||
161 | */ | ||
162 | protected InputStream getInputStream() | ||
163 | throws IOException | ||
164 | { | ||
165 | FileInputStream fin = new FileInputStream(fFilename); | ||
166 | BufferedInputStream bin = new BufferedInputStream(fin); | ||
167 | return bin; | ||
168 | } | ||
169 | |||
170 | protected AudioDevice getAudioDevice() | ||
171 | throws JavaLayerException | ||
172 | { | ||
173 | return FactoryRegistry.systemRegistry().createAudioDevice(); | ||
174 | } | ||
175 | |||
176 | } | ||