source: josm/trunk/src/org/openstreetmap/josm/actions/audio/AudioBackAction.java@ 12328

Last change on this file since 12328 was 12328, checked in by Don-vip, 9 years ago

fix #2089 - Add support for MP3, AIFF and AAC audio codecs (.mp3, .aac, .aif, .aiff files) if Java FX is on the classpath (i.e. Windows, macOS, nearly all major Linux distributions). The classes are not public on purpose, as the whole system will have to be simplified when all Linux distributions propose Java FX and so we can get rid of old Java Sound implementation.

  • Property svn:eol-style set to native
File size: 1.6 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.actions.audio;
3
4import static org.openstreetmap.josm.gui.help.HelpUtil.ht;
5import static org.openstreetmap.josm.tools.I18n.tr;
6import static org.openstreetmap.josm.tools.I18n.trc;
7
8import java.awt.event.ActionEvent;
9import java.awt.event.KeyEvent;
10import java.io.IOException;
11
12import org.openstreetmap.josm.Main;
13import org.openstreetmap.josm.actions.JosmAction;
14import org.openstreetmap.josm.gui.layer.markerlayer.MarkerLayer;
15import org.openstreetmap.josm.io.audio.AudioPlayer;
16import org.openstreetmap.josm.io.audio.AudioUtil;
17import org.openstreetmap.josm.tools.Shortcut;
18
19/**
20 * Jump the audio backward 10 seconds and start playing if paused.
21 * @since 547
22 */
23public 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}
Note: See TracBrowser for help on using the repository browser.