1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.actions.audio;
|
---|
3 |
|
---|
4 | import static org.openstreetmap.josm.tools.I18n.tr;
|
---|
5 | import static org.openstreetmap.josm.tools.I18n.trc;
|
---|
6 |
|
---|
7 | import java.awt.event.ActionEvent;
|
---|
8 | import java.awt.event.KeyEvent;
|
---|
9 | import java.io.IOException;
|
---|
10 |
|
---|
11 | import org.openstreetmap.josm.gui.layer.markerlayer.MarkerLayer;
|
---|
12 | import org.openstreetmap.josm.io.audio.AudioPlayer;
|
---|
13 | import org.openstreetmap.josm.io.audio.AudioUtil;
|
---|
14 | import org.openstreetmap.josm.spi.preferences.Config;
|
---|
15 | import org.openstreetmap.josm.tools.Shortcut;
|
---|
16 |
|
---|
17 | /**
|
---|
18 | * Jump the audio forward 10 seconds.
|
---|
19 | * @since 547
|
---|
20 | */
|
---|
21 | public class AudioFwdAction extends AbstractAudioAction {
|
---|
22 |
|
---|
23 | /**
|
---|
24 | * Constructs a new {@code AudioFwdAction}.
|
---|
25 | */
|
---|
26 | public AudioFwdAction() {
|
---|
27 | super(trc("audio", "Forward"), "audio-fwd", trc("audio", "Jump forward"),
|
---|
28 | Shortcut.registerShortcut("audio:forward", tr("Audio: {0}", trc("audio", "Forward")), KeyEvent.VK_F7, Shortcut.DIRECT), true);
|
---|
29 | }
|
---|
30 |
|
---|
31 | @Override
|
---|
32 | public void actionPerformed(ActionEvent e) {
|
---|
33 | try {
|
---|
34 | if (AudioPlayer.playing() || AudioPlayer.paused())
|
---|
35 | AudioPlayer.play(AudioPlayer.url(), AudioPlayer.position()
|
---|
36 | + Config.getPref().getDouble("audio.forwardbackamount", 10.0));
|
---|
37 | else
|
---|
38 | MarkerLayer.playAudio();
|
---|
39 | } catch (IOException | InterruptedException ex) {
|
---|
40 | AudioUtil.audioMalfunction(ex);
|
---|
41 | }
|
---|
42 | }
|
---|
43 | }
|
---|