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