Index: trunk/cortado/src/com/fluendo/jst/Message.java |
— | — | @@ -41,6 +41,7 @@ |
42 | 42 | public static final int SEGMENT_DONE = (1 << 17); |
43 | 43 | public static final int DURATION = (1 << 18); |
44 | 44 | public static final int RESOURCE = (1 << 19); |
| 45 | + public static final int BYTEPOSITION = (1 << 20); |
45 | 46 | |
46 | 47 | private com.fluendo.jst.Object src; |
47 | 48 | private int type; |
— | — | @@ -182,4 +183,13 @@ |
183 | 184 | public long parseDurationValue() { |
184 | 185 | return longVal; |
185 | 186 | } |
| 187 | + public static Message newBytePosition(com.fluendo.jst.Object src, long aPos) { |
| 188 | + Message msg = new Message(src, BYTEPOSITION); |
| 189 | + msg.longVal = aPos; |
| 190 | + return msg; |
| 191 | + } |
| 192 | + public long parseBytePosition() { |
| 193 | + return longVal; |
| 194 | + } |
| 195 | + |
186 | 196 | } |
Index: trunk/cortado/src/com/fluendo/player/Status.java |
— | — | @@ -70,6 +70,8 @@ |
71 | 71 | private double position = 0; |
72 | 72 | private long time; |
73 | 73 | private double duration; |
| 74 | + private long byteDuration; |
| 75 | + private long bytePosition; |
74 | 76 | |
75 | 77 | private String speaker = "\0\0\0\0\0\357\0\0\357U\27" |
76 | 78 | + "\36\0\0\0\0\357\357\0\0" + "\0\357U\30\0\0\0\357\0\357" |
— | — | @@ -217,8 +219,8 @@ |
218 | 220 | } |
219 | 221 | |
220 | 222 | private void paintSeekBar(Graphics g) { |
221 | | - Rectangle sr = getSeekBarRect(); |
222 | | - Rectangle tr = getThumbRect(); |
| 223 | + Rectangle sr = getSeekBarRect(); |
| 224 | + Rectangle tr = getThumbRect(); |
223 | 225 | |
224 | 226 | // Bounding rectangle |
225 | 227 | g.setColor(Color.darkGray); |
— | — | @@ -227,7 +229,7 @@ |
228 | 230 | // Progress bar |
229 | 231 | g.setColor(Color.gray); |
230 | 232 | g.fillRect(sr.x + 2, sr.y + 3, tr.x - (sr.x + 2), sr.height - 6); |
231 | | - |
| 233 | + |
232 | 234 | // Thumb |
233 | 235 | g.setColor(Color.white); |
234 | 236 | g.drawLine(tr.x + 1, tr.y, tr.x + tr.width - 1, tr.y); // Top |
— | — | @@ -331,16 +333,22 @@ |
332 | 334 | if (clicked == NONE) { |
333 | 335 | double newPosition; |
334 | 336 | |
335 | | - if (seconds < duration) |
| 337 | + if (seconds < duration || seekable) |
336 | 338 | time = (long) seconds; |
337 | 339 | else |
338 | 340 | time = (long) duration; |
339 | 341 | |
340 | | - newPosition = ((double) time) / duration; |
341 | | - if (newPosition != position) { |
342 | | - position = newPosition; |
343 | | - component.repaint(); |
344 | | - } |
| 342 | + if(duration > -1) { |
| 343 | + newPosition = ((double) time) / duration; |
| 344 | + if (newPosition != position) { |
| 345 | + position = newPosition; |
| 346 | + component.repaint(); |
| 347 | + } |
| 348 | + } else { |
| 349 | + newPosition = ((double)bytePosition) / (double)byteDuration; |
| 350 | + position = newPosition; |
| 351 | + component.repaint(); |
| 352 | + } |
345 | 353 | } |
346 | 354 | } |
347 | 355 | |
— | — | @@ -348,6 +356,22 @@ |
349 | 357 | duration = seconds; |
350 | 358 | component.repaint(); |
351 | 359 | } |
| 360 | + |
| 361 | + public void setByteDuration(long bytes) { |
| 362 | + this.byteDuration = bytes; |
| 363 | + if(duration == -1) { |
| 364 | + position = ((double)bytePosition) / (double)byteDuration; |
| 365 | + component.repaint(); |
| 366 | + } |
| 367 | + } |
| 368 | + |
| 369 | + public void setBytePosition(long bytes) { |
| 370 | + this.bytePosition = bytes; |
| 371 | + if(duration == -1) { |
| 372 | + position = ((double)bytePosition) / (double)byteDuration; |
| 373 | + component.repaint(); |
| 374 | + } |
| 375 | + } |
352 | 376 | |
353 | 377 | public void setMessage(String m) { |
354 | 378 | message = m; |
Index: trunk/cortado/src/com/fluendo/player/Cortado.java |
— | — | @@ -544,6 +544,8 @@ |
545 | 545 | long duration; |
546 | 546 | |
547 | 547 | duration = msg.parseDurationValue(); |
| 548 | + |
| 549 | + status.setByteDuration(duration); |
548 | 550 | |
549 | 551 | Debug.log(Debug.DEBUG, "got duration: "+duration); |
550 | 552 | if (duration != -1) { |
— | — | @@ -618,6 +620,9 @@ |
619 | 621 | } |
620 | 622 | } |
621 | 623 | break; |
| 624 | + case Message.BYTEPOSITION: |
| 625 | + status.setBytePosition(msg.parseBytePosition()); |
| 626 | + break; |
622 | 627 | default: |
623 | 628 | break; |
624 | 629 | } |
Index: trunk/cortado/src/com/fluendo/plugin/HTTPSrc.java |
— | — | @@ -34,6 +34,7 @@ |
35 | 35 | private InputStream input; |
36 | 36 | private long contentLength; |
37 | 37 | private long offset; |
| 38 | + private long offsetLastMessage = 0; |
38 | 39 | private long skipBytes = 0; |
39 | 40 | private String mime; |
40 | 41 | private Caps outCaps; |
— | — | @@ -164,6 +165,10 @@ |
165 | 166 | } |
166 | 167 | if (data.length <= 0) { |
167 | 168 | /* EOS */ |
| 169 | + |
| 170 | + postMessage (Message.newBytePosition(this, offset)); |
| 171 | + offsetLastMessage = offset; |
| 172 | + |
168 | 173 | try { |
169 | 174 | input.close(); |
170 | 175 | } |
— | — | @@ -179,6 +184,13 @@ |
180 | 185 | } |
181 | 186 | |
182 | 187 | offset += data.length; |
| 188 | + if(offsetLastMessage > offset) { |
| 189 | + offsetLastMessage = 0; |
| 190 | + } |
| 191 | + if(offset - offsetLastMessage > contentLength / 100) { |
| 192 | + postMessage (Message.newBytePosition(this, offset)); |
| 193 | + offsetLastMessage = offset; |
| 194 | + } |
183 | 195 | |
184 | 196 | // Negotiate capabilities |
185 | 197 | if (srcpad.getCaps() == null) { |