Index: trunk/cortado/src/com/fluendo/player/DurationScanner.java |
— | — | @@ -43,6 +43,7 @@ |
44 | 44 | final static int VORBIS = 1; |
45 | 45 | final static int THEORA = 2; |
46 | 46 | private long contentLength = -1; |
| 47 | + private long responseOffset; |
47 | 48 | private Hashtable streaminfo = new Hashtable(); |
48 | 49 | private SyncState oy = new SyncState(); |
49 | 50 | private Page og = new Page(); |
— | — | @@ -86,7 +87,6 @@ |
87 | 88 | dis = uc.getInputStream(); |
88 | 89 | |
89 | 90 | String responseRange = uc.getHeaderField("Content-Range"); |
90 | | - long responseOffset; |
91 | 91 | if (responseRange == null) { |
92 | 92 | Debug.info("Response contained no Content-Range field, assuming offset=0"); |
93 | 93 | responseOffset = 0; |
— | — | @@ -199,8 +199,8 @@ |
200 | 200 | |
201 | 201 | public float getDurationForURL(URL url, String user, String password) { |
202 | 202 | try { |
203 | | - int headbytes = 16 * 1024; |
204 | | - int tailbytes = 80 * 1024; |
| 203 | + int headbytes = 24 * 1024; |
| 204 | + int tailbytes = 128 * 1024; |
205 | 205 | |
206 | 206 | float time = 0; |
207 | 207 | |
— | — | @@ -217,8 +217,12 @@ |
218 | 218 | time = t > time ? t : time; |
219 | 219 | read = is.read(buffer); |
220 | 220 | } |
221 | | - |
| 221 | + is.close(); |
222 | 222 | is = openWithConnection(url, user, password, contentLength - tailbytes); |
| 223 | + if(responseOffset == 0) { |
| 224 | + Debug.warning("DurationScanner: Couldn't complete duration scan due to failing range requests!"); |
| 225 | + return -1; |
| 226 | + } |
223 | 227 | |
224 | 228 | read = is.read(buffer); |
225 | 229 | // read tail until eos, also abort if way too many bytes have been read |
— | — | @@ -231,6 +235,7 @@ |
232 | 236 | |
233 | 237 | return time; |
234 | 238 | } catch (IOException e) { |
| 239 | + Debug.error(e.toString()); |
235 | 240 | return -1; |
236 | 241 | } |
237 | 242 | } |
Index: trunk/cortado/src/com/fluendo/player/Cortado.java |
— | — | @@ -15,7 +15,6 @@ |
16 | 16 | * along with this program; if not, write to the Free Software |
17 | 17 | * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA. |
18 | 18 | */ |
19 | | - |
20 | 19 | package com.fluendo.player; |
21 | 20 | |
22 | 21 | import java.applet.*; |
— | — | @@ -28,11 +27,10 @@ |
29 | 28 | |
30 | 29 | public class Cortado extends Applet implements Runnable, MouseMotionListener, |
31 | 30 | MouseListener, ComponentListener, BusHandler, StatusListener, ActionListener { |
| 31 | + |
32 | 32 | private static final long serialVersionUID = 1L; |
33 | | - |
34 | 33 | private Cortado cortado; |
35 | 34 | private CortadoPipeline pipeline; |
36 | | - |
37 | 35 | private String urlString; |
38 | 36 | private boolean audio; |
39 | 37 | private boolean video; |
— | — | @@ -45,8 +43,7 @@ |
46 | 44 | private int bufferLow; |
47 | 45 | private int bufferHigh; |
48 | 46 | private int debug; |
49 | | - private double duration; |
50 | | - |
| 47 | + private double durationParam; |
51 | 48 | private boolean statusRunning; |
52 | 49 | private Thread statusThread; |
53 | 50 | public Status status; |
— | — | @@ -55,19 +52,16 @@ |
56 | 53 | private boolean isBuffering; |
57 | 54 | private int desiredState; |
58 | 55 | private boolean started = false; |
59 | | - |
60 | 56 | private boolean isEOS; |
61 | 57 | private boolean isError; |
62 | | - |
63 | | - private static final String[] autoBoolVals = { "auto", "true", "false" }; |
| 58 | + private static final String[] autoBoolVals = {"auto", "true", "false"}; |
64 | 59 | private static final int BOOL_AUTO = 0; |
65 | 60 | private static final int BOOL_TRUE = 1; |
66 | 61 | private static final int BOOL_FALSE = 2; |
67 | 62 | private int seekable; |
68 | 63 | private int live; |
69 | | - |
70 | 64 | private int showStatus; |
71 | | - private static final String[] showStatusVals = { "auto", "show", "hide" }; |
| 65 | + private static final String[] showStatusVals = {"auto", "show", "hide"}; |
72 | 66 | public static final int STATUS_AUTO = 0; |
73 | 67 | public static final int STATUS_SHOW = 1; |
74 | 68 | public static final int STATUS_HIDE = 2; |
— | — | @@ -75,49 +69,53 @@ |
76 | 70 | private int hideCounter; |
77 | 71 | private boolean mayHide; |
78 | 72 | |
| 73 | + // HTML-5 media element attributes |
| 74 | + public double currentTime = 0; |
| 75 | + public double duration = -1; |
| 76 | + public boolean paused; |
| 77 | + public String src; |
| 78 | + |
79 | 79 | private PopupMenu menu; |
80 | | - |
81 | 80 | private Hashtable params = new Hashtable(); |
82 | | - |
83 | 81 | private Configure configure; |
84 | | - |
85 | 82 | private Dimension appletDimension; |
86 | 83 | |
87 | 84 | public String getAppletInfo() { |
88 | 85 | return "Title: Fluendo media player \nAuthor: Wim Taymans \nA Java based network multimedia player."; |
89 | 86 | } |
| 87 | + |
90 | 88 | public String getRevision() { |
91 | 89 | return "$Revision: 4170 $"; |
92 | 90 | } |
93 | 91 | |
94 | 92 | public String[][] getParameterInfo() { |
95 | 93 | String[][] info = { |
96 | | - { "url", "URL", "The media file to play" }, |
97 | | - { "seekable", "enum", |
98 | | - "Can you seek in this file (auto|true|false) (default auto)" }, |
99 | | - { "live", "enum", |
100 | | - "Is this a live stream (disabled PAUSE) (auto|true|false) (default auto)" }, |
101 | | - { "duration", "float", |
102 | | - "Total duration of the file in seconds (default unknown)" }, |
103 | | - { "audio", "boolean", "Enable audio playback (default true)" }, |
104 | | - { "video", "boolean", "Enable video playback (default true)" }, |
105 | | - { "statusHeight", "int", "The height of the status area (default 12)" }, |
106 | | - { "autoPlay", "boolean", "Automatically start playback (default true)" }, |
107 | | - { "showStatus", "enum", "Show status area (auto|show|hide) (default auto)" }, |
108 | | - { "hideTimeout", "int", "Timeout in seconds to hide the status area when " + |
109 | | - "showStatus is auto (default 0)" }, |
110 | | - { "showSpeaker", "boolean", "Show a speaker icon when audio is available (default true)" }, |
111 | | - { "keepAspect", "boolean", |
112 | | - "Use aspect ratio of video (default true)" }, |
113 | | - { "bufferSize", "int", |
114 | | - "The size of the prebuffer in Kbytes (default 100)" }, |
115 | | - { "bufferLow", "int", "Percent of empty buffer (default 10)" }, |
116 | | - { "bufferHigh", "int", "Percent of full buffer (default 70)" }, |
117 | | - { "userId", "string", |
118 | | - "userId for basic authentication (default null)" }, |
119 | | - { "password", "string", |
120 | | - "password for basic authentication (default null)" }, |
121 | | - { "debug", "int", "Debug level 0 - 4 (default = 3)" }, }; |
| 94 | + {"url", "URL", "The media file to play"}, |
| 95 | + {"seekable", "enum", |
| 96 | + "Can you seek in this file (auto|true|false) (default auto)"}, |
| 97 | + {"live", "enum", |
| 98 | + "Is this a live stream (disabled PAUSE) (auto|true|false) (default auto)"}, |
| 99 | + {"duration", "float", |
| 100 | + "Total duration of the file in seconds (default unknown)"}, |
| 101 | + {"audio", "boolean", "Enable audio playback (default true)"}, |
| 102 | + {"video", "boolean", "Enable video playback (default true)"}, |
| 103 | + {"statusHeight", "int", "The height of the status area (default 12)"}, |
| 104 | + {"autoPlay", "boolean", "Automatically start playback (default true)"}, |
| 105 | + {"showStatus", "enum", "Show status area (auto|show|hide) (default auto)"}, |
| 106 | + {"hideTimeout", "int", "Timeout in seconds to hide the status area when " + |
| 107 | + "showStatus is auto (default 0)"}, |
| 108 | + {"showSpeaker", "boolean", "Show a speaker icon when audio is available (default true)"}, |
| 109 | + {"keepAspect", "boolean", |
| 110 | + "Use aspect ratio of video (default true)"}, |
| 111 | + {"bufferSize", "int", |
| 112 | + "The size of the prebuffer in Kbytes (default 100)"}, |
| 113 | + {"bufferLow", "int", "Percent of empty buffer (default 10)"}, |
| 114 | + {"bufferHigh", "int", "Percent of full buffer (default 70)"}, |
| 115 | + {"userId", "string", |
| 116 | + "userId for basic authentication (default null)"}, |
| 117 | + {"password", "string", |
| 118 | + "password for basic authentication (default null)"}, |
| 119 | + {"debug", "int", "Debug level 0 - 4 (default = 3)"},}; |
122 | 120 | return info; |
123 | 121 | } |
124 | 122 | |
— | — | @@ -149,50 +147,55 @@ |
150 | 148 | } |
151 | 149 | |
152 | 150 | public int getEnumParam(String name, String[] vals, String def) { |
153 | | - int res = -1; |
| 151 | + int res = -1; |
154 | 152 | |
155 | | - String val = getParam (name, def); |
156 | | - for (int i=0; i<vals.length;i++) { |
157 | | - if (vals[i].equals (val)) { |
158 | | - res = i; |
159 | | - break; |
160 | | - } |
161 | | - } |
162 | | - if (res != -1) |
163 | | - Debug.info("param \""+name+"\" has enum value \""+res+"\" ("+vals[res]+")"); |
164 | | - else |
165 | | - Debug.info("param \""+name+"\" has invalid enum value"); |
166 | | - return res; |
| 153 | + String val = getParam(name, def); |
| 154 | + for (int i = 0; i < vals.length; i++) { |
| 155 | + if (vals[i].equals(val)) { |
| 156 | + res = i; |
| 157 | + break; |
| 158 | + } |
| 159 | + } |
| 160 | + if (res != -1) { |
| 161 | + Debug.info("param \"" + name + "\" has enum value \"" + res + "\" (" + vals[res] + ")"); |
| 162 | + } else { |
| 163 | + Debug.info("param \"" + name + "\" has invalid enum value"); |
| 164 | + } |
| 165 | + return res; |
167 | 166 | } |
| 167 | + |
168 | 168 | public String getStringParam(String name, String def) { |
169 | | - String res = getParam(name, def); |
170 | | - Debug.info("param \""+name+"\" has string value \""+res+"\""); |
171 | | - return res; |
| 169 | + String res = getParam(name, def); |
| 170 | + Debug.info("param \"" + name + "\" has string value \"" + res + "\""); |
| 171 | + return res; |
172 | 172 | } |
| 173 | + |
173 | 174 | public boolean getBoolParam(String name, boolean def) { |
174 | | - boolean res; |
175 | | - String defStr = def ? "true" : "false"; |
176 | | - String paramVal; |
| 175 | + boolean res; |
| 176 | + String defStr = def ? "true" : "false"; |
| 177 | + String paramVal; |
177 | 178 | |
178 | | - paramVal = String.valueOf(getParam(name, defStr)); |
| 179 | + paramVal = String.valueOf(getParam(name, defStr)); |
179 | 180 | |
180 | | - res = paramVal.equals("true"); |
181 | | - res |= paramVal.equals("1"); |
| 181 | + res = paramVal.equals("true"); |
| 182 | + res |= paramVal.equals("1"); |
182 | 183 | |
183 | | - Debug.info("param \""+name+"\" has boolean value \""+res+"\""); |
184 | | - return res; |
| 184 | + Debug.info("param \"" + name + "\" has boolean value \"" + res + "\""); |
| 185 | + return res; |
185 | 186 | } |
| 187 | + |
186 | 188 | public double getDoubleParam(String name, double def) { |
187 | | - double res; |
188 | | - res = Double.valueOf(getParam(name, ""+def)).doubleValue(); |
189 | | - Debug.info("param \""+name+"\" has double value \""+res+"\""); |
190 | | - return res; |
| 189 | + double res; |
| 190 | + res = Double.valueOf(getParam(name, "" + def)).doubleValue(); |
| 191 | + Debug.info("param \"" + name + "\" has double value \"" + res + "\""); |
| 192 | + return res; |
191 | 193 | } |
| 194 | + |
192 | 195 | public int getIntParam(String name, int def) { |
193 | | - int res; |
194 | | - res = Integer.valueOf(getParam(name, ""+def)).intValue(); |
195 | | - Debug.info("param \""+name+"\" has int value \""+res+"\""); |
196 | | - return res; |
| 196 | + int res; |
| 197 | + res = Integer.valueOf(getParam(name, "" + def)).intValue(); |
| 198 | + Debug.info("param \"" + name + "\" has int value \"" + res + "\""); |
| 199 | + return res; |
197 | 200 | } |
198 | 201 | |
199 | 202 | public void shutDown(Throwable error) { |
— | — | @@ -204,18 +207,19 @@ |
205 | 208 | public synchronized void init() { |
206 | 209 | cortado = this; |
207 | 210 | |
208 | | - Debug.info("init()"); |
| 211 | + Debug.info("init()"); |
209 | 212 | |
210 | | - if (pipeline != null) |
211 | | - stop(); |
| 213 | + if (pipeline != null) { |
| 214 | + stop(); |
| 215 | + } |
212 | 216 | |
213 | 217 | pipeline = new CortadoPipeline(this); |
214 | 218 | configure = new Configure(); |
215 | 219 | |
216 | | - urlString = getStringParam("url", null); |
| 220 | + src = urlString = getStringParam("url", null); |
217 | 221 | seekable = getEnumParam("seekable", autoBoolVals, "auto"); |
218 | 222 | live = getEnumParam("live", autoBoolVals, "auto"); |
219 | | - duration = getDoubleParam("duration", -1.0); |
| 223 | + durationParam = getDoubleParam("duration", -1.0); |
220 | 224 | audio = getBoolParam("audio", true); |
221 | 225 | video = getBoolParam("video", true); |
222 | 226 | statusHeight = getIntParam("statusHeight", 12); |
— | — | @@ -230,20 +234,22 @@ |
231 | 235 | debug = getIntParam("debug", 3); |
232 | 236 | userId = getStringParam("userId", null); |
233 | 237 | password = getStringParam("password", null); |
234 | | - |
| 238 | + |
235 | 239 | // if audio-only don't hide the status bar |
236 | | - if(!video) hideTimeout = Integer.MAX_VALUE; |
| 240 | + if (!video) { |
| 241 | + hideTimeout = Integer.MAX_VALUE; |
| 242 | + } |
237 | 243 | |
238 | 244 | Debug.level = debug; |
239 | 245 | Debug.log(Debug.INFO, "build info: " + configure.buildInfo); |
240 | 246 | Debug.log(Debug.INFO, "revision: " + getRevision()); |
241 | 247 | |
242 | | - /* FIXME, HTTP Range returns 206, which HTTPConnection on MS JVM thinks |
243 | | - * is a fatal error. Disable seeking for now. */ |
244 | | - if (System.getProperty("java.vendor").toUpperCase().startsWith ("MICROSOFT", 0)){ |
245 | | - Debug.log (Debug.WARNING, "Found MS JVM, disable seeking."); |
246 | | - seekable = BOOL_FALSE; |
247 | | - } |
| 248 | + /* FIXME, HTTP Range returns 206, which HTTPConnection on MS JVM thinks |
| 249 | + * is a fatal error. Disable seeking for now. */ |
| 250 | + if (System.getProperty("java.vendor").toUpperCase().startsWith("MICROSOFT", 0)) { |
| 251 | + Debug.log(Debug.WARNING, "Found MS JVM, disable seeking."); |
| 252 | + seekable = BOOL_FALSE; |
| 253 | + } |
248 | 254 | |
249 | 255 | pipeline.setUrl(urlString); |
250 | 256 | pipeline.setUserId(userId); |
— | — | @@ -254,14 +260,13 @@ |
255 | 261 | pipeline.setBufferLow(bufferLow); |
256 | 262 | pipeline.setBufferHigh(bufferHigh); |
257 | 263 | |
258 | | - URL documentBase; |
259 | | - try { |
260 | | - documentBase = getDocumentBase(); |
261 | | - Debug.log(Debug.INFO, "Document base: " + documentBase); |
262 | | - } |
263 | | - catch (Throwable t) { |
264 | | - documentBase = null; |
265 | | - } |
| 264 | + URL documentBase; |
| 265 | + try { |
| 266 | + documentBase = getDocumentBase(); |
| 267 | + Debug.log(Debug.INFO, "Document base: " + documentBase); |
| 268 | + } catch (Throwable t) { |
| 269 | + documentBase = null; |
| 270 | + } |
266 | 271 | pipeline.setDocumentBase(documentBase); |
267 | 272 | pipeline.setComponent(this); |
268 | 273 | pipeline.getBus().addHandler(this); |
— | — | @@ -273,28 +278,42 @@ |
274 | 279 | status.setShowSpeaker(showSpeaker); |
275 | 280 | status.setHaveAudio(audio); |
276 | 281 | status.setHavePercent(true); |
277 | | - /* assume live stream unless specified */ |
278 | | - if (live == BOOL_FALSE) |
279 | | - status.setLive(false); |
280 | | - else |
281 | | - status.setLive(true); |
| 282 | + /* assume live stream unless specified */ |
| 283 | + if (live == BOOL_FALSE) { |
| 284 | + status.setLive(false); |
| 285 | + } else { |
| 286 | + status.setLive(true); |
| 287 | + } |
282 | 288 | |
283 | | - /* assume non seekable stream unless specified */ |
284 | | - if (seekable == BOOL_TRUE) |
285 | | - status.setSeekable(true); |
286 | | - else |
287 | | - status.setSeekable(false); |
| 289 | + /* assume non seekable stream unless specified */ |
| 290 | + if (seekable == BOOL_TRUE) { |
| 291 | + status.setSeekable(true); |
| 292 | + } else { |
| 293 | + status.setSeekable(false); |
| 294 | + } |
288 | 295 | |
289 | | - status.setDuration(duration); |
| 296 | + if (durationParam < 0) { |
| 297 | + try { |
| 298 | + String base = documentBase != null ? documentBase.toString().substring(0, documentBase.toString().lastIndexOf("/")) : ""; |
| 299 | + String docurlstring = urlString.contains("://") ? urlString : base + "/" + urlString; |
| 300 | + Debug.log(Debug.INFO, "trying to determine duration for " + docurlstring); |
| 301 | + URL url = new URL(docurlstring); |
| 302 | + duration = durationParam = new DurationScanner().getDurationForURL(url, userId, password); |
| 303 | + Debug.log(Debug.INFO, "Determined stream duration to be approx. " + durationParam); |
| 304 | + } catch (Exception ex) { |
| 305 | + Debug.log(Debug.WARNING, "Couldn't determine duration for stream."); |
| 306 | + } |
| 307 | + } |
| 308 | + |
| 309 | + status.setDuration(durationParam); |
290 | 310 | inStatus = false; |
291 | 311 | mayHide = (hideTimeout == 0); |
292 | | - hideCounter = 0; |
293 | | - if (showStatus != STATUS_HIDE) { |
294 | | - status.setVisible(true); |
295 | | - } |
296 | | - else { |
297 | | - status.setVisible(false); |
298 | | - } |
| 312 | + hideCounter = 0; |
| 313 | + if (showStatus != STATUS_HIDE) { |
| 314 | + status.setVisible(true); |
| 315 | + } else { |
| 316 | + status.setVisible(false); |
| 317 | + } |
299 | 318 | |
300 | 319 | menu = new PopupMenu(); |
301 | 320 | menu.add("About..."); |
— | — | @@ -303,7 +322,7 @@ |
304 | 323 | } |
305 | 324 | |
306 | 325 | public void actionPerformed(ActionEvent e) { |
307 | | - String command = e.getActionCommand(); |
| 326 | + String command = e.getActionCommand(); |
308 | 327 | |
309 | 328 | if (command.equals("About...")) { |
310 | 329 | AboutFrame about = new AboutFrame(pipeline); |
— | — | @@ -312,7 +331,7 @@ |
313 | 332 | } |
314 | 333 | |
315 | 334 | public Graphics getGraphics() { |
316 | | - Dimension dim = getSize(); |
| 335 | + Dimension dim = getSize(); |
317 | 336 | Graphics g = super.getGraphics(); |
318 | 337 | |
319 | 338 | if (status != null && status.isVisible()) { |
— | — | @@ -325,27 +344,31 @@ |
326 | 345 | |
327 | 346 | public void componentHidden(ComponentEvent e) { |
328 | 347 | } |
| 348 | + |
329 | 349 | public void componentMoved(ComponentEvent e) { |
330 | 350 | } |
| 351 | + |
331 | 352 | public void componentResized(ComponentEvent e) { |
332 | | - /* reset cached dimension */ |
333 | | - appletDimension = super.getSize(); |
334 | | - if (pipeline != null) { |
335 | | - pipeline.resize(appletDimension); |
336 | | - } |
| 353 | + /* reset cached dimension */ |
| 354 | + appletDimension = super.getSize(); |
| 355 | + if (pipeline != null) { |
| 356 | + pipeline.resize(appletDimension); |
| 357 | + } |
337 | 358 | } |
| 359 | + |
338 | 360 | public void componentShown(ComponentEvent e) { |
339 | | - // reset cached dimension |
340 | | - appletDimension = super.getSize(); |
341 | | - Debug.debug("Component shown, size = " + appletDimension); |
342 | | - if (pipeline != null) { |
343 | | - pipeline.resize(appletDimension); |
344 | | - } |
| 361 | + // reset cached dimension |
| 362 | + appletDimension = super.getSize(); |
| 363 | + Debug.debug("Component shown, size = " + appletDimension); |
| 364 | + if (pipeline != null) { |
| 365 | + pipeline.resize(appletDimension); |
| 366 | + } |
345 | 367 | } |
346 | 368 | |
347 | 369 | public Dimension getSize() { |
348 | | - if (appletDimension == null) |
| 370 | + if (appletDimension == null) { |
349 | 371 | appletDimension = super.getSize(); |
| 372 | + } |
350 | 373 | |
351 | 374 | return appletDimension; |
352 | 375 | } |
— | — | @@ -366,45 +389,44 @@ |
367 | 390 | Debug.log(Debug.INFO, "entering status thread"); |
368 | 391 | while (statusRunning) { |
369 | 392 | try { |
370 | | - long now; |
371 | | - |
372 | | - now = pipeline.getPosition() / Clock.SECOND; |
| 393 | + long now; |
| 394 | + |
| 395 | + currentTime = now = pipeline.getPosition() / Clock.SECOND; |
373 | 396 | status.setTime(now); |
374 | 397 | |
375 | 398 | Thread.sleep(1000); |
376 | 399 | |
377 | | - if (hideCounter > 0) { |
378 | | - hideCounter--; |
379 | | - if (hideCounter == 0) { |
380 | | - mayHide = true; |
381 | | - setStatusVisible(false, false); |
382 | | - } |
383 | | - } |
| 400 | + if (hideCounter > 0) { |
| 401 | + hideCounter--; |
| 402 | + if (hideCounter == 0) { |
| 403 | + mayHide = true; |
| 404 | + setStatusVisible(false, false); |
| 405 | + } |
| 406 | + } |
384 | 407 | } catch (Exception e) { |
385 | 408 | if (statusRunning) { |
386 | 409 | Debug.log(Debug.ERROR, "Exception in status thread:"); |
387 | 410 | e.printStackTrace(); |
388 | | - } |
| 411 | + } |
389 | 412 | } |
390 | 413 | } |
391 | 414 | Debug.log(Debug.INFO, "exit status thread"); |
392 | 415 | } |
393 | 416 | |
394 | 417 | public void paint(Graphics g) { |
395 | | - Dimension dim = getSize(); |
| 418 | + Dimension dim = getSize(); |
396 | 419 | |
397 | 420 | int dwidth = dim.width; |
398 | 421 | int dheight = dim.height; |
399 | 422 | |
400 | 423 | /* sometimes dimension is wrong */ |
401 | 424 | if (dwidth <= 0 || dheight < statusHeight) { |
402 | | - appletDimension = null; |
403 | | - Debug.log (Debug.WARNING, |
404 | | - "paint aborted: appletDimension wrong; dwidth " + dwidth |
405 | | - + ", dheight " + dheight + ", statusHeight " + statusHeight); |
406 | | - return; |
407 | | - } |
408 | | - |
| 425 | + appletDimension = null; |
| 426 | + Debug.log(Debug.WARNING, |
| 427 | + "paint aborted: appletDimension wrong; dwidth " + dwidth + ", dheight " + dheight + ", statusHeight " + statusHeight); |
| 428 | + return; |
| 429 | + } |
| 430 | + |
409 | 431 | if (status != null && status.isVisible()) { |
410 | 432 | status.setBounds(0, dheight - statusHeight, dwidth, statusHeight); |
411 | 433 | status.paint(g); |
— | — | @@ -415,43 +437,46 @@ |
416 | 438 | /* no change, do nothing */ |
417 | 439 | if (status.isVisible() == b) { |
418 | 440 | return; |
419 | | - } |
| 441 | + } |
420 | 442 | |
421 | | - /* refuse to hide when hideTimeout did not expire */ |
422 | | - if (!b && !mayHide) { |
| 443 | + /* refuse to hide when hideTimeout did not expire */ |
| 444 | + if (!b && !mayHide) { |
423 | 445 | return; |
424 | | - } |
| 446 | + } |
425 | 447 | |
426 | | - if (!force) { |
427 | | - if (showStatus == STATUS_SHOW && !b) { |
428 | | - return; |
429 | | - } |
430 | | - if (showStatus == STATUS_HIDE && b) { |
431 | | - return; |
432 | | - } |
433 | | - } |
434 | | - /* never hide when we are in error */ |
435 | | - if (isError && !b) { |
| 448 | + if (!force) { |
| 449 | + if (showStatus == STATUS_SHOW && !b) { |
| 450 | + return; |
| 451 | + } |
| 452 | + if (showStatus == STATUS_HIDE && b) { |
| 453 | + return; |
| 454 | + } |
| 455 | + } |
| 456 | + /* never hide when we are in error */ |
| 457 | + if (isError && !b) { |
436 | 458 | return; |
437 | | - } |
438 | | - |
| 459 | + } |
| 460 | + |
439 | 461 | /* don't make invisible when the mouse pointer is inside status area */ |
440 | 462 | if (inStatus && !b) { |
441 | 463 | b = true; |
442 | | - } |
| 464 | + } |
443 | 465 | |
444 | | - if(b != status.isVisible()) |
445 | | - Debug.log (Debug.INFO, "Status: "+ (b ? "Show" : "Hide")); |
446 | | - |
447 | | - if(b) hideCounter = hideTimeout; |
| 466 | + if (b != status.isVisible()) { |
| 467 | + Debug.log(Debug.INFO, "Status: " + (b ? "Show" : "Hide")); |
| 468 | + } |
| 469 | + |
| 470 | + if (b) { |
| 471 | + hideCounter = hideTimeout; |
| 472 | + } |
448 | 473 | status.setVisible(b); |
449 | 474 | repaint(); |
450 | 475 | } |
451 | 476 | |
452 | 477 | private boolean intersectStatus(MouseEvent e) { |
453 | | - int y = e.getY(); |
454 | | - int max = getSize().height; |
455 | | - int top = max - statusHeight; |
| 478 | + int y = e.getY(); |
| 479 | + int max = getSize().height; |
| 480 | + int top = max - statusHeight; |
456 | 481 | |
457 | 482 | inStatus = y > top && y < max; |
458 | 483 | return inStatus; |
— | — | @@ -484,10 +509,9 @@ |
485 | 510 | int y = getSize().height - statusHeight; |
486 | 511 | e.translatePoint(0, -y); |
487 | 512 | ((MouseListener) status).mouseReleased(e); |
| 513 | + } else { |
| 514 | + status.cancelMouseOperation(); |
488 | 515 | } |
489 | | - else { |
490 | | - status.cancelMouseOperation(); |
491 | | - } |
492 | 516 | } |
493 | 517 | |
494 | 518 | public void mouseDragged(MouseEvent e) { |
— | — | @@ -497,8 +521,8 @@ |
498 | 522 | e.translatePoint(0, -y); |
499 | 523 | ((MouseMotionListener) status).mouseDragged(e); |
500 | 524 | } /*else { |
501 | | - setStatusVisible(false, false); |
502 | | - }*/ |
| 525 | + setStatusVisible(false, false); |
| 526 | + }*/ |
503 | 527 | } |
504 | 528 | |
505 | 529 | public void mouseMoved(MouseEvent e) { |
— | — | @@ -508,338 +532,372 @@ |
509 | 533 | e.translatePoint(0, -y); |
510 | 534 | ((MouseMotionListener) status).mouseMoved(e); |
511 | 535 | } /*else { |
512 | | - setStatusVisible(false, false); |
| 536 | + setStatusVisible(false, false); |
513 | 537 | }*/ |
514 | 538 | setStatusVisible(true, false); |
515 | 539 | } |
516 | 540 | |
517 | 541 | public void handleMessage(Message msg) { |
518 | 542 | switch (msg.getType()) { |
519 | | - case Message.WARNING: |
520 | | - Debug.info(msg.toString()); |
521 | | - break; |
522 | | - case Message.ERROR: |
523 | | - Debug.info(msg.toString()); |
524 | | - if (!isError) { |
525 | | - status.setMessage(msg.parseErrorString()); |
526 | | - status.setState(Status.STATE_STOPPED); |
527 | | - pipeline.setState(Element.STOP); |
528 | | - setStatusVisible(true, true); |
529 | | - isError = true; |
530 | | - } |
531 | | - break; |
532 | | - case Message.EOS: |
533 | | - Debug.log(Debug.INFO, "EOS: playback ended"); |
534 | | - if (!isError) { |
535 | | - status.setState(Status.STATE_STOPPED); |
536 | | - status.setMessage("Playback ended"); |
537 | | - isEOS = true; |
538 | | - pipeline.setState(Element.STOP); |
539 | | - setStatusVisible(true, false); |
540 | | - } |
541 | | - break; |
542 | | - case Message.STREAM_STATUS: |
543 | | - Debug.info(msg.toString()); |
544 | | - break; |
545 | | - case Message.RESOURCE: |
546 | | - if (!isError) { |
547 | | - status.setMessage(msg.parseResourceString()); |
548 | | - setStatusVisible(true, false); |
549 | | - } |
550 | | - break; |
551 | | - case Message.DURATION: |
552 | | - long duration; |
| 543 | + case Message.WARNING: |
| 544 | + Debug.info(msg.toString()); |
| 545 | + break; |
| 546 | + case Message.ERROR: |
| 547 | + Debug.info(msg.toString()); |
| 548 | + if (!isError) { |
| 549 | + status.setMessage(msg.parseErrorString()); |
| 550 | + status.setState(Status.STATE_STOPPED); |
| 551 | + pipeline.setState(Element.STOP); |
| 552 | + setStatusVisible(true, true); |
| 553 | + isError = true; |
| 554 | + } |
| 555 | + break; |
| 556 | + case Message.EOS: |
| 557 | + Debug.log(Debug.INFO, "EOS: playback ended"); |
| 558 | + if (!isError) { |
| 559 | + status.setState(Status.STATE_STOPPED); |
| 560 | + status.setMessage("Playback ended"); |
| 561 | + isEOS = true; |
| 562 | + pipeline.setState(Element.STOP); |
| 563 | + setStatusVisible(true, false); |
| 564 | + } |
| 565 | + break; |
| 566 | + case Message.STREAM_STATUS: |
| 567 | + Debug.info(msg.toString()); |
| 568 | + break; |
| 569 | + case Message.RESOURCE: |
| 570 | + if (!isError) { |
| 571 | + status.setMessage(msg.parseResourceString()); |
| 572 | + setStatusVisible(true, false); |
| 573 | + } |
| 574 | + break; |
| 575 | + case Message.DURATION: |
| 576 | + long duration; |
553 | 577 | |
554 | | - duration = msg.parseDurationValue(); |
555 | | - |
556 | | - status.setByteDuration(duration); |
| 578 | + duration = msg.parseDurationValue(); |
557 | 579 | |
558 | | - Debug.log(Debug.DEBUG, "got duration: "+duration); |
559 | | - if (duration != -1) { |
560 | | - /* we got duration, we can enable automatic setting */ |
561 | | - if (seekable == BOOL_AUTO) |
562 | | - status.setSeekable(true); |
563 | | - if (live == BOOL_AUTO) |
564 | | - status.setLive(false); |
565 | | - } |
566 | | - break; |
567 | | - case Message.BUFFERING: |
568 | | - boolean busy; |
569 | | - int percent; |
| 580 | + status.setByteDuration(duration); |
570 | 581 | |
571 | | - if (isError) |
572 | | - break; |
| 582 | + Debug.log(Debug.DEBUG, "got duration: " + duration); |
| 583 | + if (duration != -1) { |
| 584 | + /* we got duration, we can enable automatic setting */ |
| 585 | + if (seekable == BOOL_AUTO) { |
| 586 | + status.setSeekable(true); |
| 587 | + } |
| 588 | + if (live == BOOL_AUTO) { |
| 589 | + status.setLive(false); |
| 590 | + } |
| 591 | + } |
| 592 | + break; |
| 593 | + case Message.BUFFERING: |
| 594 | + boolean busy; |
| 595 | + int percent; |
573 | 596 | |
574 | | - busy = msg.parseBufferingBusy(); |
575 | | - percent = msg.parseBufferingPercent(); |
| 597 | + if (isError) { |
| 598 | + break; |
| 599 | + } |
576 | 600 | |
577 | | - if (busy) { |
578 | | - if (!isBuffering) { |
579 | | - Debug.log(Debug.INFO, "PAUSE: we are buffering"); |
580 | | - if (desiredState == Element.PLAY) |
581 | | - pipeline.setState(Element.PAUSE); |
582 | | - isBuffering = true; |
583 | | - setStatusVisible(true, false); |
584 | | - } |
585 | | - status.setBufferPercent(busy, percent); |
586 | | - } |
587 | | - else { |
588 | | - if (isBuffering) { |
589 | | - Debug.log(Debug.INFO, "PLAY: we finished buffering"); |
590 | | - if (desiredState == Element.PLAY) |
591 | | - pipeline.setState(Element.PLAY); |
592 | | - isBuffering = false; |
593 | | - setStatusVisible(false, false); |
594 | | - } |
595 | | - status.setBufferPercent(busy, percent); |
596 | | - } |
597 | | - break; |
598 | | - case Message.STATE_CHANGED: |
599 | | - if (msg.getSrc() == pipeline) { |
600 | | - int old, next; |
| 601 | + busy = msg.parseBufferingBusy(); |
| 602 | + percent = msg.parseBufferingPercent(); |
601 | 603 | |
602 | | - old = msg.parseStateChangedOld(); |
603 | | - next = msg.parseStateChangedNext(); |
| 604 | + if (busy) { |
| 605 | + if (!isBuffering) { |
| 606 | + Debug.log(Debug.INFO, "PAUSE: we are buffering"); |
| 607 | + if (desiredState == Element.PLAY) { |
| 608 | + pipeline.setState(Element.PAUSE); |
| 609 | + } |
| 610 | + isBuffering = true; |
| 611 | + setStatusVisible(true, false); |
| 612 | + } |
| 613 | + status.setBufferPercent(busy, percent); |
| 614 | + } else { |
| 615 | + if (isBuffering) { |
| 616 | + Debug.log(Debug.INFO, "PLAY: we finished buffering"); |
| 617 | + if (desiredState == Element.PLAY) { |
| 618 | + pipeline.setState(Element.PLAY); |
| 619 | + } |
| 620 | + isBuffering = false; |
| 621 | + setStatusVisible(false, false); |
| 622 | + } |
| 623 | + status.setBufferPercent(busy, percent); |
| 624 | + } |
| 625 | + break; |
| 626 | + case Message.STATE_CHANGED: |
| 627 | + if (msg.getSrc() == pipeline) { |
| 628 | + int old, next; |
604 | 629 | |
605 | | - switch (next) { |
606 | | - case Element.PAUSE: |
607 | | - if (!isError && !isEOS) { |
608 | | - status.setMessage("Paused"); |
609 | | - } |
610 | | - status.setState(Status.STATE_PAUSED); |
611 | | - break; |
612 | | - case Element.PLAY: |
613 | | - if (!isError && !isEOS) { |
614 | | - status.setMessage("Playing"); |
615 | | - setStatusVisible(false, false); |
616 | | - if (!mayHide) |
617 | | - hideCounter = hideTimeout; |
618 | | - } |
619 | | - status.setState(Status.STATE_PLAYING); |
620 | | - break; |
621 | | - case Element.STOP: |
622 | | - if (!isError && !isEOS) { |
623 | | - status.setMessage("Stopped"); |
624 | | - setStatusVisible(true, false); |
625 | | - } |
626 | | - status.setState(Status.STATE_STOPPED); |
627 | | - break; |
| 630 | + old = msg.parseStateChangedOld(); |
| 631 | + next = msg.parseStateChangedNext(); |
| 632 | + |
| 633 | + switch (next) { |
| 634 | + case Element.PAUSE: |
| 635 | + if (!isError && !isEOS) { |
| 636 | + status.setMessage("Paused"); |
| 637 | + } |
| 638 | + status.setState(Status.STATE_PAUSED); |
| 639 | + break; |
| 640 | + case Element.PLAY: |
| 641 | + if (!isError && !isEOS) { |
| 642 | + status.setMessage("Playing"); |
| 643 | + setStatusVisible(false, false); |
| 644 | + if (!mayHide) { |
| 645 | + hideCounter = hideTimeout; |
| 646 | + } |
| 647 | + } |
| 648 | + status.setState(Status.STATE_PLAYING); |
| 649 | + break; |
| 650 | + case Element.STOP: |
| 651 | + if (!isError && !isEOS) { |
| 652 | + status.setMessage("Stopped"); |
| 653 | + setStatusVisible(true, false); |
| 654 | + } |
| 655 | + status.setState(Status.STATE_STOPPED); |
| 656 | + break; |
| 657 | + } |
628 | 658 | } |
629 | | - } |
630 | | - break; |
631 | | - case Message.BYTEPOSITION: |
632 | | - status.setBytePosition(msg.parseBytePosition()); |
633 | | - break; |
634 | | - default: |
635 | | - break; |
| 659 | + break; |
| 660 | + case Message.BYTEPOSITION: |
| 661 | + status.setBytePosition(msg.parseBytePosition()); |
| 662 | + break; |
| 663 | + default: |
| 664 | + break; |
636 | 665 | } |
637 | 666 | } |
638 | 667 | |
639 | 668 | public void doPause() { |
640 | | - isError = false; |
641 | | - isEOS = false; |
642 | | - status.setMessage("Pause"); |
643 | | - desiredState = Element.PAUSE; |
644 | | - pipeline.setState(desiredState); |
| 669 | + isError = false; |
| 670 | + isEOS = false; |
| 671 | + paused = true; |
| 672 | + status.setMessage("Pause"); |
| 673 | + desiredState = Element.PAUSE; |
| 674 | + pipeline.setState(desiredState); |
645 | 675 | } |
| 676 | + |
646 | 677 | public void doPlay() { |
647 | | - isError = false; |
648 | | - isEOS = false; |
649 | | - status.setMessage("Play"); |
650 | | - desiredState = Element.PLAY; |
651 | | - pipeline.setState(desiredState); |
| 678 | + isError = false; |
| 679 | + isEOS = false; |
| 680 | + paused = false; |
| 681 | + status.setMessage("Play"); |
| 682 | + desiredState = Element.PLAY; |
| 683 | + pipeline.setState(desiredState); |
652 | 684 | } |
| 685 | + |
653 | 686 | public void doStop() { |
654 | | - status.setMessage("Stop"); |
655 | | - desiredState = Element.STOP; |
656 | | - pipeline.setState(desiredState); |
| 687 | + status.setMessage("Stop"); |
| 688 | + desiredState = Element.STOP; |
| 689 | + pipeline.setState(desiredState); |
657 | 690 | } |
658 | 691 | |
659 | 692 | public void doSeek(double aPos) { |
660 | | - boolean res; |
661 | | - com.fluendo.jst.Event event; |
| 693 | + boolean res; |
| 694 | + com.fluendo.jst.Event event; |
662 | 695 | |
663 | | - /* get value, convert to PERCENT and construct seek event */ |
664 | | - event = com.fluendo.jst.Event.newSeek(Format.PERCENT, |
665 | | - (int) (aPos * 100.0 * Format.PERCENT_SCALE)); |
| 696 | + /* get value, convert to PERCENT and construct seek event */ |
| 697 | + event = com.fluendo.jst.Event.newSeek(Format.PERCENT, |
| 698 | + (int) (aPos * 100.0 * Format.PERCENT_SCALE)); |
666 | 699 | |
667 | | - /* send event to pipeline */ |
668 | | - res = pipeline.sendEvent(event); |
669 | | - if (!res) { |
670 | | - Debug.log(Debug.WARNING, "seek failed"); |
671 | | - } |
| 700 | + /* send event to pipeline */ |
| 701 | + res = pipeline.sendEvent(event); |
| 702 | + if (!res) { |
| 703 | + Debug.log(Debug.WARNING, "seek failed"); |
| 704 | + } |
672 | 705 | } |
673 | 706 | |
674 | 707 | public double getPlayPosition() { |
675 | | - return (double) pipeline.getPosition() / Clock.SECOND; |
| 708 | + return (double) pipeline.getPosition() / Clock.SECOND; |
676 | 709 | } |
677 | 710 | |
678 | 711 | public void newState(int aState) { |
679 | 712 | int ret; |
680 | 713 | switch (aState) { |
681 | | - case Status.STATE_PAUSED: |
682 | | - doPause(); |
683 | | - break; |
684 | | - case Status.STATE_PLAYING: |
685 | | - doPlay(); |
686 | | - break; |
687 | | - case Status.STATE_STOPPED: |
688 | | - doStop(); |
689 | | - break; |
690 | | - default: |
691 | | - break; |
| 714 | + case Status.STATE_PAUSED: |
| 715 | + doPause(); |
| 716 | + break; |
| 717 | + case Status.STATE_PLAYING: |
| 718 | + doPlay(); |
| 719 | + break; |
| 720 | + case Status.STATE_STOPPED: |
| 721 | + doStop(); |
| 722 | + break; |
| 723 | + default: |
| 724 | + break; |
692 | 725 | } |
693 | 726 | } |
| 727 | + |
694 | 728 | public void newSeek(double aPos) { |
695 | | - doSeek (aPos); |
| 729 | + doSeek(aPos); |
696 | 730 | } |
697 | 731 | |
698 | 732 | public synchronized void start() { |
699 | 733 | int res; |
700 | 734 | |
701 | | - Debug.info("Application starting"); |
| 735 | + Debug.info("Application starting"); |
702 | 736 | |
703 | 737 | addComponentListener(this); |
704 | 738 | addMouseListener(this); |
705 | 739 | addMouseMotionListener(this); |
706 | 740 | status.addStatusListener(this); |
707 | 741 | |
708 | | - if (autoPlay) |
709 | | - desiredState = Element.PLAY; |
710 | | - else |
711 | | - desiredState = Element.PAUSE; |
| 742 | + if (autoPlay) { |
| 743 | + desiredState = Element.PLAY; |
| 744 | + } else { |
| 745 | + desiredState = Element.PAUSE; |
| 746 | + } |
712 | 747 | |
713 | 748 | res = pipeline.setState(desiredState); |
714 | 749 | |
715 | | - if (statusThread != null) |
716 | | - throw new RuntimeException ("invalid state"); |
| 750 | + if (statusThread != null) { |
| 751 | + throw new RuntimeException("invalid state"); |
| 752 | + } |
717 | 753 | |
718 | | - statusThread = new Thread(this, "cortado-StatusThread-"+Debug.genId()); |
719 | | - statusRunning = true; |
| 754 | + statusThread = new Thread(this, "cortado-StatusThread-" + Debug.genId()); |
| 755 | + statusRunning = true; |
720 | 756 | statusThread.start(); |
721 | 757 | } |
722 | 758 | |
723 | 759 | public synchronized void stop() { |
724 | | - Debug.info("Application stopping..."); |
| 760 | + Debug.info("Application stopping..."); |
725 | 761 | |
726 | 762 | status.removeStatusListener(this); |
727 | 763 | removeMouseMotionListener(this); |
728 | 764 | removeMouseListener(this); |
729 | 765 | removeComponentListener(this); |
730 | 766 | |
731 | | - statusRunning = false; |
| 767 | + statusRunning = false; |
732 | 768 | desiredState = Element.STOP; |
733 | | - if (pipeline != null) { |
734 | | - try { |
735 | | - pipeline.setState(desiredState); |
736 | | - } |
737 | | - catch (Throwable e) { |
738 | | - } |
739 | | - try { |
740 | | - pipeline.shutDown(); |
741 | | - } |
742 | | - catch (Throwable e) { |
743 | | - } |
744 | | - pipeline = null; |
745 | | - } |
| 769 | + if (pipeline != null) { |
| 770 | + try { |
| 771 | + pipeline.setState(desiredState); |
| 772 | + } catch (Throwable e) { |
| 773 | + } |
| 774 | + try { |
| 775 | + pipeline.shutDown(); |
| 776 | + } catch (Throwable e) { |
| 777 | + } |
| 778 | + pipeline = null; |
| 779 | + } |
746 | 780 | if (statusThread != null) { |
747 | | - try { |
748 | | - statusThread.interrupt(); |
749 | | - } catch (Throwable e) { |
750 | | - } |
751 | | - try { |
752 | | - statusThread.join(); |
753 | | - } catch (Throwable e) { |
754 | | - } |
755 | | - statusThread = null; |
756 | | - } |
757 | | - Debug.info("Application stopped"); |
| 781 | + try { |
| 782 | + statusThread.interrupt(); |
| 783 | + } catch (Throwable e) { |
| 784 | + } |
| 785 | + try { |
| 786 | + statusThread.join(); |
| 787 | + } catch (Throwable e) { |
| 788 | + } |
| 789 | + statusThread = null; |
| 790 | + } |
| 791 | + Debug.info("Application stopped"); |
758 | 792 | } |
759 | 793 | |
760 | 794 | public int getStatusHeight() { |
761 | | - return statusHeight; |
| 795 | + return statusHeight; |
762 | 796 | } |
763 | 797 | |
764 | 798 | public int getShowStatus() { |
765 | | - return showStatus; |
| 799 | + return showStatus; |
766 | 800 | } |
| 801 | + |
| 802 | + /* HTML-5 media element methods */ |
| 803 | + public synchronized void play() { |
| 804 | + doPlay(); |
| 805 | + } |
| 806 | + |
| 807 | + public synchronized void pause() { |
| 808 | + doPause(); |
| 809 | + } |
767 | 810 | } |
768 | 811 | |
769 | 812 | /* dialog box */ |
| 813 | +class AppFrame extends Frame |
| 814 | + implements WindowListener { |
770 | 815 | |
771 | | -class AppFrame extends Frame |
772 | | - implements WindowListener { |
773 | | - public AppFrame(String title) { |
774 | | - super(title); |
775 | | - addWindowListener(this); |
776 | | - } |
777 | | - public void windowClosing(WindowEvent e) { |
778 | | - setVisible(false); |
779 | | - dispose(); |
780 | | - System.exit(0); |
781 | | - } |
782 | | - public void windowClosed(WindowEvent e) {} |
783 | | - public void windowDeactivated(WindowEvent e) {} |
784 | | - public void windowActivated(WindowEvent e) {} |
785 | | - public void windowDeiconified(WindowEvent e) {} |
786 | | - public void windowIconified(WindowEvent e) {} |
787 | | - public void windowOpened(WindowEvent e) {} |
788 | | -} |
| 816 | + public AppFrame(String title) { |
| 817 | + super(title); |
| 818 | + addWindowListener(this); |
| 819 | + } |
789 | 820 | |
790 | | -class AboutFrame extends AppFrame { |
791 | | - Dialog d; |
| 821 | + public void windowClosing(WindowEvent e) { |
| 822 | + setVisible(false); |
| 823 | + dispose(); |
| 824 | + System.exit(0); |
| 825 | + } |
792 | 826 | |
| 827 | + public void windowClosed(WindowEvent e) { |
| 828 | + } |
| 829 | + |
| 830 | + public void windowDeactivated(WindowEvent e) { |
| 831 | + } |
| 832 | + |
| 833 | + public void windowActivated(WindowEvent e) { |
| 834 | + } |
| 835 | + |
| 836 | + public void windowDeiconified(WindowEvent e) { |
| 837 | + } |
| 838 | + |
| 839 | + public void windowIconified(WindowEvent e) { |
| 840 | + } |
| 841 | + |
| 842 | + public void windowOpened(WindowEvent e) { |
| 843 | + } |
| 844 | +} |
| 845 | + |
| 846 | +class AboutFrame extends AppFrame { |
| 847 | + |
| 848 | + Dialog d; |
| 849 | + |
793 | 850 | public String getRevision() { |
794 | 851 | return "$Revision: 4170 $"; |
795 | 852 | } |
796 | | - |
797 | | - public AboutFrame(CortadoPipeline pipeline) { |
798 | | - super("AboutFrame"); |
799 | 853 | |
800 | | - Configure configure = new Configure(); |
801 | | - SourceInfo info = new SourceInfo(); |
| 854 | + public AboutFrame(CortadoPipeline pipeline) { |
| 855 | + super("AboutFrame"); |
802 | 856 | |
803 | | - setSize(200, 100); |
804 | | - Button dbtn; |
805 | | - d = new Dialog(this, "About Cortado", false); |
806 | | - d.setVisible(true); |
| 857 | + Configure configure = new Configure(); |
| 858 | + SourceInfo info = new SourceInfo(); |
807 | 859 | |
808 | | - TextArea ta = new TextArea("", 8, 40, TextArea.SCROLLBARS_NONE); |
809 | | - d.add(ta); |
810 | | - ta.appendText("This is Cortado " + configure.buildVersion + ".\n"); |
811 | | - ta.appendText("Brought to you by Wim Taymans.\n"); |
812 | | - ta.appendText("(C) Copyright 2004,2005,2006 Fluendo\n\n"); |
813 | | - ta.appendText("Built on " + configure.buildDate + "\n"); |
814 | | - ta.appendText("Built in " + configure.buildType + " mode.\n"); |
815 | | - ta.appendText("Built from SVN branch " + info.branch + ", revision " + |
816 | | - info.revision + "\n"); |
817 | | - ta.appendText("Running on Java VM " + System.getProperty("java.version") |
818 | | - + " from " + System.getProperty("java.vendor") + "\n"); |
| 860 | + setSize(200, 100); |
| 861 | + Button dbtn; |
| 862 | + d = new Dialog(this, "About Cortado", false); |
| 863 | + d.setVisible(true); |
819 | 864 | |
820 | | - if (pipeline.isAudioEnabled()) { |
821 | | - if (pipeline.usingJavaX) { |
822 | | - ta.appendText("Using the javax.sound backend."); |
823 | | - } else { |
824 | | - ta.appendText("Using the sun.audio backend.\n\n"); |
825 | | - ta.appendText("NOTE: you should install the Java(TM) from Sun for better audio quality."); |
826 | | - } |
827 | | - } |
| 865 | + TextArea ta = new TextArea("", 8, 40, TextArea.SCROLLBARS_NONE); |
| 866 | + d.add(ta); |
| 867 | + ta.appendText("This is Cortado " + configure.buildVersion + ".\n"); |
| 868 | + ta.appendText("Brought to you by Wim Taymans.\n"); |
| 869 | + ta.appendText("(C) Copyright 2004,2005,2006 Fluendo\n\n"); |
| 870 | + ta.appendText("Built on " + configure.buildDate + "\n"); |
| 871 | + ta.appendText("Built in " + configure.buildType + " mode.\n"); |
| 872 | + ta.appendText("Built from SVN branch " + info.branch + ", revision " + |
| 873 | + info.revision + "\n"); |
| 874 | + ta.appendText("Running on Java VM " + System.getProperty("java.version") + " from " + System.getProperty("java.vendor") + "\n"); |
828 | 875 | |
829 | | - d.add(dbtn = new Button("OK"), |
830 | | - BorderLayout.SOUTH); |
| 876 | + if (pipeline.isAudioEnabled()) { |
| 877 | + if (pipeline.usingJavaX) { |
| 878 | + ta.appendText("Using the javax.sound backend."); |
| 879 | + } else { |
| 880 | + ta.appendText("Using the sun.audio backend.\n\n"); |
| 881 | + ta.appendText("NOTE: you should install the Java(TM) from Sun for better audio quality."); |
| 882 | + } |
| 883 | + } |
831 | 884 | |
832 | | - Dimension dim = d.getPreferredSize(); |
833 | | - dim.height += 30; |
834 | | - d.setSize(dim); |
835 | | - dbtn.addActionListener(new ActionListener() { |
836 | | - public void actionPerformed(ActionEvent e) { |
837 | | - d.setVisible(false); |
838 | | - } |
839 | | - }); |
840 | | - d.addWindowListener(new WindowAdapter() { |
841 | | - public void windowClosing(WindowEvent e) { |
842 | | - d.setVisible(false); |
843 | | - } |
844 | | - }); |
845 | | - } |
| 885 | + d.add(dbtn = new Button("OK"), |
| 886 | + BorderLayout.SOUTH); |
| 887 | + |
| 888 | + Dimension dim = d.getPreferredSize(); |
| 889 | + dim.height += 30; |
| 890 | + d.setSize(dim); |
| 891 | + dbtn.addActionListener(new ActionListener() { |
| 892 | + |
| 893 | + public void actionPerformed(ActionEvent e) { |
| 894 | + d.setVisible(false); |
| 895 | + } |
| 896 | + }); |
| 897 | + d.addWindowListener(new WindowAdapter() { |
| 898 | + |
| 899 | + public void windowClosing(WindowEvent e) { |
| 900 | + d.setVisible(false); |
| 901 | + } |
| 902 | + }); |
| 903 | + } |
846 | 904 | } |