Index: /trunk/src/org/openstreetmap/josm/tools/AudioPlayer.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/tools/AudioPlayer.java	(revision 9143)
+++ /trunk/src/org/openstreetmap/josm/tools/AudioPlayer.java	(revision 9144)
@@ -120,5 +120,5 @@
      * start at the beginning of the stream
      * @param url The resource to play, which must be a WAV file or stream
-     * @throws Exception audio fault exception, e.g. can't open stream,  unhandleable audio format
+     * @throws Exception audio fault exception, e.g. can't open stream, unhandleable audio format
      */
     public static void play(URL url) throws Exception {
@@ -130,5 +130,5 @@
      * @param url The resource to play, which must be a WAV file or stream
      * @param seconds The number of seconds into the audio to start playing
-     * @throws Exception audio fault exception, e.g. can't open stream,  unhandleable audio format
+     * @throws Exception audio fault exception, e.g. can't open stream, unhandleable audio format
      */
     public static void play(URL url, double seconds) throws Exception {
Index: /trunk/src/org/openstreetmap/josm/tools/AudioUtil.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/tools/AudioUtil.java	(revision 9143)
+++ /trunk/src/org/openstreetmap/josm/tools/AudioUtil.java	(revision 9144)
@@ -41,4 +41,7 @@
             return naturalLength / calibration;
         } catch (UnsupportedAudioFileException | IOException e) {
+            if (Main.isDebugEnabled()) {
+                Main.debug(e.getMessage());
+            }
             return 0.0;
         }
Index: /trunk/test/data/regress/6851/20111003_121216-wp.gpx
===================================================================
--- /trunk/test/data/regress/6851/20111003_121216-wp.gpx	(revision 9144)
+++ /trunk/test/data/regress/6851/20111003_121216-wp.gpx	(revision 9144)
@@ -0,0 +1,13 @@
+<?xml version="1.0" standalone="yes"?>
+<gpx version="1.1" creator="OSMtracker" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.topografix.com/GPX/1/1" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd">
+<wpt lat="48.0621400" lon="10.9932500"><ele>639</ele><time>2011-10-03T19:12:31Z</time><name>voice</name><link href="20111003_121226.wav" /></wpt>
+<wpt lat="48.0589500" lon="11.0025800"><ele>630</ele><time>2011-10-03T19:16:03Z</time><name>voice</name><link href="20111003_121557.wav" /></wpt>
+<wpt lat="48.0587600" lon="11.0046800"><ele>636</ele><time>2011-10-03T19:19:17Z</time><name>voice</name><link href="20111003_121911.wav" /></wpt>
+<wpt lat="48.0584800" lon="11.0074200"><ele>632</ele><time>2011-10-03T19:21:37Z</time><name>voice</name><link href="20111003_122131.wav" /></wpt>
+<wpt lat="48.0617300" lon="11.0086400"><ele>624</ele><time>2011-10-03T19:26:27Z</time><name>voice</name><link href="20111003_122620.wav" /></wpt>
+<wpt lat="48.0617600" lon="11.0086500"><ele>624</ele><time>2011-10-03T19:26:34Z</time><name>voice</name><link href="20111003_122627.wav" /></wpt>
+<wpt lat="48.0614600" lon="11.0093100"><ele>622</ele><time>2011-10-03T19:28:09Z</time><name>voice</name><link href="20111003_122803.wav" /></wpt>
+<wpt lat="48.0614600" lon="11.0093100"><ele>622</ele><time>2011-10-03T19:34:15Z</time><name>voice</name><link href="20111003_123409.wav" /></wpt>
+<wpt lat="48.0614500" lon="11.0093200"><ele>622</ele><time>2011-10-03T19:35:40Z</time><name>voice</name><link href="20111003_123533.wav" /></wpt>
+<wpt lat="48.0608100" lon="11.0095800"><ele>610</ele><time>2011-10-03T19:36:15Z</time><name>voice</name><link href="20111003_123605.wav" /></wpt>
+</gpx>
Index: /trunk/test/unit/org/openstreetmap/josm/tools/AudioPlayerTest.java
===================================================================
--- /trunk/test/unit/org/openstreetmap/josm/tools/AudioPlayerTest.java	(revision 9144)
+++ /trunk/test/unit/org/openstreetmap/josm/tools/AudioPlayerTest.java	(revision 9144)
@@ -0,0 +1,62 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.tools;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.openstreetmap.josm.JOSMFixture;
+import org.openstreetmap.josm.TestUtils;
+
+/**
+ * Unit tests of {@link AudioPlayer} class.
+ */
+public class AudioPlayerTest {
+
+    // We play wav files of about 4 seconds + pause, so define timeout at 10 seconds
+    private static final long MAX_DURATION = 10000;
+
+    /**
+     * Setup test.
+     */
+    @BeforeClass
+    public static void setUp() {
+        JOSMFixture.createUnitTestFixture().init();
+    }
+
+    /**
+     * Test method for {@code AudioPlayer#play(URL)}
+     * @throws Exception audio fault exception, e.g. can't open stream, unhandleable audio format
+     * @throws MalformedURLException wrong URL
+     */
+    @Test
+    public void testPlay() throws MalformedURLException, Exception {
+        File wav1 = new File(TestUtils.getRegressionDataFile(6851, "20111003_121226.wav"));
+        File wav2 = new File(TestUtils.getRegressionDataFile(6851, "20111003_121557.wav"));
+
+        for (File w : new File[] {wav1, wav2}) {
+            System.out.println("Playing " + w.toPath());
+            URL url = w.toURI().toURL();
+            long start = System.currentTimeMillis();
+            AudioPlayer.play(url);
+            assertTrue(AudioPlayer.playing());
+            assertFalse(AudioPlayer.paused());
+            AudioPlayer.pause();
+            assertFalse(AudioPlayer.playing());
+            assertTrue(AudioPlayer.paused());
+            AudioPlayer.play(url, AudioPlayer.position());
+            while (AudioPlayer.playing() && (System.currentTimeMillis() - start) < MAX_DURATION) {
+                Thread.sleep(500);
+            }
+            long duration = System.currentTimeMillis() - start;
+            System.out.println("Play finished after " + Utils.getDurationString(duration));
+            assertTrue(duration < MAX_DURATION);
+            AudioPlayer.reset();
+        }
+    }
+}
Index: /trunk/test/unit/org/openstreetmap/josm/tools/AudioUtilTest.java
===================================================================
--- /trunk/test/unit/org/openstreetmap/josm/tools/AudioUtilTest.java	(revision 9144)
+++ /trunk/test/unit/org/openstreetmap/josm/tools/AudioUtilTest.java	(revision 9144)
@@ -0,0 +1,39 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.tools;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.File;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.openstreetmap.josm.JOSMFixture;
+import org.openstreetmap.josm.TestUtils;
+
+/**
+ * Unit tests of {@link AudioUtil} class.
+ */
+public class AudioUtilTest {
+
+    private static final double EPSILON = 1e-11;
+
+    /**
+     * Setup test.
+     */
+    @BeforeClass
+    public static void setUp() {
+        JOSMFixture.createUnitTestFixture().init();
+    }
+
+    /**
+     * Test method for {@code AudioUtil#getCalibratedDuration(File)}
+     */
+    @Test
+    public void testGetCalibratedDuration() {
+        assertEquals(0.0, AudioUtil.getCalibratedDuration(new File("invalid_file")), EPSILON);
+        File wav1 = new File(TestUtils.getRegressionDataFile(6851, "20111003_121226.wav"));
+        assertEquals(4.8317006802721085, AudioUtil.getCalibratedDuration(wav1), EPSILON);
+        File wav2 = new File(TestUtils.getRegressionDataFile(6851, "20111003_121557.wav"));
+        assertEquals(4.924580498866213, AudioUtil.getCalibratedDuration(wav2), EPSILON);
+    }
+}
