Changeset 1685 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2009-06-21T12:02:15+02:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/UploadAction.java
r1679 r1685 482 482 handleGoneForKnownPrimitive(m.group(1), m.group(2)); 483 483 } else { 484 logger.warning(tr("Error header \"{0}\" does n't match expected pattern \"{1}\"",e.getErrorHeader(), pattern));484 logger.warning(tr("Error header \"{0}\" does not match expected pattern \"{1}\"",e.getErrorHeader(), pattern)); 485 485 handleGoneForUnknownPrimitive(e); 486 486 } -
trunk/src/org/openstreetmap/josm/gui/MapView.java
r1677 r1685 44 44 import org.openstreetmap.josm.gui.layer.markerlayer.MarkerLayer; 45 45 import org.openstreetmap.josm.gui.layer.markerlayer.PlayHeadMarker; 46 import org.openstreetmap.josm.tools.AudioPlayer; 46 47 47 48 /** … … 175 176 l.activeLayerChange(old, layer); 176 177 } 178 AudioPlayer.reset(); 177 179 repaint(); 178 180 } … … 210 212 } 211 213 layer.destroy(); 214 AudioPlayer.reset(); 212 215 } 213 216 … … 242 245 else 243 246 layers.add(pos, layer); 247 AudioPlayer.reset(); 244 248 } 245 249 … … 376 380 x.setEnabled(((MapMode)x.getAction()).layerIsSupported(layer)); 377 381 } 382 AudioPlayer.reset(); 378 383 repaint(); 379 384 } -
trunk/src/org/openstreetmap/josm/gui/layer/GpxLayer.java
r1658 r1685 203 203 Main.pref.put("markers.lastaudiodirectory", fc.getCurrentDirectory().getAbsolutePath()); 204 204 205 MarkerLayer ml = new MarkerLayer(new GpxData(), tr("Audio markers from {0}", name), getAssociatedFile(), me);206 205 File sel[] = fc.getSelectedFiles(); 207 206 if(sel != null) { … … 214 213 }); 215 214 } 215 } 216 217 String names = null; 218 for (int i = 0; i < sel.length; i++) { 219 if(names == null) 220 names = " ("; 221 else 222 names += ", "; 223 names += sel[i].getName(); 224 } 225 if(names != null) 226 names += ")"; 227 else 228 names = ""; 229 MarkerLayer ml = new MarkerLayer(new GpxData(), tr("Audio markers from {0}", name) + names, 230 getAssociatedFile(), me); 231 if(sel != null) 232 { 216 233 double firstStartTime = sel[0].lastModified()/1000.0 /* ms -> seconds */ - AudioUtil.getCalibratedDuration(sel[0]); 217 234 for (int i = 0; i < sel.length; i++) { -
trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/AudioMarker.java
r1677 r1685 19 19 private URL audioUrl; 20 20 private static AudioMarker recentlyPlayedMarker = null; 21 public 21 public double syncOffset; 22 22 public boolean timeFromAudio = false; // as opposed to from the GPX track 23 23 -
trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/MarkerLayer.java
r1646 r1685 345 345 346 346 public static void playAudio() { 347 playAdjacentMarker(null, true); 348 } 349 350 public static void playNextMarker() { 351 playAdjacentMarker(AudioMarker.recentlyPlayedMarker(), true); 352 } 353 354 public static void playPreviousMarker() { 355 playAdjacentMarker(AudioMarker.recentlyPlayedMarker(), false); 356 } 357 358 private static Marker getAdjacentMarker(Marker startMarker, boolean next, Layer layer) { 359 Marker previousMarker = null; 360 boolean nextTime = false; 361 if (layer.getClass() == MarkerLayer.class) { 362 MarkerLayer markerLayer = (MarkerLayer) layer; 363 for (Marker marker : markerLayer.data) { 364 if (marker == startMarker) { 365 if (next) 366 nextTime = true; 367 else { 368 if (previousMarker == null) 369 previousMarker = startMarker; // if no previous one, play the first one again 370 return previousMarker; 371 } 372 } 373 else if (marker.getClass() == AudioMarker.class) 374 { 375 if(nextTime || startMarker == null) 376 return marker; 377 previousMarker = marker; 378 } 379 } 380 if (nextTime) // there was no next marker in that layer, so play the last one again 381 return startMarker; 382 } 383 return null; 384 } 385 386 private static void playAdjacentMarker(Marker startMarker, boolean next) { 387 Marker m = null; 347 388 if (Main.map == null || Main.map.mapView == null) 348 389 return; 349 for (Layer layer : Main.map.mapView.getAllLayers()) { 350 if (layer.getClass() == MarkerLayer.class) { 351 MarkerLayer markerLayer = (MarkerLayer) layer; 352 for (Marker marker : markerLayer.data) { 353 if (marker.getClass() == AudioMarker.class) { 354 ((AudioMarker)marker).play(); 355 break; 356 } 357 } 358 } 359 } 360 } 361 362 public static void playNextMarker() { 363 playAdjacentMarker(true); 364 } 365 366 public static void playPreviousMarker() { 367 playAdjacentMarker(false); 368 } 369 370 private static void playAdjacentMarker(boolean next) { 371 Marker startMarker = AudioMarker.recentlyPlayedMarker(); 372 if (startMarker == null) { 373 // message? 374 return; 375 } 376 Marker previousMarker = null; 377 boolean nextTime = false; 378 if (Main.map == null || Main.map.mapView == null) 379 return; 380 for (Layer layer : Main.map.mapView.getAllLayers()) { 381 if (layer.getClass() == MarkerLayer.class) { 382 MarkerLayer markerLayer = (MarkerLayer) layer; 383 for (Marker marker : markerLayer.data) { 384 if (marker == startMarker) { 385 if (next) { 386 nextTime = true; 387 } else { 388 if (previousMarker == null) 389 previousMarker = startMarker; // if no previous one, play the first one again 390 ((AudioMarker)previousMarker).play(); 391 break; 392 } 393 } else if (nextTime && marker.getClass() == AudioMarker.class) { 394 ((AudioMarker)marker).play(); 395 return; 396 } 397 if (marker.getClass() == AudioMarker.class) 398 previousMarker = marker; 399 } 400 if (nextTime) { 401 // there was no next marker in that layer, so play the last one again 402 ((AudioMarker)startMarker).play(); 403 return; 404 } 405 } 406 } 390 Layer l = Main.map.mapView.getActiveLayer(); 391 if(l != null) 392 m = getAdjacentMarker(startMarker, next, l); 393 if(m == null) 394 { 395 for (Layer layer : Main.map.mapView.getAllLayers()) 396 { 397 m = getAdjacentMarker(startMarker, next, layer); 398 if(m != null) 399 break; 400 } 401 } 402 if(m != null) 403 ((AudioMarker)m).play(); 407 404 } 408 405 -
trunk/src/org/openstreetmap/josm/tools/AudioPlayer.java
r1245 r1685 190 190 } catch (Exception ex) { 191 191 return null; 192 } 193 } 194 195 public static void reset() { 196 if(audioPlayer != null) 197 { 198 try { 199 pause(); 200 } catch(Exception e) {} 201 audioPlayer.playingUrl = null; 192 202 } 193 203 } -
trunk/src/org/openstreetmap/josm/tools/AudioUtil.java
r1677 r1685 12 12 import org.openstreetmap.josm.Main; 13 13 14 15 14 /** 16 15 * Returns calibrated length of recording in seconds. … … 20 19 */ 21 20 public class AudioUtil { 22 23 21 static public double getCalibratedDuration(File wavFile) { 24 22 try { 25 23 AudioInputStream audioInputStream = AudioSystem.getAudioInputStream( 26 24 new URL("file:".concat(wavFile.getAbsolutePath()))); 27 25 AudioFormat audioFormat = audioInputStream.getFormat(); 28 26 long filesize = wavFile.length();
Note:
See TracChangeset
for help on using the changeset viewer.