X-Git-Url: https://gitweb.fperrin.net/?p=GpsPrune.git;a=blobdiff_plain;f=src%2Ftim%2Fprune%2Ffunction%2FPlayAudioFunction.java;h=44b77d9bc3ca7827081ff48f86a53c3143f9e27e;hp=2ac71e93b6e38bbbaab727aa1a6d7d421c4a117a;hb=HEAD;hpb=2302358503c38817e19f6e529f6c9e530aac0e86 diff --git a/src/tim/prune/function/PlayAudioFunction.java b/src/tim/prune/function/PlayAudioFunction.java index 2ac71e9..44b77d9 100644 --- a/src/tim/prune/function/PlayAudioFunction.java +++ b/src/tim/prune/function/PlayAudioFunction.java @@ -1,11 +1,11 @@ package tim.prune.function; +import java.awt.Desktop; import java.io.BufferedOutputStream; import java.io.ByteArrayInputStream; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; -import java.lang.reflect.InvocationTargetException; import javax.sound.sampled.AudioInputStream; import javax.sound.sampled.AudioSystem; @@ -146,17 +146,10 @@ public class PlayAudioFunction extends GenericFunction implements Runnable { try { - Class d = Class.forName("java.awt.Desktop"); - d.getDeclaredMethod("open", new Class[] {File.class}).invoke( - d.getDeclaredMethod("getDesktop").invoke(null), new Object[] {inFile}); - //above code mimics: Desktop.getDesktop().open(audioFile); + Desktop.getDesktop().open(inFile); played = true; } - catch (InvocationTargetException e) { - System.err.println("ITE: " + e.getCause().getClass().getName() + " - " + e.getCause().getMessage()); - played = false; - } - catch (Exception ignore) { + catch (IOException ignore) { System.err.println(ignore.getClass().getName() + " - " + ignore.getMessage()); played = false; }