1 | // License: GPL. Copyright 2007 by Immanuel Scholz and others
|
---|
2 | package org.openstreetmap.josm.actions.audio;
|
---|
3 |
|
---|
4 | import static org.openstreetmap.josm.tools.I18n.tr;
|
---|
5 |
|
---|
6 | import java.awt.event.ActionEvent;
|
---|
7 | import java.awt.event.KeyEvent;
|
---|
8 |
|
---|
9 | import org.openstreetmap.josm.Main;
|
---|
10 | import org.openstreetmap.josm.actions.JosmAction;
|
---|
11 | import org.openstreetmap.josm.gui.layer.markerlayer.MarkerLayer;
|
---|
12 | import org.openstreetmap.josm.tools.AudioPlayer;
|
---|
13 | import org.openstreetmap.josm.tools.Shortcut;
|
---|
14 |
|
---|
15 | public class AudioFwdAction extends JosmAction {
|
---|
16 |
|
---|
17 | private double amount;
|
---|
18 |
|
---|
19 | public AudioFwdAction() {
|
---|
20 | super(tr("Forward"), "audio-fwd", tr("Jump forward"),
|
---|
21 | Shortcut.registerShortcut("audio:forward", tr("Audio: {0}", tr("Forward")), KeyEvent.VK_F7, Shortcut.GROUP_DIRECT), true);
|
---|
22 | try {
|
---|
23 | amount = Double.parseDouble(Main.pref.get("audio.forwardbackamount","10.0"));
|
---|
24 | } catch (NumberFormatException e) {
|
---|
25 | amount = 10.0;
|
---|
26 | }
|
---|
27 | }
|
---|
28 |
|
---|
29 | public void actionPerformed(ActionEvent e) {
|
---|
30 | try {
|
---|
31 | if (AudioPlayer.playing() || AudioPlayer.paused())
|
---|
32 | AudioPlayer.play(AudioPlayer.url(), AudioPlayer.position() + amount);
|
---|
33 | else
|
---|
34 | MarkerLayer.playAudio();
|
---|
35 | } catch (Exception ex) {
|
---|
36 | AudioPlayer.audioMalfunction(ex);
|
---|
37 | }
|
---|
38 | }
|
---|
39 | }
|
---|