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 | import java.io.IOException;
|
---|
11 |
|
---|
12 | import org.openstreetmap.josm.Main;
|
---|
13 | import org.openstreetmap.josm.gui.layer.markerlayer.MarkerLayer;
|
---|
14 | import org.openstreetmap.josm.io.audio.AudioPlayer;
|
---|
15 | import org.openstreetmap.josm.io.audio.AudioUtil;
|
---|
16 | import org.openstreetmap.josm.tools.Shortcut;
|
---|
17 |
|
---|
18 | /**
|
---|
19 | * Jump the audio backward 10 seconds and start playing if paused.
|
---|
20 | * @since 547
|
---|
21 | */
|
---|
22 | public class AudioBackAction extends AbstractAudioAction {
|
---|
23 |
|
---|
24 | /**
|
---|
25 | * Constructs a new {@code AudioBackAction}.
|
---|
26 | */
|
---|
27 | public AudioBackAction() {
|
---|
28 | super(trc("audio", "Back"), "audio-back", trc("audio", "Jump back."),
|
---|
29 | Shortcut.registerShortcut("audio:back", tr("Audio: {0}", trc("audio", "Back")), KeyEvent.VK_F6, Shortcut.DIRECT), true);
|
---|
30 | this.putValue("help", ht("/Action/AudioBack"));
|
---|
31 | }
|
---|
32 |
|
---|
33 | @Override
|
---|
34 | public void actionPerformed(ActionEvent e) {
|
---|
35 | try {
|
---|
36 | if (AudioPlayer.playing() || AudioPlayer.paused())
|
---|
37 | AudioPlayer.play(AudioPlayer.url(), AudioPlayer.position()
|
---|
38 | - Main.pref.getDouble("audio.forwardbackamount", 10.0));
|
---|
39 | else
|
---|
40 | MarkerLayer.playAudio();
|
---|
41 | } catch (IOException | InterruptedException ex) {
|
---|
42 | AudioUtil.audioMalfunction(ex);
|
---|
43 | }
|
---|
44 | }
|
---|
45 | }
|
---|