1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.actions.audio;
|
---|
3 |
|
---|
4 | import static org.openstreetmap.josm.gui.help.HelpUtil.ht;
|
---|
5 | import static org.openstreetmap.josm.tools.I18n.tr;
|
---|
6 | import static org.openstreetmap.josm.tools.I18n.trc;
|
---|
7 |
|
---|
8 | import java.awt.event.ActionEvent;
|
---|
9 | import java.awt.event.KeyEvent;
|
---|
10 |
|
---|
11 | import org.openstreetmap.josm.Main;
|
---|
12 | import org.openstreetmap.josm.actions.JosmAction;
|
---|
13 | import org.openstreetmap.josm.gui.layer.markerlayer.MarkerLayer;
|
---|
14 | import org.openstreetmap.josm.tools.AudioPlayer;
|
---|
15 | import org.openstreetmap.josm.tools.Shortcut;
|
---|
16 |
|
---|
17 | /**
|
---|
18 | * Jump the audio backward 10 seconds and start playing if paused.
|
---|
19 | * @since 547
|
---|
20 | */
|
---|
21 | public class AudioBackAction extends JosmAction {
|
---|
22 |
|
---|
23 | /**
|
---|
24 | * Constructs a new {@code AudioBackAction}.
|
---|
25 | */
|
---|
26 | public AudioBackAction() {
|
---|
27 | super(trc("audio", "Back"), "audio-back", trc("audio", "Jump back."),
|
---|
28 | Shortcut.registerShortcut("audio:back", tr("Audio: {0}", trc("audio", "Back")), KeyEvent.VK_F6, Shortcut.DIRECT), true);
|
---|
29 | this.putValue("help", ht("/Action/AudioBack"));
|
---|
30 | }
|
---|
31 |
|
---|
32 | @Override
|
---|
33 | public void actionPerformed(ActionEvent e) {
|
---|
34 | try {
|
---|
35 | if (AudioPlayer.playing() || AudioPlayer.paused())
|
---|
36 | AudioPlayer.play(AudioPlayer.url(), AudioPlayer.position()
|
---|
37 | - Main.pref.getDouble("audio.forwardbackamount", 10.0));
|
---|
38 | else
|
---|
39 | MarkerLayer.playAudio();
|
---|
40 | } catch (Exception ex) {
|
---|
41 | AudioPlayer.audioMalfunction(ex);
|
---|
42 | }
|
---|
43 | }
|
---|
44 | }
|
---|