| 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.InputEvent;
|
|---|
| 8 | import java.awt.event.KeyEvent;
|
|---|
| 9 |
|
|---|
| 10 | import org.openstreetmap.josm.Main;
|
|---|
| 11 | import org.openstreetmap.josm.actions.JosmAction;
|
|---|
| 12 | import org.openstreetmap.josm.data.osm.DataSet;
|
|---|
| 13 | import org.openstreetmap.josm.gui.layer.OsmDataLayer;
|
|---|
| 14 | import org.openstreetmap.josm.gui.layer.markerlayer.MarkerLayer;
|
|---|
| 15 | import org.openstreetmap.josm.tools.AudioPlayer;
|
|---|
| 16 |
|
|---|
| 17 | public class AudioBackAction extends JosmAction {
|
|---|
| 18 |
|
|---|
| 19 | private double amount; // note, normally negative, i.e. jump backwards in time
|
|---|
| 20 |
|
|---|
| 21 | public AudioBackAction() {
|
|---|
| 22 | super(tr("Back"), "audio-back", tr("Jump back."), KeyEvent.VK_F6, 0, true);
|
|---|
| 23 | try {
|
|---|
| 24 | amount = - Double.parseDouble(Main.pref.get("audio.forwardbackamount","10.0"));
|
|---|
| 25 | } catch (NumberFormatException e) {
|
|---|
| 26 | amount = 10.0;
|
|---|
| 27 | }
|
|---|
| 28 | this.putValue("help", "Action/Back");
|
|---|
| 29 | }
|
|---|
| 30 |
|
|---|
| 31 | public void actionPerformed(ActionEvent e) {
|
|---|
| 32 | try {
|
|---|
| 33 | if (AudioPlayer.playing() || AudioPlayer.paused())
|
|---|
| 34 | AudioPlayer.play(AudioPlayer.url(), AudioPlayer.position() + amount);
|
|---|
| 35 | else
|
|---|
| 36 | MarkerLayer.playAudio();
|
|---|
| 37 | } catch (Exception ex) {
|
|---|
| 38 | AudioPlayer.audioMalfunction(ex);
|
|---|
| 39 | }
|
|---|
| 40 | }
|
|---|
| 41 | }
|
|---|