1 | // License: GPL. Copyright 2007 by Immanuel Scholz and others
|
---|
2 | package org.openstreetmap.josm.actions.audio;
|
---|
3 |
|
---|
4 | import java.awt.event.ActionEvent;
|
---|
5 |
|
---|
6 | import org.openstreetmap.josm.Main;
|
---|
7 | import org.openstreetmap.josm.actions.JosmAction;
|
---|
8 | import org.openstreetmap.josm.tools.AudioPlayer;
|
---|
9 | import org.openstreetmap.josm.tools.Shortcut;
|
---|
10 |
|
---|
11 | abstract public class AudioFastSlowAction extends JosmAction {
|
---|
12 |
|
---|
13 | private double multiplier;
|
---|
14 |
|
---|
15 | public AudioFastSlowAction(String name, String iconName, String tooltip, Shortcut shortcut, boolean fast) {
|
---|
16 | super(name, iconName, tooltip, shortcut, true);
|
---|
17 | multiplier = Main.pref.getDouble("audio.fastfwdmultiplier","1.3");
|
---|
18 | if (! fast)
|
---|
19 | multiplier = 1.0 / multiplier;
|
---|
20 | }
|
---|
21 |
|
---|
22 | public void actionPerformed(ActionEvent e) {
|
---|
23 | double speed = AudioPlayer.speed();
|
---|
24 | if (speed * multiplier <= 0.1)
|
---|
25 | return;
|
---|
26 | try {
|
---|
27 | if (AudioPlayer.playing() || AudioPlayer.paused())
|
---|
28 | AudioPlayer.play(AudioPlayer.url(), AudioPlayer.position(), speed * multiplier);
|
---|
29 | } catch (Exception ex) {
|
---|
30 | AudioPlayer.audioMalfunction(ex);
|
---|
31 | }
|
---|
32 | }
|
---|
33 | }
|
---|